0.1.2 • Published 5 years ago

jambopay-sms v0.1.2

Weekly downloads
1
License
ISC
Repository
-
Last release
5 years ago

JAMBOPAY SMS SDK FOR NODEJS

This is the unofficial node.js sdk for integration with the Jambopay SMS gateway

All of the methods called return promises and can therefore be easily chained

INSTALLATION

npm i jambopay-sms

1. GETTING STARTED

 Object.assign( global, { JP_SMS: require('jambopay-sms')});

The above makes the {jambopay-sms} module globally available as 'JP_SMS' in your project

1b. SENDER INSTANTIATION ( new JP_SMS('YOUR SENDER ID', 'YOUR DEFAULT COUNTRY CODE') )

const JAMBO_KENYA = new JP_SMS('KENYA','254');

You may instantiate as many sender objects as you require


2. SET THE ENDPOINT URL (.set_endpoint_url(remote_host_address))

( Not necessary if using the default one i.e https://sms.jambopay.co.ke )

Example:

 JAMBO_KENYA.set_endpoint_url( 'https://sms.jambopay.co.ke' );

3. LOGIN (.login(username,password))

Example:

JAMBO_KENYA
.login(
    'your_jambopay@user.email',
    'your_s3cu^34ccessP455w0RD'
)
.then(d => 
{
    
    //@ All subsequent operations are placed here  
    //e.g new instantiation that will inherit login state

    const JAMBO_AFRICA = new JP_SMS("AFRICA","001");

})
.catch(e => {

    //@ Handle the error 

})

This only needs to be done once regardless of the number of instantiations - all other instantiations will benefit from this login

This module handles basic authentication re-negotiation with the SMS gateway so that you don't have to. This fetches an authentication token for use with each request.

USER METHODS

A. SINGLE SMS (.sendOne)

JAMBO_KENYA
.sendOne(  
     'RECIPIENT_NUMBER',
     'MESSAGE TO RECIPIENT'
)
.then(d=>console.dir(d.data))
.catch(console.error)

Upon successful queueing, you will receive a confirmation email (upon completion) and a refund in the case of a failed SMS message


B. MULTIPLE SMS (.sendMany)

JAMBO_KENYA
.sendMany(  
    [
        ['RECIPIENT_NUMBER','MESSAGE TO RECIPIENT'],
        ['RECIPIENT_NUMBER','MESSAGE TO RECIPIENT'],
        ...
    ]
)
.then(d=>console.dir(d.data))
.catch(console.error)

Upon successful queueing, you will receive a confirmation email (upon completion) and all applicable refunds for failed SMS messages


C. SCHEDULED SMS

To effect this, pass an extra object in the format {start:Date,end:Date} to the single or multiple methods as shown below

1. SINGLE SCHEDULED SMS

JAMBO_KENYA
.sendOne(  
     'RECIPIENT_NUMBER',
     'MESSAGE TO RECIPIENT',
     { start: new Date('2019-06-13T15:10')}
)
.then(d=>console.dir(d.data))
.catch(console.error)

2. MULTIPLE SCHEDULED SMS

JAMBO_KENYA
.sendMany(  
    [
        ['RECIPIENT_NUMBER','MESSAGE TO RECIPIENT'],
        ['RECIPIENT_NUMBER','MESSAGE TO RECIPIENT'],
        ...
    ],
    { start: new Date('2019-06-13T15:10')}
)
.then(d=>console.dir(d.data))
.catch(console.error)

An 'end' parameter can be passed (where necessary). If one is not passed, a two hour period from the 'start' will be effected.

Please note that if any message in the batch fails, retries will be made until either it's effective 'end' or the system maximum number of retries is reached.

A sending summary email will only be sent if either all messages were successfully sent or the defined 'end' of the schedule period has reached.


D. GET USER BALANCE (.getBalance)

JAMBO_KENYA
.getBalance(   )
.then(d=>console.dir(d.data))
.catch(console.error)

This will return all the relevant balances for the loged in user.


E. USER PROFILE (.getProfile)

JAMBO_KENYA
.getProfile(   )
.then(d=>console.dir(d.data))
.catch(console.error)

This will return the loged in user's profile.

F. PASSWORD RECOVERY (.recoverPassword)

JAMBO_KENYA
.recoverPassword('USER EMAIL ADDRESS')
.then(d=>console.dir(d.data))
.catch(console.error)

This will send a one time password recovery link to the user-provided email address (provided that an active account is linked to it).

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.1

5 years ago