-
Notifications
You must be signed in to change notification settings - Fork 8
/
ListInstanceResource.gs
35 lines (25 loc) · 1.21 KB
/
ListInstanceResource.gs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
@module resources/ListInstanceResource
Most Twilio REST resources follow a "List/Instance" model, where there is a single resource
like:
/Accounts/{SID}/Calls
which can be POSTed to or GETed to create a new instance, or query existing resources, etc.
Simlarly, these resources also have an "instance", which looks like:
/Accounts/{SID}/Calls/{some unique identifier}
Which can get GETed or maybe POSTed. For these relative simple/similar resources, this module
will generate a consistent REST interface for whatever methods the resource supports
*/
//var generate = require('./generate');
var ListInstanceResource_ = function (client, accountSid, resourceName, instanceMethods, listMethods) {
var baseResourceUrl = '/Accounts/' + accountSid + '/' + resourceName;
function Resource(instanceId) {
var resourceApi = {};
generate_.restFunctions(resourceApi, client, instanceMethods, '/Accounts/' + accountSid + '/' + resourceName + '/' + instanceId);
return resourceApi;
}
//generate rest functions for base resource
generate_.restFunctions(Resource, client, listMethods, baseResourceUrl);
//expose base url
Resource.baseResourceUrl = baseResourceUrl;
return Resource;
};