diff --git a/src/rest/iam/v1/key.ts b/src/rest/iam/v1/key.ts new file mode 100644 index 000000000..36a8f4faa --- /dev/null +++ b/src/rest/iam/v1/key.ts @@ -0,0 +1,194 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Iam + * This is the public Twilio REST API. + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { inspect, InspectOptions } from "util"; +import V1 from "../V1"; +const deserialize = require("../../../base/deserialize"); +const serialize = require("../../../base/serialize"); +import { isValidPathParam } from "../../../base/utility"; + +export type KeyKeytype = "restricted"; + +/** + * Options to pass to create a KeyInstance + */ +export interface KeyListInstanceCreateOptions { + /** The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Payments resource. */ + accountSid: string; + /** A descriptive string that you create to describe the resource. It can be up to 64 characters long. */ + friendlyName?: string; + /** */ + keyType?: KeyKeytype; + /** The \\\\`Policy\\\\` object is a collection that specifies the allowed Twilio permissions for the restricted key. For more information on the permissions available with restricted API keys, refer to the [Twilio documentation](https://www.twilio.com/docs/iam/api-keys/restricted-api-keys#permissions-available-with-restricted-api-keys). */ + policy?: any; +} + +export interface KeySolution {} + +export interface KeyListInstance { + _version: V1; + _solution: KeySolution; + _uri: string; + + /** + * Create a KeyInstance + * + * @param params - Parameter for request + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed KeyInstance + */ + create( + params: KeyListInstanceCreateOptions, + callback?: (error: Error | null, item?: KeyInstance) => any + ): Promise; + + /** + * Provide a user-friendly representation + */ + toJSON(): any; + [inspect.custom](_depth: any, options: InspectOptions): any; +} + +export function KeyListInstance(version: V1): KeyListInstance { + const instance = {} as KeyListInstance; + + instance._version = version; + instance._solution = {}; + instance._uri = `/Keys`; + + instance.create = function create( + params: KeyListInstanceCreateOptions, + callback?: (error: Error | null, items: KeyInstance) => any + ): Promise { + if (params === null || params === undefined) { + throw new Error('Required parameter "params" missing.'); + } + + if (params["accountSid"] === null || params["accountSid"] === undefined) { + throw new Error("Required parameter \"params['accountSid']\" missing."); + } + + let data: any = {}; + + data["AccountSid"] = params["accountSid"]; + if (params["friendlyName"] !== undefined) + data["FriendlyName"] = params["friendlyName"]; + if (params["keyType"] !== undefined) data["KeyType"] = params["keyType"]; + if (params["policy"] !== undefined) + data["Policy"] = serialize.object(params["policy"]); + + const headers: any = {}; + headers["Content-Type"] = "application/x-www-form-urlencoded"; + headers["Accept"] = "application/json"; + + let operationVersion = version, + operationPromise = operationVersion.create({ + uri: instance._uri, + method: "post", + data, + headers, + }); + + operationPromise = operationPromise.then( + (payload) => new KeyInstance(operationVersion, payload) + ); + + operationPromise = instance._version.setPromiseCallback( + operationPromise, + callback + ); + return operationPromise; + }; + + instance.toJSON = function toJSON() { + return instance._solution; + }; + + instance[inspect.custom] = function inspectImpl( + _depth: any, + options: InspectOptions + ) { + return inspect(instance.toJSON(), options); + }; + + return instance; +} + +interface KeyPayload extends KeyResource {} + +interface KeyResource { + sid: string; + friendly_name: string; + date_created: Date; + date_updated: Date; + secret: string; + policy: any; +} + +export class KeyInstance { + constructor(protected _version: V1, payload: KeyResource) { + this.sid = payload.sid; + this.friendlyName = payload.friendly_name; + this.dateCreated = deserialize.rfc2822DateTime(payload.date_created); + this.dateUpdated = deserialize.rfc2822DateTime(payload.date_updated); + this.secret = payload.secret; + this.policy = payload.policy; + } + + /** + * The unique string that that we created to identify the NewKey resource. You will use this as the basic-auth `user` when authenticating to the API. + */ + sid: string; + /** + * The string that you assigned to describe the resource. + */ + friendlyName: string; + /** + * The date and time in GMT that the API Key was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. + */ + dateCreated: Date; + /** + * The date and time in GMT that the new API Key was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. + */ + dateUpdated: Date; + /** + * The secret your application uses to sign Access Tokens and to authenticate to the REST API (you will use this as the basic-auth `password`). **Note that for security reasons, this field is ONLY returned when the API Key is first created.** + */ + secret: string; + /** + * Collection of allow assertions. + */ + policy: any; + + /** + * Provide a user-friendly representation + * + * @returns Object + */ + toJSON() { + return { + sid: this.sid, + friendlyName: this.friendlyName, + dateCreated: this.dateCreated, + dateUpdated: this.dateUpdated, + secret: this.secret, + policy: this.policy, + }; + } + + [inspect.custom](_depth: any, options: InspectOptions) { + return inspect(this.toJSON(), options); + } +} diff --git a/src/rest/numbers/v1/webhook.ts b/src/rest/numbers/v1/webhook.ts new file mode 100644 index 000000000..f48c9294e --- /dev/null +++ b/src/rest/numbers/v1/webhook.ts @@ -0,0 +1,160 @@ +/* + * This code was generated by + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + * + * Twilio - Numbers + * This is the public Twilio REST API. + * + * NOTE: This class is auto generated by OpenAPI Generator. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { inspect, InspectOptions } from "util"; +import V1 from "../V1"; +const deserialize = require("../../../base/deserialize"); +const serialize = require("../../../base/serialize"); +import { isValidPathParam } from "../../../base/utility"; + +export interface WebhookSolution {} + +export interface WebhookListInstance { + _version: V1; + _solution: WebhookSolution; + _uri: string; + + /** + * Fetch a WebhookInstance + * + * @param callback - Callback to handle processed record + * + * @returns Resolves to processed WebhookInstance + */ + fetch( + callback?: (error: Error | null, item?: WebhookInstance) => any + ): Promise; + + /** + * Provide a user-friendly representation + */ + toJSON(): any; + [inspect.custom](_depth: any, options: InspectOptions): any; +} + +export function WebhookListInstance(version: V1): WebhookListInstance { + const instance = {} as WebhookListInstance; + + instance._version = version; + instance._solution = {}; + instance._uri = `/Porting/Configuration/Webhook`; + + instance.fetch = function fetch( + callback?: (error: Error | null, items: WebhookInstance) => any + ): Promise { + const headers: any = {}; + headers["Accept"] = "application/json"; + + let operationVersion = version, + operationPromise = operationVersion.fetch({ + uri: instance._uri, + method: "get", + headers, + }); + + operationPromise = operationPromise.then( + (payload) => new WebhookInstance(operationVersion, payload) + ); + + operationPromise = instance._version.setPromiseCallback( + operationPromise, + callback + ); + return operationPromise; + }; + + instance.toJSON = function toJSON() { + return instance._solution; + }; + + instance[inspect.custom] = function inspectImpl( + _depth: any, + options: InspectOptions + ) { + return inspect(instance.toJSON(), options); + }; + + return instance; +} + +interface WebhookPayload extends WebhookResource {} + +interface WebhookResource { + url: string; + port_in_target_url: string; + port_out_target_url: string; + notifications_of: Array; + port_in_target_date_created: Date; + port_out_target_date_created: Date; +} + +export class WebhookInstance { + constructor(protected _version: V1, payload: WebhookResource) { + this.url = payload.url; + this.portInTargetUrl = payload.port_in_target_url; + this.portOutTargetUrl = payload.port_out_target_url; + this.notificationsOf = payload.notifications_of; + this.portInTargetDateCreated = deserialize.iso8601DateTime( + payload.port_in_target_date_created + ); + this.portOutTargetDateCreated = deserialize.iso8601DateTime( + payload.port_out_target_date_created + ); + } + + /** + * The URL of the webhook configuration request + */ + url: string; + /** + * The complete webhook url that will be called when a notification event for port in request or port in phone number happens + */ + portInTargetUrl: string; + /** + * The complete webhook url that will be called when a notification event for a port out phone number happens. + */ + portOutTargetUrl: string; + /** + * A list to filter what notification events to receive for this account and its sub accounts. If it is an empty list, then it means that there are no filters for the notifications events to send in each webhook and all events will get sent. + */ + notificationsOf: Array; + /** + * Creation date for the port in webhook configuration + */ + portInTargetDateCreated: Date; + /** + * Creation date for the port out webhook configuration + */ + portOutTargetDateCreated: Date; + + /** + * Provide a user-friendly representation + * + * @returns Object + */ + toJSON() { + return { + url: this.url, + portInTargetUrl: this.portInTargetUrl, + portOutTargetUrl: this.portOutTargetUrl, + notificationsOf: this.notificationsOf, + portInTargetDateCreated: this.portInTargetDateCreated, + portOutTargetDateCreated: this.portOutTargetDateCreated, + }; + } + + [inspect.custom](_depth: any, options: InspectOptions) { + return inspect(this.toJSON(), options); + } +}