twilio 5.1.0 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/lib/base/BaseTwilio.js +2 -1
  2. package/lib/rest/Marketplace.d.ts +4 -0
  3. package/lib/rest/Marketplace.js +8 -0
  4. package/lib/rest/MarketplaceBase.d.ts +13 -0
  5. package/lib/rest/MarketplaceBase.js +31 -0
  6. package/lib/rest/Twilio.d.ts +5 -0
  7. package/lib/rest/Twilio.js +6 -0
  8. package/lib/rest/api/v2010/account/call.d.ts +1 -1
  9. package/lib/rest/api/v2010/account/message.d.ts +2 -2
  10. package/lib/rest/api/v2010/account/recording.d.ts +1 -1
  11. package/lib/rest/content/v2/content.d.ts +54 -0
  12. package/lib/rest/content/v2/content.js +18 -0
  13. package/lib/rest/content/v2/contentAndApprovals.d.ts +54 -0
  14. package/lib/rest/content/v2/contentAndApprovals.js +18 -0
  15. package/lib/rest/events/v1/eventType.d.ts +12 -0
  16. package/lib/rest/events/v1/eventType.js +4 -0
  17. package/lib/rest/marketplace/V1.d.ts +25 -0
  18. package/lib/rest/marketplace/V1.js +51 -0
  19. package/lib/rest/marketplace/v1/availableAddOn/availableAddOnExtension.d.ts +219 -0
  20. package/lib/rest/marketplace/v1/availableAddOn/availableAddOnExtension.js +187 -0
  21. package/lib/rest/marketplace/v1/availableAddOn.d.ts +231 -0
  22. package/lib/rest/marketplace/v1/availableAddOn.js +196 -0
  23. package/lib/rest/marketplace/v1/installedAddOn/installedAddOnExtension.d.ts +251 -0
  24. package/lib/rest/marketplace/v1/installedAddOn/installedAddOnExtension.js +214 -0
  25. package/lib/rest/marketplace/v1/installedAddOn/installedAddOnUsage.d.ts +84 -0
  26. package/lib/rest/marketplace/v1/installedAddOn/installedAddOnUsage.js +86 -0
  27. package/lib/rest/marketplace/v1/installedAddOn.d.ts +340 -0
  28. package/lib/rest/marketplace/v1/installedAddOn.js +294 -0
  29. package/lib/rest/marketplace/v1/moduleDataManagement.d.ts +147 -0
  30. package/lib/rest/marketplace/v1/moduleDataManagement.js +153 -0
  31. package/lib/rest/messaging/v1/tollfreeVerification.d.ts +13 -1
  32. package/lib/rest/messaging/v1/tollfreeVerification.js +4 -0
  33. package/lib/rest/numbers/V1.d.ts +5 -0
  34. package/lib/rest/numbers/V1.js +8 -0
  35. package/lib/rest/numbers/v1/portingPortIn.d.ts +3 -0
  36. package/lib/rest/numbers/v1/portingPortIn.js +2 -0
  37. package/lib/rest/numbers/v1/portingPortInPhoneNumber.d.ts +24 -6
  38. package/lib/rest/numbers/v1/portingPortInPhoneNumber.js +9 -3
  39. package/lib/rest/numbers/v1/portingPortability.d.ts +0 -12
  40. package/lib/rest/numbers/v1/portingPortability.js +0 -4
  41. package/lib/rest/numbers/v1/signingRequestConfiguration.d.ts +100 -0
  42. package/lib/rest/numbers/v1/signingRequestConfiguration.js +89 -0
  43. package/lib/rest/trusthub/v1/complianceTollfreeInquiries.d.ts +2 -0
  44. package/lib/rest/trusthub/v1/complianceTollfreeInquiries.js +2 -0
  45. package/package.json +1 -1
@@ -0,0 +1,196 @@
1
+ "use strict";
2
+ /*
3
+ * This code was generated by
4
+ * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
5
+ * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
6
+ * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
7
+ *
8
+ * Twilio - Marketplace
9
+ * This is the public Twilio REST API.
10
+ *
11
+ * NOTE: This class is auto generated by OpenAPI Generator.
12
+ * https://openapi-generator.tech
13
+ * Do not edit the class manually.
14
+ */
15
+ var __importDefault = (this && this.__importDefault) || function (mod) {
16
+ return (mod && mod.__esModule) ? mod : { "default": mod };
17
+ };
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.AvailableAddOnPage = exports.AvailableAddOnListInstance = exports.AvailableAddOnInstance = exports.AvailableAddOnContextImpl = void 0;
20
+ const util_1 = require("util");
21
+ const Page_1 = __importDefault(require("../../../base/Page"));
22
+ const deserialize = require("../../../base/deserialize");
23
+ const serialize = require("../../../base/serialize");
24
+ const utility_1 = require("../../../base/utility");
25
+ const availableAddOnExtension_1 = require("./availableAddOn/availableAddOnExtension");
26
+ class AvailableAddOnContextImpl {
27
+ constructor(_version, sid) {
28
+ this._version = _version;
29
+ if (!(0, utility_1.isValidPathParam)(sid)) {
30
+ throw new Error("Parameter 'sid' is not valid.");
31
+ }
32
+ this._solution = { sid };
33
+ this._uri = `/AvailableAddOns/${sid}`;
34
+ }
35
+ get extensions() {
36
+ this._extensions =
37
+ this._extensions ||
38
+ (0, availableAddOnExtension_1.AvailableAddOnExtensionListInstance)(this._version, this._solution.sid);
39
+ return this._extensions;
40
+ }
41
+ fetch(callback) {
42
+ const instance = this;
43
+ let operationVersion = instance._version, operationPromise = operationVersion.fetch({
44
+ uri: instance._uri,
45
+ method: "get",
46
+ });
47
+ operationPromise = operationPromise.then((payload) => new AvailableAddOnInstance(operationVersion, payload, instance._solution.sid));
48
+ operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
49
+ return operationPromise;
50
+ }
51
+ /**
52
+ * Provide a user-friendly representation
53
+ *
54
+ * @returns Object
55
+ */
56
+ toJSON() {
57
+ return this._solution;
58
+ }
59
+ [util_1.inspect.custom](_depth, options) {
60
+ return (0, util_1.inspect)(this.toJSON(), options);
61
+ }
62
+ }
63
+ exports.AvailableAddOnContextImpl = AvailableAddOnContextImpl;
64
+ class AvailableAddOnInstance {
65
+ constructor(_version, payload, sid) {
66
+ this._version = _version;
67
+ this.sid = payload.sid;
68
+ this.friendlyName = payload.friendly_name;
69
+ this.description = payload.description;
70
+ this.pricingType = payload.pricing_type;
71
+ this.configurationSchema = payload.configuration_schema;
72
+ this.url = payload.url;
73
+ this.links = payload.links;
74
+ this._solution = { sid: sid || this.sid };
75
+ }
76
+ get _proxy() {
77
+ this._context =
78
+ this._context ||
79
+ new AvailableAddOnContextImpl(this._version, this._solution.sid);
80
+ return this._context;
81
+ }
82
+ /**
83
+ * Fetch a AvailableAddOnInstance
84
+ *
85
+ * @param callback - Callback to handle processed record
86
+ *
87
+ * @returns Resolves to processed AvailableAddOnInstance
88
+ */
89
+ fetch(callback) {
90
+ return this._proxy.fetch(callback);
91
+ }
92
+ /**
93
+ * Access the extensions.
94
+ */
95
+ extensions() {
96
+ return this._proxy.extensions;
97
+ }
98
+ /**
99
+ * Provide a user-friendly representation
100
+ *
101
+ * @returns Object
102
+ */
103
+ toJSON() {
104
+ return {
105
+ sid: this.sid,
106
+ friendlyName: this.friendlyName,
107
+ description: this.description,
108
+ pricingType: this.pricingType,
109
+ configurationSchema: this.configurationSchema,
110
+ url: this.url,
111
+ links: this.links,
112
+ };
113
+ }
114
+ [util_1.inspect.custom](_depth, options) {
115
+ return (0, util_1.inspect)(this.toJSON(), options);
116
+ }
117
+ }
118
+ exports.AvailableAddOnInstance = AvailableAddOnInstance;
119
+ function AvailableAddOnListInstance(version) {
120
+ const instance = ((sid) => instance.get(sid));
121
+ instance.get = function get(sid) {
122
+ return new AvailableAddOnContextImpl(version, sid);
123
+ };
124
+ instance._version = version;
125
+ instance._solution = {};
126
+ instance._uri = `/AvailableAddOns`;
127
+ instance.page = function page(params, callback) {
128
+ if (params instanceof Function) {
129
+ callback = params;
130
+ params = {};
131
+ }
132
+ else {
133
+ params = params || {};
134
+ }
135
+ let data = {};
136
+ if (params["pageSize"] !== undefined)
137
+ data["PageSize"] = params["pageSize"];
138
+ if (params.pageNumber !== undefined)
139
+ data["Page"] = params.pageNumber;
140
+ if (params.pageToken !== undefined)
141
+ data["PageToken"] = params.pageToken;
142
+ const headers = {};
143
+ let operationVersion = version, operationPromise = operationVersion.page({
144
+ uri: instance._uri,
145
+ method: "get",
146
+ params: data,
147
+ headers,
148
+ });
149
+ operationPromise = operationPromise.then((payload) => new AvailableAddOnPage(operationVersion, payload, instance._solution));
150
+ operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
151
+ return operationPromise;
152
+ };
153
+ instance.each = instance._version.each;
154
+ instance.list = instance._version.list;
155
+ instance.getPage = function getPage(targetUrl, callback) {
156
+ const operationPromise = instance._version._domain.twilio.request({
157
+ method: "get",
158
+ uri: targetUrl,
159
+ });
160
+ let pagePromise = operationPromise.then((payload) => new AvailableAddOnPage(instance._version, payload, instance._solution));
161
+ pagePromise = instance._version.setPromiseCallback(pagePromise, callback);
162
+ return pagePromise;
163
+ };
164
+ instance.toJSON = function toJSON() {
165
+ return instance._solution;
166
+ };
167
+ instance[util_1.inspect.custom] = function inspectImpl(_depth, options) {
168
+ return (0, util_1.inspect)(instance.toJSON(), options);
169
+ };
170
+ return instance;
171
+ }
172
+ exports.AvailableAddOnListInstance = AvailableAddOnListInstance;
173
+ class AvailableAddOnPage extends Page_1.default {
174
+ /**
175
+ * Initialize the AvailableAddOnPage
176
+ *
177
+ * @param version - Version of the resource
178
+ * @param response - Response from the API
179
+ * @param solution - Path solution
180
+ */
181
+ constructor(version, response, solution) {
182
+ super(version, response, solution);
183
+ }
184
+ /**
185
+ * Build an instance of AvailableAddOnInstance
186
+ *
187
+ * @param payload - Payload response from the API
188
+ */
189
+ getInstance(payload) {
190
+ return new AvailableAddOnInstance(this._version, payload);
191
+ }
192
+ [util_1.inspect.custom](depth, options) {
193
+ return (0, util_1.inspect)(this.toJSON(), options);
194
+ }
195
+ }
196
+ exports.AvailableAddOnPage = AvailableAddOnPage;
@@ -0,0 +1,251 @@
1
+ /// <reference types="node" />
2
+ import { inspect, InspectOptions } from "util";
3
+ import Page, { TwilioResponsePayload } from "../../../../base/Page";
4
+ import Response from "../../../../http/response";
5
+ import V1 from "../../V1";
6
+ /**
7
+ * Options to pass to update a InstalledAddOnExtensionInstance
8
+ */
9
+ export interface InstalledAddOnExtensionContextUpdateOptions {
10
+ /** Whether the Extension should be invoked. */
11
+ enabled: boolean;
12
+ }
13
+ /**
14
+ * Options to pass to each
15
+ */
16
+ export interface InstalledAddOnExtensionListInstanceEachOptions {
17
+ /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
18
+ pageSize?: number;
19
+ /** Function to process each record. If this and a positional callback are passed, this one will be used */
20
+ callback?: (item: InstalledAddOnExtensionInstance, done: (err?: Error) => void) => void;
21
+ /** Function to be called upon completion of streaming */
22
+ done?: Function;
23
+ /** Upper limit for the number of records to return. each() guarantees never to return more than limit. Default is no limit */
24
+ limit?: number;
25
+ }
26
+ /**
27
+ * Options to pass to list
28
+ */
29
+ export interface InstalledAddOnExtensionListInstanceOptions {
30
+ /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
31
+ pageSize?: number;
32
+ /** Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit */
33
+ limit?: number;
34
+ }
35
+ /**
36
+ * Options to pass to page
37
+ */
38
+ export interface InstalledAddOnExtensionListInstancePageOptions {
39
+ /** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
40
+ pageSize?: number;
41
+ /** Page Number, this value is simply for client state */
42
+ pageNumber?: number;
43
+ /** PageToken provided by the API */
44
+ pageToken?: string;
45
+ }
46
+ export interface InstalledAddOnExtensionContext {
47
+ /**
48
+ * Fetch a InstalledAddOnExtensionInstance
49
+ *
50
+ * @param callback - Callback to handle processed record
51
+ *
52
+ * @returns Resolves to processed InstalledAddOnExtensionInstance
53
+ */
54
+ fetch(callback?: (error: Error | null, item?: InstalledAddOnExtensionInstance) => any): Promise<InstalledAddOnExtensionInstance>;
55
+ /**
56
+ * Update a InstalledAddOnExtensionInstance
57
+ *
58
+ * @param params - Parameter for request
59
+ * @param callback - Callback to handle processed record
60
+ *
61
+ * @returns Resolves to processed InstalledAddOnExtensionInstance
62
+ */
63
+ update(params: InstalledAddOnExtensionContextUpdateOptions, callback?: (error: Error | null, item?: InstalledAddOnExtensionInstance) => any): Promise<InstalledAddOnExtensionInstance>;
64
+ /**
65
+ * Provide a user-friendly representation
66
+ */
67
+ toJSON(): any;
68
+ [inspect.custom](_depth: any, options: InspectOptions): any;
69
+ }
70
+ export interface InstalledAddOnExtensionContextSolution {
71
+ installedAddOnSid: string;
72
+ sid: string;
73
+ }
74
+ export declare class InstalledAddOnExtensionContextImpl implements InstalledAddOnExtensionContext {
75
+ protected _version: V1;
76
+ protected _solution: InstalledAddOnExtensionContextSolution;
77
+ protected _uri: string;
78
+ constructor(_version: V1, installedAddOnSid: string, sid: string);
79
+ fetch(callback?: (error: Error | null, item?: InstalledAddOnExtensionInstance) => any): Promise<InstalledAddOnExtensionInstance>;
80
+ update(params: InstalledAddOnExtensionContextUpdateOptions, callback?: (error: Error | null, item?: InstalledAddOnExtensionInstance) => any): Promise<InstalledAddOnExtensionInstance>;
81
+ /**
82
+ * Provide a user-friendly representation
83
+ *
84
+ * @returns Object
85
+ */
86
+ toJSON(): InstalledAddOnExtensionContextSolution;
87
+ [inspect.custom](_depth: any, options: InspectOptions): string;
88
+ }
89
+ interface InstalledAddOnExtensionPayload extends TwilioResponsePayload {
90
+ extensions: InstalledAddOnExtensionResource[];
91
+ }
92
+ interface InstalledAddOnExtensionResource {
93
+ sid: string;
94
+ installed_add_on_sid: string;
95
+ friendly_name: string;
96
+ product_name: string;
97
+ unique_name: string;
98
+ enabled: boolean;
99
+ url: string;
100
+ }
101
+ export declare class InstalledAddOnExtensionInstance {
102
+ protected _version: V1;
103
+ protected _solution: InstalledAddOnExtensionContextSolution;
104
+ protected _context?: InstalledAddOnExtensionContext;
105
+ constructor(_version: V1, payload: InstalledAddOnExtensionResource, installedAddOnSid: string, sid?: string);
106
+ /**
107
+ * The unique string that we created to identify the InstalledAddOn Extension resource.
108
+ */
109
+ sid: string;
110
+ /**
111
+ * The SID of the InstalledAddOn resource to which this extension applies.
112
+ */
113
+ installedAddOnSid: string;
114
+ /**
115
+ * The string that you assigned to describe the resource.
116
+ */
117
+ friendlyName: string;
118
+ /**
119
+ * The name of the Product this Extension is used within.
120
+ */
121
+ productName: string;
122
+ /**
123
+ * An application-defined string that uniquely identifies the resource.
124
+ */
125
+ uniqueName: string;
126
+ /**
127
+ * Whether the Extension will be invoked.
128
+ */
129
+ enabled: boolean;
130
+ /**
131
+ * The absolute URL of the resource.
132
+ */
133
+ url: string;
134
+ private get _proxy();
135
+ /**
136
+ * Fetch a InstalledAddOnExtensionInstance
137
+ *
138
+ * @param callback - Callback to handle processed record
139
+ *
140
+ * @returns Resolves to processed InstalledAddOnExtensionInstance
141
+ */
142
+ fetch(callback?: (error: Error | null, item?: InstalledAddOnExtensionInstance) => any): Promise<InstalledAddOnExtensionInstance>;
143
+ /**
144
+ * Update a InstalledAddOnExtensionInstance
145
+ *
146
+ * @param params - Parameter for request
147
+ * @param callback - Callback to handle processed record
148
+ *
149
+ * @returns Resolves to processed InstalledAddOnExtensionInstance
150
+ */
151
+ update(params: InstalledAddOnExtensionContextUpdateOptions, callback?: (error: Error | null, item?: InstalledAddOnExtensionInstance) => any): Promise<InstalledAddOnExtensionInstance>;
152
+ /**
153
+ * Provide a user-friendly representation
154
+ *
155
+ * @returns Object
156
+ */
157
+ toJSON(): {
158
+ sid: string;
159
+ installedAddOnSid: string;
160
+ friendlyName: string;
161
+ productName: string;
162
+ uniqueName: string;
163
+ enabled: boolean;
164
+ url: string;
165
+ };
166
+ [inspect.custom](_depth: any, options: InspectOptions): string;
167
+ }
168
+ export interface InstalledAddOnExtensionSolution {
169
+ installedAddOnSid: string;
170
+ }
171
+ export interface InstalledAddOnExtensionListInstance {
172
+ _version: V1;
173
+ _solution: InstalledAddOnExtensionSolution;
174
+ _uri: string;
175
+ (sid: string): InstalledAddOnExtensionContext;
176
+ get(sid: string): InstalledAddOnExtensionContext;
177
+ /**
178
+ * Streams InstalledAddOnExtensionInstance records from the API.
179
+ *
180
+ * This operation lazily loads records as efficiently as possible until the limit
181
+ * is reached.
182
+ *
183
+ * The results are passed into the callback function, so this operation is memory
184
+ * efficient.
185
+ *
186
+ * If a function is passed as the first argument, it will be used as the callback
187
+ * function.
188
+ *
189
+ * @param { InstalledAddOnExtensionListInstanceEachOptions } [params] - Options for request
190
+ * @param { function } [callback] - Function to process each record
191
+ */
192
+ each(callback?: (item: InstalledAddOnExtensionInstance, done: (err?: Error) => void) => void): void;
193
+ each(params: InstalledAddOnExtensionListInstanceEachOptions, callback?: (item: InstalledAddOnExtensionInstance, done: (err?: Error) => void) => void): void;
194
+ /**
195
+ * Retrieve a single target page of InstalledAddOnExtensionInstance records from the API.
196
+ *
197
+ * The request is executed immediately.
198
+ *
199
+ * @param { string } [targetUrl] - API-generated URL for the requested results page
200
+ * @param { function } [callback] - Callback to handle list of records
201
+ */
202
+ getPage(targetUrl: string, callback?: (error: Error | null, items: InstalledAddOnExtensionPage) => any): Promise<InstalledAddOnExtensionPage>;
203
+ /**
204
+ * Lists InstalledAddOnExtensionInstance records from the API as a list.
205
+ *
206
+ * If a function is passed as the first argument, it will be used as the callback
207
+ * function.
208
+ *
209
+ * @param { InstalledAddOnExtensionListInstanceOptions } [params] - Options for request
210
+ * @param { function } [callback] - Callback to handle list of records
211
+ */
212
+ list(callback?: (error: Error | null, items: InstalledAddOnExtensionInstance[]) => any): Promise<InstalledAddOnExtensionInstance[]>;
213
+ list(params: InstalledAddOnExtensionListInstanceOptions, callback?: (error: Error | null, items: InstalledAddOnExtensionInstance[]) => any): Promise<InstalledAddOnExtensionInstance[]>;
214
+ /**
215
+ * Retrieve a single page of InstalledAddOnExtensionInstance records from the API.
216
+ *
217
+ * The request is executed immediately.
218
+ *
219
+ * If a function is passed as the first argument, it will be used as the callback
220
+ * function.
221
+ *
222
+ * @param { InstalledAddOnExtensionListInstancePageOptions } [params] - Options for request
223
+ * @param { function } [callback] - Callback to handle list of records
224
+ */
225
+ page(callback?: (error: Error | null, items: InstalledAddOnExtensionPage) => any): Promise<InstalledAddOnExtensionPage>;
226
+ page(params: InstalledAddOnExtensionListInstancePageOptions, callback?: (error: Error | null, items: InstalledAddOnExtensionPage) => any): Promise<InstalledAddOnExtensionPage>;
227
+ /**
228
+ * Provide a user-friendly representation
229
+ */
230
+ toJSON(): any;
231
+ [inspect.custom](_depth: any, options: InspectOptions): any;
232
+ }
233
+ export declare function InstalledAddOnExtensionListInstance(version: V1, installedAddOnSid: string): InstalledAddOnExtensionListInstance;
234
+ export declare class InstalledAddOnExtensionPage extends Page<V1, InstalledAddOnExtensionPayload, InstalledAddOnExtensionResource, InstalledAddOnExtensionInstance> {
235
+ /**
236
+ * Initialize the InstalledAddOnExtensionPage
237
+ *
238
+ * @param version - Version of the resource
239
+ * @param response - Response from the API
240
+ * @param solution - Path solution
241
+ */
242
+ constructor(version: V1, response: Response<string>, solution: InstalledAddOnExtensionSolution);
243
+ /**
244
+ * Build an instance of InstalledAddOnExtensionInstance
245
+ *
246
+ * @param payload - Payload response from the API
247
+ */
248
+ getInstance(payload: InstalledAddOnExtensionResource): InstalledAddOnExtensionInstance;
249
+ [inspect.custom](depth: any, options: InspectOptions): string;
250
+ }
251
+ export {};
@@ -0,0 +1,214 @@
1
+ "use strict";
2
+ /*
3
+ * This code was generated by
4
+ * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
5
+ * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
6
+ * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
7
+ *
8
+ * Twilio - Marketplace
9
+ * This is the public Twilio REST API.
10
+ *
11
+ * NOTE: This class is auto generated by OpenAPI Generator.
12
+ * https://openapi-generator.tech
13
+ * Do not edit the class manually.
14
+ */
15
+ var __importDefault = (this && this.__importDefault) || function (mod) {
16
+ return (mod && mod.__esModule) ? mod : { "default": mod };
17
+ };
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.InstalledAddOnExtensionPage = exports.InstalledAddOnExtensionListInstance = exports.InstalledAddOnExtensionInstance = exports.InstalledAddOnExtensionContextImpl = void 0;
20
+ const util_1 = require("util");
21
+ const Page_1 = __importDefault(require("../../../../base/Page"));
22
+ const deserialize = require("../../../../base/deserialize");
23
+ const serialize = require("../../../../base/serialize");
24
+ const utility_1 = require("../../../../base/utility");
25
+ class InstalledAddOnExtensionContextImpl {
26
+ constructor(_version, installedAddOnSid, sid) {
27
+ this._version = _version;
28
+ if (!(0, utility_1.isValidPathParam)(installedAddOnSid)) {
29
+ throw new Error("Parameter 'installedAddOnSid' is not valid.");
30
+ }
31
+ if (!(0, utility_1.isValidPathParam)(sid)) {
32
+ throw new Error("Parameter 'sid' is not valid.");
33
+ }
34
+ this._solution = { installedAddOnSid, sid };
35
+ this._uri = `/InstalledAddOns/${installedAddOnSid}/Extensions/${sid}`;
36
+ }
37
+ fetch(callback) {
38
+ const instance = this;
39
+ let operationVersion = instance._version, operationPromise = operationVersion.fetch({
40
+ uri: instance._uri,
41
+ method: "get",
42
+ });
43
+ operationPromise = operationPromise.then((payload) => new InstalledAddOnExtensionInstance(operationVersion, payload, instance._solution.installedAddOnSid, instance._solution.sid));
44
+ operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
45
+ return operationPromise;
46
+ }
47
+ update(params, callback) {
48
+ if (params === null || params === undefined) {
49
+ throw new Error('Required parameter "params" missing.');
50
+ }
51
+ if (params["enabled"] === null || params["enabled"] === undefined) {
52
+ throw new Error("Required parameter \"params['enabled']\" missing.");
53
+ }
54
+ let data = {};
55
+ data["Enabled"] = serialize.bool(params["enabled"]);
56
+ const headers = {};
57
+ headers["Content-Type"] = "application/x-www-form-urlencoded";
58
+ const instance = this;
59
+ let operationVersion = instance._version, operationPromise = operationVersion.update({
60
+ uri: instance._uri,
61
+ method: "post",
62
+ data,
63
+ headers,
64
+ });
65
+ operationPromise = operationPromise.then((payload) => new InstalledAddOnExtensionInstance(operationVersion, payload, instance._solution.installedAddOnSid, instance._solution.sid));
66
+ operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
67
+ return operationPromise;
68
+ }
69
+ /**
70
+ * Provide a user-friendly representation
71
+ *
72
+ * @returns Object
73
+ */
74
+ toJSON() {
75
+ return this._solution;
76
+ }
77
+ [util_1.inspect.custom](_depth, options) {
78
+ return (0, util_1.inspect)(this.toJSON(), options);
79
+ }
80
+ }
81
+ exports.InstalledAddOnExtensionContextImpl = InstalledAddOnExtensionContextImpl;
82
+ class InstalledAddOnExtensionInstance {
83
+ constructor(_version, payload, installedAddOnSid, sid) {
84
+ this._version = _version;
85
+ this.sid = payload.sid;
86
+ this.installedAddOnSid = payload.installed_add_on_sid;
87
+ this.friendlyName = payload.friendly_name;
88
+ this.productName = payload.product_name;
89
+ this.uniqueName = payload.unique_name;
90
+ this.enabled = payload.enabled;
91
+ this.url = payload.url;
92
+ this._solution = { installedAddOnSid, sid: sid || this.sid };
93
+ }
94
+ get _proxy() {
95
+ this._context =
96
+ this._context ||
97
+ new InstalledAddOnExtensionContextImpl(this._version, this._solution.installedAddOnSid, this._solution.sid);
98
+ return this._context;
99
+ }
100
+ /**
101
+ * Fetch a InstalledAddOnExtensionInstance
102
+ *
103
+ * @param callback - Callback to handle processed record
104
+ *
105
+ * @returns Resolves to processed InstalledAddOnExtensionInstance
106
+ */
107
+ fetch(callback) {
108
+ return this._proxy.fetch(callback);
109
+ }
110
+ update(params, callback) {
111
+ return this._proxy.update(params, callback);
112
+ }
113
+ /**
114
+ * Provide a user-friendly representation
115
+ *
116
+ * @returns Object
117
+ */
118
+ toJSON() {
119
+ return {
120
+ sid: this.sid,
121
+ installedAddOnSid: this.installedAddOnSid,
122
+ friendlyName: this.friendlyName,
123
+ productName: this.productName,
124
+ uniqueName: this.uniqueName,
125
+ enabled: this.enabled,
126
+ url: this.url,
127
+ };
128
+ }
129
+ [util_1.inspect.custom](_depth, options) {
130
+ return (0, util_1.inspect)(this.toJSON(), options);
131
+ }
132
+ }
133
+ exports.InstalledAddOnExtensionInstance = InstalledAddOnExtensionInstance;
134
+ function InstalledAddOnExtensionListInstance(version, installedAddOnSid) {
135
+ if (!(0, utility_1.isValidPathParam)(installedAddOnSid)) {
136
+ throw new Error("Parameter 'installedAddOnSid' is not valid.");
137
+ }
138
+ const instance = ((sid) => instance.get(sid));
139
+ instance.get = function get(sid) {
140
+ return new InstalledAddOnExtensionContextImpl(version, installedAddOnSid, sid);
141
+ };
142
+ instance._version = version;
143
+ instance._solution = { installedAddOnSid };
144
+ instance._uri = `/InstalledAddOns/${installedAddOnSid}/Extensions`;
145
+ instance.page = function page(params, callback) {
146
+ if (params instanceof Function) {
147
+ callback = params;
148
+ params = {};
149
+ }
150
+ else {
151
+ params = params || {};
152
+ }
153
+ let data = {};
154
+ if (params["pageSize"] !== undefined)
155
+ data["PageSize"] = params["pageSize"];
156
+ if (params.pageNumber !== undefined)
157
+ data["Page"] = params.pageNumber;
158
+ if (params.pageToken !== undefined)
159
+ data["PageToken"] = params.pageToken;
160
+ const headers = {};
161
+ let operationVersion = version, operationPromise = operationVersion.page({
162
+ uri: instance._uri,
163
+ method: "get",
164
+ params: data,
165
+ headers,
166
+ });
167
+ operationPromise = operationPromise.then((payload) => new InstalledAddOnExtensionPage(operationVersion, payload, instance._solution));
168
+ operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
169
+ return operationPromise;
170
+ };
171
+ instance.each = instance._version.each;
172
+ instance.list = instance._version.list;
173
+ instance.getPage = function getPage(targetUrl, callback) {
174
+ const operationPromise = instance._version._domain.twilio.request({
175
+ method: "get",
176
+ uri: targetUrl,
177
+ });
178
+ let pagePromise = operationPromise.then((payload) => new InstalledAddOnExtensionPage(instance._version, payload, instance._solution));
179
+ pagePromise = instance._version.setPromiseCallback(pagePromise, callback);
180
+ return pagePromise;
181
+ };
182
+ instance.toJSON = function toJSON() {
183
+ return instance._solution;
184
+ };
185
+ instance[util_1.inspect.custom] = function inspectImpl(_depth, options) {
186
+ return (0, util_1.inspect)(instance.toJSON(), options);
187
+ };
188
+ return instance;
189
+ }
190
+ exports.InstalledAddOnExtensionListInstance = InstalledAddOnExtensionListInstance;
191
+ class InstalledAddOnExtensionPage extends Page_1.default {
192
+ /**
193
+ * Initialize the InstalledAddOnExtensionPage
194
+ *
195
+ * @param version - Version of the resource
196
+ * @param response - Response from the API
197
+ * @param solution - Path solution
198
+ */
199
+ constructor(version, response, solution) {
200
+ super(version, response, solution);
201
+ }
202
+ /**
203
+ * Build an instance of InstalledAddOnExtensionInstance
204
+ *
205
+ * @param payload - Payload response from the API
206
+ */
207
+ getInstance(payload) {
208
+ return new InstalledAddOnExtensionInstance(this._version, payload, this._solution.installedAddOnSid);
209
+ }
210
+ [util_1.inspect.custom](depth, options) {
211
+ return (0, util_1.inspect)(this.toJSON(), options);
212
+ }
213
+ }
214
+ exports.InstalledAddOnExtensionPage = InstalledAddOnExtensionPage;