africastalking
Advanced tools
Comparing version 0.0.1-a to 0.0.1-b
@@ -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` | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
56327
9
427
177
5
5
+ Addedbody-parser@^1.15.0
+ Addedbody-parser@1.20.3(transitive)
+ Addedbytes@3.1.2(transitive)
+ Addedcall-bind@1.0.7(transitive)
+ Addedcontent-type@1.0.5(transitive)
+ Addeddebug@2.6.9(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addeddepd@2.0.0(transitive)
+ Addeddestroy@1.2.0(transitive)
+ Addedee-first@1.1.1(transitive)
+ Addedes-define-property@1.0.0(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.4(transitive)
+ Addedgopd@1.0.1(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.0.3(transitive)
+ Addedhas-symbols@1.0.3(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedhttp-errors@2.0.0(transitive)
+ Addediconv-lite@0.4.24(transitive)
+ Addedmedia-typer@0.3.0(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedms@2.0.0(transitive)
+ Addedobject-inspect@1.13.3(transitive)
+ Addedon-finished@2.4.1(transitive)
+ Addedqs@6.13.0(transitive)
+ Addedraw-body@2.5.2(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedsetprototypeof@1.2.0(transitive)
+ Addedside-channel@1.0.6(transitive)
+ Addedstatuses@2.0.1(transitive)
+ Addedtoidentifier@1.0.1(transitive)
+ Addedtype-is@1.6.18(transitive)
+ Addedunpipe@1.0.0(transitive)