<commit_before>## Sms Owl Node.js Wrapper

This package is wrapper of Sms Owl REST API hosted at [https://smsowl.in](https://smsowl.in)
<commit_msg>Updated README file.<commit_after>## Sms Owl Node.js Wrapper

This package is wrapper of Sms Owl REST API hosted at [https://smsowl.in](https://smsowl.in)


### Installing Sms Owl package

Use following command to install npm package.

	$ npm install smsowl

### Requiring library

Library can be imported to node file with following line of code.

	var smsOwl = require("smsowl");


### Configuring credentials

Credentials should be configured before sending SMS.

	
    smsowl.configure({
        accountId: "YOUR-ACCOUNT-ID",
        apiKey: "YOUR-API-KEY"
    });


### Sending promotional SMS


##### sendPromotionalSms(senderId,to,message,smsType,callback)

 - senderId: Sender Id registered and approved in Sms Owl portal.
 - to: Either single number with country code or array of phone numbers.
 - message: Message to be sent.
 - smsType: It can have either of two values `normal` or `flash`
 - callback: Function to be called after success of failure.



		smsowl.sendPromotionalSms("TESTER",["+919876543210","+91123456789],"hello world","normal",function(error,result){
        	if(error){
            	// Handle Error
        	}else{
           		// Handle success
        	}
   		});


##### sendPromotionalSms(senderId,to,message,callback)

Same as above but smsType defaults to `normal`


### Sending Transactional SMS

##### smsowl.sendTransactionalSms(senderId,to,templateId,placeholderObject,callback);

 - senderId: Sender Id registered and approved in Sms Owl portal.
 - to: Destination number with country prefix. Only single number can be specified.
 - templateId: Template Id of message. Only template message can be send via transactional route.
 - placeholderObject: Placeholder values.

Lets assume templateId of "39ec9de0efa8a48cb6e60ee5" with following template.

	Hello {customerName}, your invoice amount is Rs. {amount}.

    smsowl.sendTransactionalSms("TESTER","+919876543210","39ec9de0efa8a48cb6e60ee5",{customerName:"Bob",amount:500},function(error,result){
        if(error){
            //Handle error
        }else{
            //Handle success
        }
    });



### Promise Pattern

Our API also support promise pattern. In above mentioned APIs just omit callback parameter and use returned promise. Following is example.

	smsowl.sendPromotionalSms("TESTER","+919876543210","hello world")
        .then(function(result){
          	//handle success
        },function(error){
            //handle error
        });


### Return object structure

On success for single SMS sent the following object is passed to 2nd parameter of callback or to 1st parameter of promise's success callback

	{
	    "status": "success",
	    "smsId": "79fee3193f5fd8f828737527"
	}



On success for bulk SMS sent the following object is passed to 2nd parameter (results) of callback or to 1st parameter of promise callback

	{
	    "status": "success",
	    "smsIds": [
	        "79fee3193f5fd8f828737527",
	        "af93998f580162afe8b7d031",
	        "3190d3b8d782f0ce7acfb1cf",
	        "a2d107d4a6ac8769aeeff2ab"
	    ]
	}

Of failure following object is sent to 1 parameter (error) of callback of to 1st parameter of promise's failure callback.
	
	{
	    "status": "error",
	    "message" : "Description of error"
	}
{'fraction_non_alphanumeric': 0.09610849056603774, 'fraction_numerical': 0.044516509433962265, 'mean_word_length': 3.4410994764397906, 'pattern_counts': {'":': 5, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, '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': '2288910', 'n_tokens_mistral': 1152, 'n_tokens_neox': 1003, 'n_words': 334}