diff --git a/twilio/index.d.ts b/twilio/index.d.ts
index 022ac98440..b5b653f64a 100644
--- a/twilio/index.d.ts
+++ b/twilio/index.d.ts
@@ -6,11 +6,9 @@
///
///
///
-
-import * as Express from 'express';
-import * as Http from 'http';
-
-import Q = require('q');
+import Express = require("express");
+import Http = require("http");
+import Q = require("q");
declare interface twilio {
(sid?: string, tkn?: string, options?: twilio.ClientOptions): twilio.RestClient;
@@ -52,9 +50,11 @@ declare namespace twilio {
}
export interface RequestCallback { (err: any, data: any, response: Http.ClientResponse): void; }
- export interface BaseRequestCallback { (err: any, data: any): void; }
- export interface RestMethod { (args: any | BaseRequestCallback, callback?: RequestCallback): Q.Promise; }
+ export interface RestMethod {
+ (callback: RequestCallback): Q.Promise;
+ (args: any, callback?: RequestCallback): Q.Promise;
+ }
/// Resource stock interfaces
export interface BaseMappedResource {
@@ -448,7 +448,7 @@ declare namespace twilio {
}
// For interop with node middleware chains
- export interface MiddlewareFunction { (request: Http.ServerRequest, response: Http.ServerResponse, next: Express.NextFunction): void; }
+ export interface MiddlewareFunction { (request: Http.IncomingMessage, response: Http.ServerResponse, next: Express.NextFunction): void; }
export function webhook(authToken: string, options?: WebhookOptions): MiddlewareFunction;
export function webhook(options?: WebhookOptions): MiddlewareFunction;
@@ -581,7 +581,7 @@ declare namespace twilio {
post: RestMethod;
create: RestMethod;
}
- export interface CallResource extends CreatableMappedResource {
+ export interface CallResource extends CreatableMappedResource, ListableResource {
feedbackSummary: CallFeedbackSummaryResource;
}
diff --git a/twilio/twilio-tests.ts b/twilio/twilio-tests.ts
index 54823816eb..44ade2e246 100644
--- a/twilio/twilio-tests.ts
+++ b/twilio/twilio-tests.ts
@@ -18,11 +18,16 @@ client.calls.get(function(err: any, response: any) {
});
});
+// Using the alias described above
+client.calls.list(function(err: any, response: any) {
+ response.calls.forEach(function(call: any) {});
+});
+
//Get a list of calls made by this account, from this phone number
// GET /2010-04-01/Accounts/ACCOUNT_SID/Calls?From=+16513334455
client.calls.get({
from:'+16513334455'
-}, function(err: any, response: any) {
+}, function(err, response) {
response.calls.forEach(function(call: any) {
console.log('Received call from: ' + call.from);
console.log('This call\'s unique ID is: ' + call.sid);
@@ -31,14 +36,14 @@ client.calls.get({
//Get data for a specific call
// GET /2010-04-01/Accounts/ACCOUNT_SID/Calls/abc123...
-client.calls('abc123...').get(function(err: any, call: any) {
+client.calls('abc123...').get(function(err, call) {
console.log('This call\'s unique ID is: ' + call.sid);
console.log('This call was created at: ' + call.dateCreated);
});
//Get data for a specific call, for a specific account
// GET /2010-04-01/Accounts/AC.../Calls/abc123...
-client.accounts('AC...').calls('abc123...').get(function(err: any, response: any) {
+client.accounts('AC...').calls('abc123...').get(function(err, response) {
response.calls.forEach(function(call: any) {
console.log('Received call from: ' + call.from);
console.log('This call\'s unique ID is: ' + call.sid);
@@ -59,7 +64,7 @@ client.sms.messages.post({
// Delete a TwiML application
// DELETE /2010-04-01/Accounts/ACCOUNT_SID/Applications/APP...
-client.applications('APP...').delete(function(err: any, response: any, nodeResponse: any) {
+client.applications('APP...').delete(function(err, response, nodeResponse) {
//DELETE requests do not return data - if there was no error, it worked.
err ? console.log('There was an error') : console.log('it worked!');
});