Comparing version 0.6.0 to 0.6.1
@@ -9,4 +9,13 @@ /** | ||
exports.Capability = require('./Capability'); | ||
exports.RestClient = require('./RestClient'); | ||
exports.TwimlResponse = require('./TwimlResponse'); | ||
var RestClient = require('./RestClient'); | ||
function initializer(sid,tkn) { | ||
return new RestClient(sid, tkn); | ||
} | ||
initializer.RestClient = RestClient; | ||
initializer.Capability = require('./Capability'); | ||
initializer.TwimlResponse = require('./TwimlResponse'); | ||
//public module interface is a function, which passes through to RestClient constructor | ||
module.exports = initializer; |
@@ -11,3 +11,4 @@ /** | ||
var request = require('request'), | ||
moduleinfo = require('../package.json'); | ||
moduleinfo = require('../package.json'), | ||
_ = require('underscore'); | ||
@@ -39,22 +40,21 @@ //REST API Config Defaults | ||
//REST Resource - shorthand for just "account" and "accounts" to match the REST API | ||
this.account = this.accounts = require('./resources/Accounts')(this); | ||
var accountResource = require('./resources/Accounts')(this); | ||
this.accounts = accountResource; | ||
//Create shorthand for common resource functions on the default account | ||
//mix the account object in with the client object - assume master account for resources | ||
_.extend(this,accountResource); | ||
//SMS shorthand | ||
this.sms = this.account.sms.messages.post; | ||
this.listSms = this.account.sms.messages.get; | ||
this.sendSms = this.accounts.sms.messages.post; | ||
this.listSms = this.accounts.sms.messages.get; | ||
this.getSms = function(sid, callback) { | ||
this.account.sms.messages(sid).get(callback); | ||
this.accounts.sms.messages(sid).get(callback); | ||
}; | ||
//Calls shorthand | ||
this.call = this.account.calls.post; | ||
this.listCalls = this.account.calls.get; | ||
this.makeCall = this.accounts.calls.post; | ||
this.listCalls = this.accounts.calls.get; | ||
this.getCall = function(sid, callback) { | ||
this.account.calls(sid).get(callback); | ||
this.accounts.calls(sid).get(callback); | ||
}; | ||
//Combine the two-step process of purchasing a phone number | ||
} | ||
@@ -61,0 +61,0 @@ |
{ | ||
"name":"twilio", | ||
"description":"A Twilio helper library", | ||
"version":"0.6.0", | ||
"version":"0.6.1", | ||
"author":"Kevin Whinnery <kevin.whinnery@gmail.com>", | ||
@@ -6,0 +6,0 @@ "contributors":[ |
@@ -20,2 +20,2 @@ # node-twilio | ||
Looking for 0.4.x documentation? That's [here](https://github.com/kwhinnery/twilio-node/blob/master/README-0-3-x.md). | ||
Looking for 0.4.x or earlier documentation? That's [here](https://github.com/kwhinnery/twilio-node/blob/master/old-help.md). |
@@ -9,3 +9,3 @@ var config = require('../config'), | ||
it('gets an unfiltered list of Accounts associated with this master account', function (done) { | ||
client.account.get(function (err, data, response) { | ||
client.accounts.get(function (err, data, response) { | ||
expect(data.accounts.length).toBeGreaterThan(0); | ||
@@ -19,3 +19,3 @@ done(); | ||
it('allows for the creation of subaccounts', function (done) { | ||
client.account.create({ | ||
client.accounts.create({ | ||
friendlyName:'TestAccountUno' | ||
@@ -27,3 +27,3 @@ }, function (err, data, response) { | ||
//Create a second account using the "post" function, and an uppercased name | ||
client.account.post({ | ||
client.accounts.post({ | ||
FriendlyName:'TestAccountDos' | ||
@@ -39,3 +39,3 @@ }, function (err2, data2, response2) { | ||
it('provides a means of getting account details for a specific sid', function (done) { | ||
client.account(newAccountSidOne).get(function (err, data) { | ||
client.accounts(newAccountSidOne).get(function (err, data) { | ||
expect(data.sid).toBe(newAccountSidOne); | ||
@@ -47,3 +47,3 @@ done(); | ||
it('provdes a means of updating and closing subaccounts', function (done) { | ||
client.account(newAccountSidOne).put({ | ||
client.accounts(newAccountSidOne).put({ | ||
Status:'closed' | ||
@@ -54,3 +54,3 @@ }, function (err, data) { | ||
client.account(newAccountSidTwo).update({ | ||
client.accounts(newAccountSidTwo).update({ | ||
status:'closed' | ||
@@ -57,0 +57,0 @@ }, function (err2, data2) { |
@@ -15,3 +15,3 @@ var config = require('../config'), | ||
it('creates a new application, configured with voice and SMS urls', function(done) { | ||
client.account.applications.create(app, function(err, data) { | ||
client.applications.create(app, function(err, data) { | ||
expect(data.voice_url).toBe(app.VoiceUrl); | ||
@@ -24,3 +24,3 @@ instanceSid = data.sid; | ||
it('gets information about an app with a specific sid', function(done) { | ||
client.account.applications(instanceSid).get(function(err,data) { | ||
client.applications(instanceSid).get(function(err,data) { | ||
expect(data.sid).toBe(instanceSid); | ||
@@ -32,3 +32,3 @@ done(); | ||
it('lists all apps with the friendly name we created (should be one)', function(done) { | ||
client.account.applications.get({ | ||
client.applications.get({ | ||
friendlyName:app.FriendlyName | ||
@@ -43,3 +43,3 @@ }, function(err, data) { | ||
it('updates details about an existing app', function(done) { | ||
client.account.applications(instanceSid).update({ | ||
client.applications(instanceSid).update({ | ||
voiceUrl:'http://lame.com/lameo' | ||
@@ -53,6 +53,6 @@ }, function(err, data) { | ||
it('deletes a created app', function(done) { | ||
client.account.applications(instanceSid).delete(function(err, data) { | ||
client.applications(instanceSid).delete(function(err, data) { | ||
expect(err).toBeFalsy(); | ||
if (!err) { | ||
client.account.applications(instanceSid).get(function(err2, data2, httpResponse) { | ||
client.accounts.applications(instanceSid).get(function(err2, data2, httpResponse) { | ||
expect(err2).toBeTruthy(); | ||
@@ -59,0 +59,0 @@ expect(err2.status).toBe(404); |
@@ -9,3 +9,3 @@ var config = require('../config'), | ||
it('gets a list of available phone numbers for a given country, with no filter', function (done) { | ||
client.account.availablePhoneNumbers('GB').local.get(function (err, data) { | ||
client.accounts.availablePhoneNumbers('GB').local.get(function (err, data) { | ||
expect(data.available_phone_numbers[0].phone_number).toMatch(/^\+44.*/); | ||
@@ -17,3 +17,3 @@ done(); | ||
it('gets a list of available phone numbers for a given country, with an area code filter', function (done) { | ||
client.account.availablePhoneNumbers('US').local.get({ | ||
client.accounts.availablePhoneNumbers('US').local.get({ | ||
areaCode:651 | ||
@@ -27,3 +27,3 @@ }, function (err, data) { | ||
it('gets a list of available TOLL FREE phone numbers for a given country, with no filter', function (done) { | ||
client.account.availablePhoneNumbers('US').tollFree.get(function (err, data) { | ||
client.accounts.availablePhoneNumbers('US').tollFree.get(function (err, data) { | ||
expect(data.available_phone_numbers[0].phone_number).toMatch(/^\+18.*/); | ||
@@ -35,3 +35,3 @@ done(); | ||
it('gets a list of available TOLL FREE phone numbers for a given country, with a filter', function (done) { | ||
client.account.availablePhoneNumbers('US').tollFree.get({ | ||
client.accounts.availablePhoneNumbers('US').tollFree.get({ | ||
Contains:'866******9' | ||
@@ -38,0 +38,0 @@ }, function (err, data) { |
@@ -11,3 +11,3 @@ var config = require('../config'), | ||
it('initiates a call from a purchased twilio number', function(done) { | ||
client.account.calls.create({ | ||
client.calls.create({ | ||
to:config.to, | ||
@@ -25,3 +25,3 @@ from:config.from, | ||
it('gets information about a specific call', function(done) { | ||
client.account.calls(instanceSid).get(function(err,data) { | ||
client.calls(instanceSid).get(function(err,data) { | ||
expect(data.sid).toBe(instanceSid); | ||
@@ -35,3 +35,3 @@ done(); | ||
client.call({ | ||
client.makeCall({ | ||
to:config.to, | ||
@@ -54,3 +54,3 @@ from:config.from, | ||
it('gets a list of calls for a specific number', function(done) { | ||
client.account.calls.get({ | ||
client.calls.get({ | ||
from:config.from | ||
@@ -57,0 +57,0 @@ }, function(err, data) { |
@@ -11,3 +11,3 @@ var config = require('../config'), | ||
it('gets a list of all connect apps', function(done) { | ||
client.account.connectApps.get(function(err, data) { | ||
client.accounts.connectApps.get(function(err, data) { | ||
expect(data.connect_apps.length).toBeGreaterThan(0); | ||
@@ -21,3 +21,3 @@ instanceSid = data.connect_apps[0].sid; | ||
var newName = 'Friendly'+new Date().getTime(); | ||
client.account.connectApps(instanceSid).update({ | ||
client.accounts.connectApps(instanceSid).update({ | ||
friendlyName:newName | ||
@@ -24,0 +24,0 @@ }, function(err, data) { |
@@ -39,2 +39,11 @@ var config = require('../config'), | ||
}); | ||
it('should initialize a new RestClient with a single line', function(done) { | ||
var oneLiner = require('../index')(config.accountSid, config.authToken); | ||
expect(oneLiner.getBaseUrl()).toBe('https://' + config.accountSid + ':' + config.authToken + '@' + 'api.twilio.com/2010-04-01'); | ||
oneLiner.accounts(config.accountSid).get(function(err, data) { | ||
expect(data.sid).toBe(config.accountSid); | ||
done(); | ||
}); | ||
}); | ||
}); |
@@ -12,3 +12,3 @@ var config = require('../config'), | ||
it('gets a list of already purchased incoming phone numbers', function(done) { | ||
client.account.incomingPhoneNumbers.get(function(err, data) { | ||
client.accounts.incomingPhoneNumbers.get(function(err, data) { | ||
expect(data.incoming_phone_numbers.length).toBeGreaterThan(0); | ||
@@ -22,3 +22,3 @@ instanceSid = data.incoming_phone_numbers[0].sid; | ||
it('gets details about a specific number, by sid', function(done) { | ||
client.account.incomingPhoneNumbers(instanceSid).get(function(err, data) { | ||
client.incomingPhoneNumbers(instanceSid).get(function(err, data) { | ||
expect(data.sid).toBe(instanceSid); | ||
@@ -31,3 +31,3 @@ done(); | ||
var randUrl = 'http://myapp.com/awesome/'+new Date().getTime(); | ||
client.account.incomingPhoneNumbers(instanceSid).update({ | ||
client.accounts.incomingPhoneNumbers(instanceSid).update({ | ||
voiceUrl:randUrl, | ||
@@ -44,3 +44,3 @@ SmsUrl:randUrl | ||
it('gets a list of Toll Free numbers for the given account', function(done) { | ||
client.account.incomingPhoneNumbers.tollFree.get(function(err, data) { | ||
client.incomingPhoneNumbers.tollFree.get(function(err, data) { | ||
expect(data.incoming_phone_numbers.length).toBeGreaterThan(0); | ||
@@ -53,3 +53,3 @@ expect(data.incoming_phone_numbers[0].phone_number).toMatch(/^\+18.*$/); | ||
it('gets a list of local numbers for the given account', function(done) { | ||
client.account.incomingPhoneNumbers.local.get(function(err, data) { | ||
client.incomingPhoneNumbers.local.get(function(err, data) { | ||
expect(data.incoming_phone_numbers.length).toBeGreaterThan(0); | ||
@@ -60,4 +60,4 @@ done(); | ||
xit('allows for the purchase of new phone numbers', function(done) { | ||
client.account.availablePhoneNumbers('US').local.get({ | ||
it('allows for the purchase of new phone numbers', function(done) { | ||
client.accounts.availablePhoneNumbers('US').local.get({ | ||
areaCode:'651' | ||
@@ -70,3 +70,3 @@ }, function(err, data) { | ||
var randUrl = 'http://myapp.com/awesome/'+new Date().getTime(); | ||
client.account.incomingPhoneNumbers.create({ | ||
client.incomingPhoneNumbers.create({ | ||
VoiceUrl:randUrl, | ||
@@ -83,4 +83,4 @@ phoneNumber:available | ||
xit('deletes a purchased phone number', function(done) { | ||
client.account.incomingPhoneNumbers(purchasedSid).delete(function(err,data,httpResponse) { | ||
it('deletes a purchased phone number', function(done) { | ||
client.incomingPhoneNumbers(purchasedSid).delete(function(err,data,httpResponse) { | ||
expect(httpResponse.statusCode).toBe(204); | ||
@@ -92,4 +92,4 @@ expect(err).toBeNull(); | ||
xit('allows for the purchase of new phone numbers using the subresource', function(done) { | ||
client.account.availablePhoneNumbers('US').local.get({ | ||
it('allows for the purchase of new phone numbers using the subresource', function(done) { | ||
client.availablePhoneNumbers('US').local.get({ | ||
areaCode:'651' | ||
@@ -102,3 +102,3 @@ }, function(err, data) { | ||
var randUrl = 'http://myapp.com/awesome/'+new Date().getTime(); | ||
client.account.incomingPhoneNumbers.local.create({ | ||
client.accounts.incomingPhoneNumbers.local.create({ | ||
VoiceUrl:randUrl, | ||
@@ -111,3 +111,3 @@ phoneNumber:available | ||
//cleanup, can be done async | ||
client.account.incomingPhoneNumbers(purchasedSid).delete(function(err,data,httpResponse) { | ||
client.accounts.incomingPhoneNumbers(purchasedSid).delete(function(err,data,httpResponse) { | ||
//test number deleted, no op for now | ||
@@ -121,4 +121,4 @@ }); | ||
//repeat, but with toll free numbers using the sub resource | ||
xit('allows for the purchase of new toll free phone numbers, using a sub resource', function(done) { | ||
client.account.availablePhoneNumbers('US').tollFree.get({ | ||
it('allows for the purchase of new toll free phone numbers, using a sub resource', function(done) { | ||
client.availablePhoneNumbers('US').tollFree.get({ | ||
areaCode:'866' | ||
@@ -131,3 +131,3 @@ }, function(err, data) { | ||
var randUrl = 'http://myapp.com/awesome/'+new Date().getTime(); | ||
client.account.incomingPhoneNumbers.tollFree.post({ | ||
client.accounts.incomingPhoneNumbers.tollFree.post({ | ||
VoiceUrl:randUrl, | ||
@@ -140,3 +140,3 @@ phoneNumber:available | ||
//cleanup, can be done async | ||
client.account.incomingPhoneNumbers(purchasedSid).delete(function(err,data,httpResponse) { | ||
client.accounts.incomingPhoneNumbers(purchasedSid).delete(function(err,data,httpResponse) { | ||
//test number deleted, no op for now | ||
@@ -143,0 +143,0 @@ }); |
@@ -13,3 +13,3 @@ var config = require('../config'), | ||
it('creates a caller ID verification request', function(done) { | ||
client.account.outgoingCallerIds.create({ | ||
client.accounts.outgoingCallerIds.create({ | ||
phoneNumber:'+16518675309' | ||
@@ -25,3 +25,3 @@ }, function(err,data) { | ||
it('gets a list of verified caller IDs', function(done) { | ||
client.account.outgoingCallerIds.get(function(err, data) { | ||
client.accounts.outgoingCallerIds.get(function(err, data) { | ||
expect(data.outgoing_caller_ids.length).toBeGreaterThan(0); | ||
@@ -35,3 +35,3 @@ instanceSid = data.outgoing_caller_ids[0].sid; | ||
it('gets details about a specific phone number SID', function(done) { | ||
client.account.outgoingCallerIds(instanceSid).get(function(err, data) { | ||
client.accounts.outgoingCallerIds(instanceSid).get(function(err, data) { | ||
expect(data.sid).toBe(instanceSid); | ||
@@ -43,3 +43,3 @@ done(); | ||
it('updates details about the caller ID', function(done) { | ||
client.account.outgoingCallerIds(instanceSid).update({ | ||
client.accounts.outgoingCallerIds(instanceSid).update({ | ||
friendlyName:'Something Friendly!' | ||
@@ -54,3 +54,3 @@ }, function(err, data) { | ||
xit('deletes a verified phone number', function(done) { | ||
client.account.outgoingCallerIds(instanceSid).delete(function(err, data, httpResponse) { | ||
client.accounts.outgoingCallerIds(instanceSid).delete(function(err, data, httpResponse) { | ||
expect(httpResponse.statusCode).toBe(204); | ||
@@ -57,0 +57,0 @@ done(); |
@@ -11,3 +11,3 @@ var config = require('../config'), | ||
it('sends an SMS message using a Twilio number', function(done) { | ||
client.sms({ | ||
client.sendSms({ | ||
To:config.to, | ||
@@ -14,0 +14,0 @@ from:config.from, |
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
59080
1181