@appsolutely/gatewayapi

Node Gatewayapi SMS API wrapper

Usage no npm install needed!

<script type="module">
  import appsolutelyGatewayapi from 'https://cdn.skypack.dev/@appsolutely/gatewayapi';
</script>

README

@appsolutely/gatewayapi

Node library for Gatewayapi.com

For documentation of the API, see Gatewayapi.com

This is not gatewayapi's official node library.

Installation


npm install @appsolutely/gatewayapi

Loading and configuring the module


// CommonJS
const gatewayapi = require('@appsolutely/gatewayapi');
gatewayapi.setApiToken('YOUR GATEWAYAPI TOKEN')

// ES Module
import * as gatewayapi from '@appsolutely/gatewayapi';
gatewayapi.setApiToken('YOUR GATEWAYAPI TOKEN')

Send SMS

const payload: gatewayapi.payloadObject = {
        sender: 'exampleSender',
        message: "Example message string to %FIRSTNAME% %LASTNAME%",
        callback_url: 'https://api.example.com/callback',
        userref: '123abc',
        tags: ['%FIRSTNAME%', '%LASTNAME%'],
        recipients: [
            {
                msisdn: 4712345678,
                tagvalues: ['Barack', 'Obama']
            },
        ],
}

gatewayapi.sendSMS(payload).then(response => {
    //Do something with the response
}).catch(error => {
    //Do something with the error
})

Check balance

gatewayapi.checkBalance(payload).then(response => {
    //Do something with the response
}).catch(error => {
    //Do something with the error
})