1.0.7 • Published 6 years ago

africaistalking v1.0.7

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

africaistalking

A promise-based API wrapper with cors enabled for africastalking

Install

npm i africaistalking --save

usage

Sending SMS

import africaistalking from 'africaistalking'

const username='MyAppUsername'
const message='Hello You!'
const to='+254711XXXYYY,+254733YYYZZZ'
const apikey='MyAppApiKey'
const from="MyCompany"  //optional parameter,check africastalking.com for documentation on how to use


africaistalking(username, message, to, apikey)
  .then(res => console.log(res))
  .catch(err => console.log(err))

Usage with Redux/redux-promise-middleware

Dispatch africaistalking API as the value of the payload property of the action.

import africaistalking from 'africaistalking'

 

 const sendMessage = (username, message, to, apikey) => ({

  type: 'SEND_MESSAGE',

  payload: africaistalking(username, message, to, apikey)

})

A pending action is immediately dispatched.

{

     type: 'SEND_MESSAGE_PENDING'

     }

Once the promise is settled, a second action will be dispatched. If the promise is resolved a fulfilled action is dispatched.

{

  type: 'SEND_MESSAGE_FULFILLED'

  payload: {

    ...

  }

}

On the other hand, if the promise is rejected, a rejected action is dispatched.

{

  type: 'SEND_MESSAGE_REJECTED'

  error: true,

  payload: {

    ...

  }

}
1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago