Wrapper for Clickatell SMS gateway
This module try to be a node module which wraps the Clickatell's API, how it is offered for other languages.
I've supposed that you have installed NodeJS and npm, so
npm install clickatell-api
To use this module, you must have a Clickatell account and the API IDs for the API that you would to use, although so far the module only offer http/s, so you must only need one, :D
Then, let's start
var clickatell = ;var cktClient = ;var cktHttp = cktClient;var promise = httpClient;promise;
but "I need https", no worries, just pass and options object with the parameter
secured and it'll use https
// All the code is the same an expcetion of thisvar ckHttp = cktClient;
but actually the
secured options parameter may be an object with the security parameters that node
https.request accepts, if you don't need them so it use the defaults, then pass true, to let clickatell-api that you want to use https.
So far, as mentioned, the module provides only the HTTP/S API and from it, it provides the next methods:
The Clickatell HTTP API doesn't send JSON data, basically it sends the response in plain text, moreover the errors are sent as a HTTP 200 response with the word 'ERR:'.
First of all, how you'll have realised the methods return a promise, so it uses promises, concretely Q promise. Secondly, this tiny module parse the response and return the response as an object when the request is successful and the promise is resolved, otherwise an instance of Error is returned rejecting the promise.
Then, bear in mind that, you know that you should receive an object with the fields specified in the text plain responses (e.g. fieldName: Value), regarding that they will be case-sensitive as they are sent by Clickatell. However, in some responses, Clickatell response with a list of field value, as kind of on JSON array, but more ugly, plain text, and this module is not smart enough to return an array of objects, so it returns an array of values for each field, and the position of one element of the array of one filed should be associated with element in the same position of the array of the another field.
I've started this project in a Hackathon and so far I don't know if I will spend time in the future enhancing and providing the whole Clickatell's API, however if somebody is interested in it, then fork it or contribute sending pull requests.
Just MIT, in details in LICENSE file