<commit_before># clickatell-api
This module try to be a node module which wraps the [Clickatell](http://www.clickatell.com)'s API, how it is offered for other languages.

## How to install

I've supposed that you have installed NodeJS and npm, so

```js
npm install clickatell-api
```

## How to use

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

```js
var clickatell = require('clickatell-api');

var cktClient = clickatell('YOUR USER', 'YOUR PASSWORD');
var cktHttp = cktClient('YOUR HTTP API ID');

var promise = httpClient.sendMessage('447777888999', 'This is a sms from node-clickatell-api :P');

promise.then(
  function (respObj) {
    console.info('Awesome, it successed');
    console.info('The id of that message is:' + respObj.ID);
  },

  function (err) {
    console.error('Sucks, something was wrong');

    if (err.code) {
      // Yes, the library create JS Error from Clickatell error messages
      // and add the message as usual, but it also populates the error
      // under code, however the errors are not always from Clickatell,
      // so check the property
      console.error('Clickatell report an error with code: ' + err.code);
    }

    console.error('Error message:' + err.message);
  }
);
```

but "I need https", no worries, just pass and options object with the parameter ```secured``` and it'll use https

```js

// All the code is the same an expcetion of this
var ckHttp = cktClient('YOUR HTTP API ID', {secured: true});

```

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.

## What API's methods, so far, it provides

So far, as mentioned, the module provides only the HTTP/S API and from it, it provides the next methods:
* sendMessage (/http/sendmsg)
* queryMessage (/http/querymsg)
* deleteMessage (/http/delmsg)
* getBalance (/http/getbalance)
* routeCoverage (/utils/routeCoverage)
* getMessageChargeByCliId (/http/getmsgcharge - with climsgid)
* getMessageChargeByApiId (/http/getmsgcharge - with apimsgid)
* spendVourcher (/http/token_pay)
* startBatch (/http_batch/startbatch)
* sendItem (/http_batch/senditem)
* quicksend (/http_batch/quicksend)<commit_msg>Fixed issues in README example code<commit_after># clickatell-api
This module try to be a node module which wraps the [Clickatell](http://www.clickatell.com)'s API, how it is offered for other languages.

## How to install

I've supposed that you have installed NodeJS and npm, so

```js
npm install clickatell-api
```

## How to use

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

```js
var clickatell = require('clickatell-api');

var cktClient = clickatell('YOUR USER', 'YOUR PASSWORD');
var cktHttp = cktClient.http('YOUR HTTP API ID');

var promise = httpClient.sendMessage('447777888999', 'This is a sms from node-clickatell-api :P');

promise.then(
  function (respObj) {
    console.info('Awesome, it successed');
    console.info('The id of that message is:' + respObj.ID);
  },

  function (err) {
    console.error('Sucks, something was wrong');

    if (err.code) {
      // Yes, the library create JS Error from Clickatell error messages
      // and add the message as usual, but it also populates the error
      // under code, however the errors are not always from Clickatell,
      // so check the property
      console.error('Clickatell report an error with code: ' + err.code);
    }

    console.error('Error message:' + err.message);
  }
);
```

but "I need https", no worries, just pass and options object with the parameter ```secured``` and it'll use https

```js

// All the code is the same an expcetion of this
var ckHttp = cktClient.http('YOUR HTTP API ID', {secured: true});

```

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.

## What API's methods, so far, it provides

So far, as mentioned, the module provides only the HTTP/S API and from it, it provides the next methods:
* sendMessage (/http/sendmsg)
* queryMessage (/http/querymsg)
* deleteMessage (/http/delmsg)
* getBalance (/http/getbalance)
* routeCoverage (/utils/routeCoverage)
* getMessageChargeByCliId (/http/getmsgcharge - with climsgid)
* getMessageChargeByApiId (/http/getmsgcharge - with apimsgid)
* spendVourcher (/http/token_pay)
* startBatch (/http_batch/startbatch)
* sendItem (/http_batch/senditem)
* quicksend (/http_batch/quicksend)
{'fraction_non_alphanumeric': 0.1073013311819282, 'fraction_numerical': 0.004840661557079467, 'mean_word_length': 4.060204081632653, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1232994', 'n_tokens_mistral': 1575, 'n_tokens_neox': 1485, 'n_words': 614}