exotel-node
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -1,2 +0,3 @@ | ||
var request = require('request'); | ||
var request = require('request'); | ||
var parseString = require('xml2js').parseString; | ||
@@ -19,3 +20,9 @@ module.exports = { | ||
makeRequest(url, params, callback); | ||
makeRequest(url, params, function(error, response) { | ||
if (error) { | ||
callback(error, null); | ||
} else { | ||
callback(null, response.TwilioResponse.SMSMessage); | ||
} | ||
}); | ||
}, | ||
@@ -33,4 +40,23 @@ | ||
makeRequest(url, params, callback); | ||
makeRequest(url, params, function(error, response) { | ||
if (error) { | ||
callback(error, null); | ||
} else { | ||
callback(null, response.TwilioResponse.Call); | ||
} | ||
}); | ||
}, | ||
getCallDetails : function(id, callback) { | ||
var url = 'https://' + this.exotel_sid + ':' + this.exotel_token + '@twilix.exotel.in/v1/Accounts/' + this.exotel_sid +'/Calls/' + id; | ||
request.get(url, function (error, response, body) { | ||
if (error) { | ||
callback(error, response); | ||
} else { | ||
parseString(response.body, {explicitArray: false}, function(err, result) { | ||
callback(null, result.TwilioResponse.Call); | ||
}); | ||
} | ||
}); | ||
} | ||
} | ||
@@ -43,5 +69,7 @@ | ||
} else { | ||
callback(null, body); | ||
parseString(response.body, {explicitArray: false}, function(err, result) { | ||
callback(null, result); | ||
}); | ||
} | ||
}); | ||
} |
{ | ||
"name": "exotel-node", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "A NodeJs wrapper for Exotel APIs", | ||
@@ -27,4 +27,5 @@ "main": "exotel.js", | ||
"dependencies": { | ||
"request": "^2.69.0" | ||
"request": "^2.69.0", | ||
"xml2js": "^0.4.16" | ||
} | ||
} |
# Exotel NodeJs Wrapper | ||
A NodeJs wrapper for Exotel APIs | ||
A NodeJs wrapper for Exotel APIs. Converts Exotel XML response to Javascript object. | ||
@@ -15,2 +15,3 @@ ```npm install exotel-node``` | ||
* [Connect call](#connect_call) | ||
* [Get call details](#get_call_details) | ||
@@ -20,3 +21,5 @@ ### <a name="send_sms"></a>Send SMS | ||
Exotel.sendSMS(TO_NUMBER, MESSAGE, function(error, response) { | ||
console.log(response); | ||
if (!error) { | ||
console.log(response); | ||
} | ||
}); | ||
@@ -28,7 +31,29 @@ ``` | ||
Exotel.connectCall(AGENT_NUMBER, CUSTOMER_NUMBER, function(error, response) { | ||
console.log(response); | ||
if (!error) { | ||
console.log(response); | ||
} | ||
}); | ||
``` | ||
### <a name="get_call_details"></a>Get call details | ||
```javascript | ||
Exotel.getCallDetails(CALL_SID, function(error, response) { | ||
if (!error) { | ||
console.log(response); | ||
console.log(response.DateCreated); // Date created | ||
console.log(response.DateUpdated); // Date updated | ||
console.log(response.AccountSid); // Account SID used to create the call | ||
console.log(response.To); // Customer number/2nd number in API call | ||
console.log(response.From); // Agent number/1st number in API call | ||
console.log(response.Status); // Call status | ||
console.log(response.StartTime); // Call start time | ||
console.log(response.EndTime); // Call end time | ||
console.log(response.Duration); // Call duration | ||
console.log(response.Price); // Call cost | ||
console.log(response.RecordingUrl); // Call recording url | ||
} | ||
}); | ||
``` | ||
--- | ||
### Submit issues | ||
You can raise an issue in this repo or mail me at sidhant@hashexclude.com |
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
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
4917
62
57
2
+ Addedxml2js@^0.4.16
+ Addedsax@1.4.1(transitive)
+ Addedxml2js@0.4.23(transitive)
+ Addedxmlbuilder@11.0.1(transitive)