Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

africastalking

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

africastalking - npm Package Compare versions

Comparing version 0.0.1-a to 0.0.1-b

lib/airtime.js

6

lib/index.js

@@ -10,2 +10,4 @@ 'use strict';

var SMS = require('./sms');
var USSD = require('./ussd');
var Airtime = require('./airtime');

@@ -56,4 +58,4 @@

this.VOICE = null;
this.USSD = null;
this.AIRTIME = null;
this.USSD = USSD;
this.AIRTIME = new Airtime(this.options);
}

@@ -60,0 +62,0 @@

{
"name": "africastalking",
"version": "0.0.1a",
"version": "0.0.1b",
"description": "Official AfricasTalking node.js API wrapper",

@@ -27,2 +27,3 @@ "main": "lib/index.js",

"bluebird": "^3.1.1",
"body-parser": "^1.15.0",
"lodash": "^4.0.0",

@@ -33,6 +34,8 @@ "unirest": "^0.4.2",

"devDependencies": {
"express": "^4.13.4",
"istanbul": "^0.4.2",
"mocha": "^2.3.4",
"should": "^8.1.1"
"should": "^8.1.1",
"supertest": "^1.2.0"
}
}

@@ -14,4 +14,4 @@ # africastalking-node.js

var options = {
apiKey: 'fb752d3417021812f0961y6c9464832dd1adb1e555c73f1e7c32bcc006488674',
username: 'salama'
apiKey: 'YOUR_API_KEY',
username: 'YOUR_USERNAME',
format: 'json' // or xml

@@ -24,2 +24,3 @@ };

**`Important`: If you register a callback URL with the API, always remember to acknowledge the receipt of any data it sends by responding with an HTTP `200`; e.g. `res.status(200);` for express**.

@@ -56,6 +57,6 @@ ### SMS

> You can register a callback URL with us and we will forward any messages that are sent to your account the moment they arrive.
> You can register a callback URL with us and we will forward any messages that are sent to your account the moment they arrive.
> [Read more](http://docs.africastalking.com/sms/callback)
- `fetchMessages(options)`:
- `fetchMessages(options)`: Manually retrieve your messages.

@@ -83,5 +84,62 @@ - `lastReceivedId`: "This is the id of the message that you last processed". Defaults to `0`. `REQUIRED`

### Voice **TODO**
### [USSD](http://docs.africastalking.com/ussd)
> Processing USSD requests using our API is very easy once your account is set up. In particular, you will need to:
> - Register a service code with us.
> - Register a URL that we can call whenever we get a request from a client coming into our system.
>
> Once you register your callback URL, any requests that we receive belonging to you will trigger a callback that sends the request data to that page using HTTP POST.
> [Read more.](http://docs.africastalking.com/ussd)
If you are using connect-like frameworks (*express*), you could use the middleware `AfricasTalking.USSD(handler)`:
`handler(params, next)`: Process USSD request and call `next()` when done.
- `params`: contains the following user data sent by Africa's Talking servers: `sessionId`, `serviceCode`, `phoneNumber` and `text`.
- `next(args)`: `args` must contain the following:
- `response`: Text to display on user's device. `REQUIRED`
- `endSession`: Boolean to decide whether to **END** session or to **CON**tinue it. `REQUIRED`
```javascript
// example (express)
app.post('/natoil-ussd', new AfricasTalking.USSD((params, next) => {
var endSession = false;
var message = '';
var session = sessions.get(params.sessionId);
var user = db.getUserByPhone(params.phoneNumber);
if (params.text === '') {
message = "Welcome to Nat Oil \n";
message += "1: For account info \n";
message += "2: For lost gas cylinder";
} else if (params.text === '1') {
message = user.getInfo();
endSession = true;
} else if (params.text === '2') {
message = "Enter 1 for recovery \n";
message += "Enter 2 for lost and found";
endSession = true;
} else {
message = "Invalid option";
endSession = true;
}
next({
response: message,
endSession: endSession
});
}));
```
## Voice **TODO**
```javascript
var voice = AfricasTalking.VOICE;

@@ -94,11 +152,22 @@ ```

- Media upload
- Remember to send back an HTTP 200.
### USSD **TODO**
### Airtime
```javascript
var ussd = AfricasTalking.USSD;
var airtime = AfricasTalking.AIRTIME;
```
- Make helpers that will construct proper `text/plain` data to send back to Africa's Taking API when it comes calling. [Read more](http://docs.africastalking.com/ussd)
- `airtime.send(options)`: Send airtime
- `recipients`: An array of the following
- `phoneNumber`: Receipient of airtime
- `amount`: Amount sent. `>= 10 && <= 10K`
```javascript
airtime.send(options)
.then(success)
.catch(error);
```
### Account

@@ -112,13 +181,2 @@ ```javascript

### Airtime **TODO**
```javascript
var airtime = AfricasTalking.AIRTIME;
```
- `send(options)`: Send airtime
- `recipients`: An array of the following
- `phoneNumber`: Receipient of airtime
- `amount`: Amount sent. `>= 10 && <= 10K`
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc