Auto-commit 2026-04-29 16:31

This commit is contained in:
2026-04-29 16:31:27 -04:00
parent e8687bb6b2
commit 0495ee5bd2
19691 changed files with 3272886 additions and 138 deletions

40
node_modules/twilio/lib/rest/verify/V2.d.ts generated vendored Normal file
View File

@@ -0,0 +1,40 @@
import VerifyBase from "../VerifyBase";
import Version from "../../base/Version";
import { FormListInstance } from "./v2/form";
import { SafelistListInstance } from "./v2/safelist";
import { ServiceListInstance } from "./v2/service";
import { TemplateListInstance } from "./v2/template";
import { VerificationAttemptListInstance } from "./v2/verificationAttempt";
import { VerificationAttemptsSummaryListInstance } from "./v2/verificationAttemptsSummary";
export default class V2 extends Version {
/**
* Initialize the V2 version of Verify
*
* @param domain - The Twilio (Twilio.Verify) domain
*/
constructor(domain: VerifyBase);
/** forms - { Twilio.Verify.V2.FormListInstance } resource */
protected _forms?: FormListInstance;
/** safelist - { Twilio.Verify.V2.SafelistListInstance } resource */
protected _safelist?: SafelistListInstance;
/** services - { Twilio.Verify.V2.ServiceListInstance } resource */
protected _services?: ServiceListInstance;
/** templates - { Twilio.Verify.V2.TemplateListInstance } resource */
protected _templates?: TemplateListInstance;
/** verificationAttempts - { Twilio.Verify.V2.VerificationAttemptListInstance } resource */
protected _verificationAttempts?: VerificationAttemptListInstance;
/** verificationAttemptsSummary - { Twilio.Verify.V2.VerificationAttemptsSummaryListInstance } resource */
protected _verificationAttemptsSummary?: VerificationAttemptsSummaryListInstance;
/** Getter for forms resource */
get forms(): FormListInstance;
/** Getter for safelist resource */
get safelist(): SafelistListInstance;
/** Getter for services resource */
get services(): ServiceListInstance;
/** Getter for templates resource */
get templates(): TemplateListInstance;
/** Getter for verificationAttempts resource */
get verificationAttempts(): VerificationAttemptListInstance;
/** Getter for verificationAttemptsSummary resource */
get verificationAttemptsSummary(): VerificationAttemptsSummaryListInstance;
}

69
node_modules/twilio/lib/rest/verify/V2.js generated vendored Normal file
View File

@@ -0,0 +1,69 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Verify
* 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.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const Version_1 = __importDefault(require("../../base/Version"));
const form_1 = require("./v2/form");
const safelist_1 = require("./v2/safelist");
const service_1 = require("./v2/service");
const template_1 = require("./v2/template");
const verificationAttempt_1 = require("./v2/verificationAttempt");
const verificationAttemptsSummary_1 = require("./v2/verificationAttemptsSummary");
class V2 extends Version_1.default {
/**
* Initialize the V2 version of Verify
*
* @param domain - The Twilio (Twilio.Verify) domain
*/
constructor(domain) {
super(domain, "v2");
}
/** Getter for forms resource */
get forms() {
this._forms = this._forms || (0, form_1.FormListInstance)(this);
return this._forms;
}
/** Getter for safelist resource */
get safelist() {
this._safelist = this._safelist || (0, safelist_1.SafelistListInstance)(this);
return this._safelist;
}
/** Getter for services resource */
get services() {
this._services = this._services || (0, service_1.ServiceListInstance)(this);
return this._services;
}
/** Getter for templates resource */
get templates() {
this._templates = this._templates || (0, template_1.TemplateListInstance)(this);
return this._templates;
}
/** Getter for verificationAttempts resource */
get verificationAttempts() {
this._verificationAttempts =
this._verificationAttempts || (0, verificationAttempt_1.VerificationAttemptListInstance)(this);
return this._verificationAttempts;
}
/** Getter for verificationAttemptsSummary resource */
get verificationAttemptsSummary() {
this._verificationAttemptsSummary =
this._verificationAttemptsSummary ||
(0, verificationAttemptsSummary_1.VerificationAttemptsSummaryListInstance)(this);
return this._verificationAttemptsSummary;
}
}
exports.default = V2;

118
node_modules/twilio/lib/rest/verify/v2/form.d.ts generated vendored Normal file
View File

@@ -0,0 +1,118 @@
import { inspect, InspectOptions } from "util";
import V2 from "../V2";
import { ApiResponse } from "../../../base/ApiResponse";
/**
* The Type of this Form. Currently only `form-push` is supported.
*/
export type FormFormTypes = "form-push";
export interface FormContext {
/**
* Fetch a FormInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed FormInstance
*/
fetch(callback?: (error: Error | null, item?: FormInstance) => any): Promise<FormInstance>;
/**
* Fetch a FormInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed FormInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<FormInstance>) => any): Promise<ApiResponse<FormInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface FormContextSolution {
formType: FormFormTypes;
}
export declare class FormContextImpl implements FormContext {
protected _version: V2;
protected _solution: FormContextSolution;
protected _uri: string;
constructor(_version: V2, formType: FormFormTypes);
fetch(callback?: (error: Error | null, item?: FormInstance) => any): Promise<FormInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<FormInstance>) => any): Promise<ApiResponse<FormInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): FormContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface FormResource {
form_type: FormFormTypes;
forms: any;
form_meta: any;
url: string;
}
export declare class FormInstance {
protected _version: V2;
protected _solution: FormContextSolution;
protected _context?: FormContext;
constructor(_version: V2, payload: FormResource, formType?: FormFormTypes);
formType: FormFormTypes;
/**
* Object that contains the available forms for this type. This available forms are given in the standard [JSON Schema](https://json-schema.org/) format
*/
forms: any;
/**
* Additional information for the available forms for this type. E.g. The separator string used for `binding` in a Factor push.
*/
formMeta: any;
/**
* The URL to access the forms for this type.
*/
url: string;
private get _proxy();
/**
* Fetch a FormInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed FormInstance
*/
fetch(callback?: (error: Error | null, item?: FormInstance) => any): Promise<FormInstance>;
/**
* Fetch a FormInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed FormInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<FormInstance>) => any): Promise<ApiResponse<FormInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
formType: "form-push";
forms: any;
formMeta: any;
url: string;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface FormSolution {
}
export interface FormListInstance {
_version: V2;
_solution: FormSolution;
_uri: string;
(formType: FormFormTypes): FormContext;
get(formType: FormFormTypes): FormContext;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function FormListInstance(version: V2): FormListInstance;
export {};

144
node_modules/twilio/lib/rest/verify/v2/form.js generated vendored Normal file
View File

@@ -0,0 +1,144 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Verify
* 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.FormInstance = exports.FormContextImpl = void 0;
exports.FormListInstance = FormListInstance;
const util_1 = require("util");
const deserialize = require("../../../base/deserialize");
const serialize = require("../../../base/serialize");
const utility_1 = require("../../../base/utility");
class FormContextImpl {
constructor(_version, formType) {
this._version = _version;
if (!(0, utility_1.isValidPathParam)(formType)) {
throw new Error("Parameter 'formType' is not valid.");
}
this._solution = { formType };
this._uri = `/Forms/${formType}`;
}
fetch(callback) {
const headers = {};
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.fetch({
uri: instance._uri,
method: "get",
headers,
});
operationPromise = operationPromise.then((payload) => new FormInstance(operationVersion, payload, instance._solution.formType));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
fetchWithHttpInfo(callback) {
const headers = {};
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.fetchWithResponseInfo({
uri: instance._uri,
method: "get",
headers,
})
.then((response) => ({
...response,
body: new FormInstance(operationVersion, response.body, instance._solution.formType),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return this._solution;
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.FormContextImpl = FormContextImpl;
class FormInstance {
constructor(_version, payload, formType) {
this._version = _version;
this.formType = payload.form_type;
this.forms = payload.forms;
this.formMeta = payload.form_meta;
this.url = payload.url;
this._solution = { formType: formType || this.formType };
}
get _proxy() {
this._context =
this._context ||
new FormContextImpl(this._version, this._solution.formType);
return this._context;
}
/**
* Fetch a FormInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed FormInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a FormInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed FormInstance with HTTP metadata
*/
fetchWithHttpInfo(callback) {
return this._proxy.fetchWithHttpInfo(callback);
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
formType: this.formType,
forms: this.forms,
formMeta: this.formMeta,
url: this.url,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.FormInstance = FormInstance;
function FormListInstance(version) {
const instance = ((formType) => instance.get(formType));
instance.get = function get(formType) {
return new FormContextImpl(version, formType);
};
instance._version = version;
instance._solution = {};
instance._uri = ``;
instance.toJSON = function toJSON() {
return instance._solution;
};
instance[util_1.inspect.custom] = function inspectImpl(_depth, options) {
return (0, util_1.inspect)(instance.toJSON(), options);
};
return instance;
}

170
node_modules/twilio/lib/rest/verify/v2/safelist.d.ts generated vendored Normal file
View File

@@ -0,0 +1,170 @@
import { inspect, InspectOptions } from "util";
import V2 from "../V2";
import { ApiResponse } from "../../../base/ApiResponse";
/**
* Options to pass to create a SafelistInstance
*/
export interface SafelistListInstanceCreateOptions {
/** The phone number to be added in SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164). */
phoneNumber: string;
}
export interface SafelistContext {
/**
* Remove a SafelistInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a SafelistInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean with HTTP metadata
*/
removeWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
/**
* Fetch a SafelistInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SafelistInstance
*/
fetch(callback?: (error: Error | null, item?: SafelistInstance) => any): Promise<SafelistInstance>;
/**
* Fetch a SafelistInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SafelistInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SafelistInstance>) => any): Promise<ApiResponse<SafelistInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface SafelistContextSolution {
phoneNumber: string;
}
export declare class SafelistContextImpl implements SafelistContext {
protected _version: V2;
protected _solution: SafelistContextSolution;
protected _uri: string;
constructor(_version: V2, phoneNumber: string);
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
removeWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
fetch(callback?: (error: Error | null, item?: SafelistInstance) => any): Promise<SafelistInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SafelistInstance>) => any): Promise<ApiResponse<SafelistInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): SafelistContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface SafelistResource {
sid: string;
phone_number: string;
url: string;
}
export declare class SafelistInstance {
protected _version: V2;
protected _solution: SafelistContextSolution;
protected _context?: SafelistContext;
constructor(_version: V2, payload: SafelistResource, phoneNumber?: string);
/**
* The unique string that we created to identify the SafeList resource.
*/
sid: string;
/**
* The phone number in SafeList.
*/
phoneNumber: string;
/**
* The absolute URL of the SafeList resource.
*/
url: string;
private get _proxy();
/**
* Remove a SafelistInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a SafelistInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean with HTTP metadata
*/
removeWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
/**
* Fetch a SafelistInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SafelistInstance
*/
fetch(callback?: (error: Error | null, item?: SafelistInstance) => any): Promise<SafelistInstance>;
/**
* Fetch a SafelistInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SafelistInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<SafelistInstance>) => any): Promise<ApiResponse<SafelistInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
phoneNumber: string;
url: string;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface SafelistSolution {
}
export interface SafelistListInstance {
_version: V2;
_solution: SafelistSolution;
_uri: string;
(phoneNumber: string): SafelistContext;
get(phoneNumber: string): SafelistContext;
/**
* Create a SafelistInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SafelistInstance
*/
create(params: SafelistListInstanceCreateOptions, callback?: (error: Error | null, item?: SafelistInstance) => any): Promise<SafelistInstance>;
/**
* Create a SafelistInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SafelistInstance with HTTP metadata
*/
createWithHttpInfo(params: SafelistListInstanceCreateOptions, callback?: (error: Error | null, item?: ApiResponse<SafelistInstance>) => any): Promise<ApiResponse<SafelistInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function SafelistListInstance(version: V2): SafelistListInstance;
export {};

237
node_modules/twilio/lib/rest/verify/v2/safelist.js generated vendored Normal file
View File

@@ -0,0 +1,237 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Verify
* 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.SafelistInstance = exports.SafelistContextImpl = void 0;
exports.SafelistListInstance = SafelistListInstance;
const util_1 = require("util");
const deserialize = require("../../../base/deserialize");
const serialize = require("../../../base/serialize");
const utility_1 = require("../../../base/utility");
class SafelistContextImpl {
constructor(_version, phoneNumber) {
this._version = _version;
if (!(0, utility_1.isValidPathParam)(phoneNumber)) {
throw new Error("Parameter 'phoneNumber' is not valid.");
}
this._solution = { phoneNumber };
this._uri = `/SafeList/Numbers/${phoneNumber}`;
}
remove(callback) {
const headers = {};
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.remove({
uri: instance._uri,
method: "delete",
headers,
});
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
removeWithHttpInfo(callback) {
const headers = {};
const instance = this;
let operationVersion = instance._version;
// DELETE operation - returns boolean based on status code
let operationPromise = operationVersion
.removeWithResponseInfo({ uri: instance._uri, method: "delete", headers })
.then((response) => ({
...response,
body: response.statusCode === 204,
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
fetch(callback) {
const headers = {};
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.fetch({
uri: instance._uri,
method: "get",
headers,
});
operationPromise = operationPromise.then((payload) => new SafelistInstance(operationVersion, payload, instance._solution.phoneNumber));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
fetchWithHttpInfo(callback) {
const headers = {};
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.fetchWithResponseInfo({
uri: instance._uri,
method: "get",
headers,
})
.then((response) => ({
...response,
body: new SafelistInstance(operationVersion, response.body, instance._solution.phoneNumber),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return this._solution;
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.SafelistContextImpl = SafelistContextImpl;
class SafelistInstance {
constructor(_version, payload, phoneNumber) {
this._version = _version;
this.sid = payload.sid;
this.phoneNumber = payload.phone_number;
this.url = payload.url;
this._solution = { phoneNumber: phoneNumber || this.phoneNumber };
}
get _proxy() {
this._context =
this._context ||
new SafelistContextImpl(this._version, this._solution.phoneNumber);
return this._context;
}
/**
* Remove a SafelistInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback) {
return this._proxy.remove(callback);
}
/**
* Remove a SafelistInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean with HTTP metadata
*/
removeWithHttpInfo(callback) {
return this._proxy.removeWithHttpInfo(callback);
}
/**
* Fetch a SafelistInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SafelistInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a SafelistInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed SafelistInstance with HTTP metadata
*/
fetchWithHttpInfo(callback) {
return this._proxy.fetchWithHttpInfo(callback);
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
sid: this.sid,
phoneNumber: this.phoneNumber,
url: this.url,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.SafelistInstance = SafelistInstance;
function SafelistListInstance(version) {
const instance = ((phoneNumber) => instance.get(phoneNumber));
instance.get = function get(phoneNumber) {
return new SafelistContextImpl(version, phoneNumber);
};
instance._version = version;
instance._solution = {};
instance._uri = `/SafeList/Numbers`;
instance.create = function create(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["phoneNumber"] === null || params["phoneNumber"] === undefined) {
throw new Error("Required parameter \"params['phoneNumber']\" missing.");
}
let data = {};
data["PhoneNumber"] = params["phoneNumber"];
const headers = {};
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 SafelistInstance(operationVersion, payload));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.createWithHttpInfo = function createWithHttpInfo(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["phoneNumber"] === null || params["phoneNumber"] === undefined) {
throw new Error("Required parameter \"params['phoneNumber']\" missing.");
}
let data = {};
data["PhoneNumber"] = params["phoneNumber"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
let operationVersion = version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.createWithResponseInfo({
uri: instance._uri,
method: "post",
data,
headers,
})
.then((response) => ({
...response,
body: new SafelistInstance(operationVersion, response.body),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.toJSON = function toJSON() {
return instance._solution;
};
instance[util_1.inspect.custom] = function inspectImpl(_depth, options) {
return (0, util_1.inspect)(instance.toJSON(), options);
};
return instance;
}

691
node_modules/twilio/lib/rest/verify/v2/service.d.ts generated vendored Normal file
View File

@@ -0,0 +1,691 @@
import { inspect, InspectOptions } from "util";
import Page, { TwilioResponsePayload } from "../../../base/Page";
import Response from "../../../http/response";
import V2 from "../V2";
import { ApiResponse } from "../../../base/ApiResponse";
import { AccessTokenListInstance } from "./service/accessToken";
import { ApproveChallengeListInstance } from "./service/approveChallenge";
import { EntityListInstance } from "./service/entity";
import { MessagingConfigurationListInstance } from "./service/messagingConfiguration";
import { NewChallengeListInstance } from "./service/newChallenge";
import { NewFactorListInstance } from "./service/newFactor";
import { NewVerifyFactorListInstance } from "./service/newVerifyFactor";
import { RateLimitListInstance } from "./service/rateLimit";
import { VerificationListInstance } from "./service/verification";
import { VerificationCheckListInstance } from "./service/verificationCheck";
import { WebhookListInstance } from "./service/webhook";
/**
* Options to pass to update a ServiceInstance
*/
export interface ServiceContextUpdateOptions {
/** A descriptive string that you create to describe the verification service. It can be up to 32 characters long. **This value should not contain PII.** */
friendlyName?: string;
/** The length of the verification code to generate. Must be an integer value between 4 and 10, inclusive. */
codeLength?: number;
/** Whether to perform a lookup with each verification started and return info about the phone number. */
lookupEnabled?: boolean;
/** Whether to skip sending SMS verifications to landlines. Requires `lookup_enabled`. */
skipSmsToLandlines?: boolean;
/** Whether to ask the user to press a number before delivering the verify code in a phone call. */
dtmfInputRequired?: boolean;
/** The name of an alternative text-to-speech service to use in phone calls. Applies only to TTS languages. */
ttsName?: string;
/** Whether to pass PSD2 transaction parameters when starting a verification. */
psd2Enabled?: boolean;
/** Whether to add a privacy warning at the end of an SMS. **Disabled by default and applies only for SMS.** */
doNotShareWarningEnabled?: boolean;
/** Whether to allow sending verifications with a custom code instead of a randomly generated one. */
customCodeEnabled?: boolean;
/** Optional configuration for the Push factors. If true, include the date in the Challenge\\\'s response. Otherwise, the date is omitted from the response. See [Challenge](https://www.twilio.com/docs/verify/api/challenge) resources details parameter for more info. Default: false. **Deprecated** do not use this parameter. */
"push.includeDate"?: boolean;
/** Optional configuration for the Push factors. Set the APN Credential for this service. This will allow to send push notifications to iOS devices. See [Credential Resource](https://www.twilio.com/docs/notify/api/credential-resource) */
"push.apnCredentialSid"?: string;
/** Optional configuration for the Push factors. Set the FCM Credential for this service. This will allow to send push notifications to Android devices. See [Credential Resource](https://www.twilio.com/docs/notify/api/credential-resource) */
"push.fcmCredentialSid"?: string;
/** Optional configuration for the TOTP factors. Set TOTP Issuer for this service. This will allow to configure the issuer of the TOTP URI. */
"totp.issuer"?: string;
/** Optional configuration for the TOTP factors. Defines how often, in seconds, are TOTP codes generated. i.e, a new TOTP code is generated every time_step seconds. Must be between 20 and 60 seconds, inclusive. Defaults to 30 seconds */
"totp.timeStep"?: number;
/** Optional configuration for the TOTP factors. Number of digits for generated TOTP codes. Must be between 3 and 8, inclusive. Defaults to 6 */
"totp.codeLength"?: number;
/** Optional configuration for the TOTP factors. The number of time-steps, past and future, that are valid for validation of TOTP codes. Must be between 0 and 2, inclusive. Defaults to 1 */
"totp.skew"?: number;
/** The default message [template](https://www.twilio.com/docs/verify/api/templates). Will be used for all SMS verifications unless explicitly overriden. SMS channel only. */
defaultTemplateSid?: string;
/** The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/services) to associate with the Verification Service. */
"whatsapp.msgServiceSid"?: string;
/** The WhatsApp number to use as the sender of the verification messages. This number must be associated with the WhatsApp Message Service. */
"whatsapp.from"?: string;
/** The Relying Party ID for Passkeys. This is the domain of your application, e.g. `example.com`. It is used to identify your application when creating Passkeys. */
"passkeys.relyingParty.id"?: string;
/** The Relying Party Name for Passkeys. This is the name of your application, e.g. `Example App`. It is used to identify your application when creating Passkeys. */
"passkeys.relyingParty.name"?: string;
/** The Relying Party Origins for Passkeys. This is the origin of your application, e.g. `login.example.com,www.example.com`. It is used to identify your application when creating Passkeys, it can have multiple origins split by `,`. */
"passkeys.relyingParty.origins"?: string;
/** The Authenticator Attachment for Passkeys. This is the type of authenticator that will be used to create Passkeys. It can be empty or it can have the values `platform`, `cross-platform` or `any`. */
"passkeys.authenticatorAttachment"?: string;
/** Indicates whether credentials must be discoverable by the authenticator. It can be empty or it can have the values `required`, `preferred` or `discouraged`. */
"passkeys.discoverableCredentials"?: string;
/** The User Verification for Passkeys. This is the type of user verification that will be used to create Passkeys. It can be empty or it can have the values `required`, `preferred` or `discouraged`. */
"passkeys.userVerification"?: string;
/** Whether to allow verifications from the service to reach the stream-events sinks if configured */
verifyEventSubscriptionEnabled?: boolean;
}
/**
* Options to pass to create a ServiceInstance
*/
export interface ServiceListInstanceCreateOptions {
/** A descriptive string that you create to describe the verification service. It can be up to 32 characters long. **This value should not contain PII.** */
friendlyName: string;
/** The length of the verification code to generate. Must be an integer value between 4 and 10, inclusive. */
codeLength?: number;
/** Whether to perform a lookup with each verification started and return info about the phone number. */
lookupEnabled?: boolean;
/** Whether to skip sending SMS verifications to landlines. Requires `lookup_enabled`. */
skipSmsToLandlines?: boolean;
/** Whether to ask the user to press a number before delivering the verify code in a phone call. */
dtmfInputRequired?: boolean;
/** The name of an alternative text-to-speech service to use in phone calls. Applies only to TTS languages. */
ttsName?: string;
/** Whether to pass PSD2 transaction parameters when starting a verification. */
psd2Enabled?: boolean;
/** Whether to add a security warning at the end of an SMS verification body. Disabled by default and applies only to SMS. Example SMS body: `Your AppName verification code is: 1234. Dont share this code with anyone; our employees will never ask for the code` */
doNotShareWarningEnabled?: boolean;
/** Whether to allow sending verifications with a custom code instead of a randomly generated one. */
customCodeEnabled?: boolean;
/** Optional configuration for the Push factors. If true, include the date in the Challenge\\\'s response. Otherwise, the date is omitted from the response. See [Challenge](https://www.twilio.com/docs/verify/api/challenge) resources details parameter for more info. Default: false. **Deprecated** do not use this parameter. This timestamp value is the same one as the one found in `date_created`, please use that one instead. */
"push.includeDate"?: boolean;
/** Optional configuration for the Push factors. Set the APN Credential for this service. This will allow to send push notifications to iOS devices. See [Credential Resource](https://www.twilio.com/docs/notify/api/credential-resource) */
"push.apnCredentialSid"?: string;
/** Optional configuration for the Push factors. Set the FCM Credential for this service. This will allow to send push notifications to Android devices. See [Credential Resource](https://www.twilio.com/docs/notify/api/credential-resource) */
"push.fcmCredentialSid"?: string;
/** Optional configuration for the TOTP factors. Set TOTP Issuer for this service. This will allow to configure the issuer of the TOTP URI. Defaults to the service friendly name if not provided. */
"totp.issuer"?: string;
/** Optional configuration for the TOTP factors. Defines how often, in seconds, are TOTP codes generated. i.e, a new TOTP code is generated every time_step seconds. Must be between 20 and 60 seconds, inclusive. Defaults to 30 seconds */
"totp.timeStep"?: number;
/** Optional configuration for the TOTP factors. Number of digits for generated TOTP codes. Must be between 3 and 8, inclusive. Defaults to 6 */
"totp.codeLength"?: number;
/** Optional configuration for the TOTP factors. The number of time-steps, past and future, that are valid for validation of TOTP codes. Must be between 0 and 2, inclusive. Defaults to 1 */
"totp.skew"?: number;
/** The default message [template](https://www.twilio.com/docs/verify/api/templates). Will be used for all SMS verifications unless explicitly overriden. SMS channel only. */
defaultTemplateSid?: string;
/** The SID of the Messaging Service containing WhatsApp Sender(s) that Verify will use to send WhatsApp messages to your users. */
"whatsapp.msgServiceSid"?: string;
/** The number to use as the WhatsApp Sender that Verify will use to send WhatsApp messages to your users.This WhatsApp Sender must be associated with a Messaging Service SID. */
"whatsapp.from"?: string;
/** The Relying Party ID for Passkeys. This is the domain of your application, e.g. `example.com`. It is used to identify your application when creating Passkeys. */
"passkeys.relyingParty.id"?: string;
/** The Relying Party Name for Passkeys. This is the name of your application, e.g. `Example App`. It is used to identify your application when creating Passkeys. */
"passkeys.relyingParty.name"?: string;
/** The Relying Party Origins for Passkeys. This is the origin of your application, e.g. `login.example.com,www.example.com`. It is used to identify your application when creating Passkeys, it can have multiple origins split by `,`. */
"passkeys.relyingParty.origins"?: string;
/** The Authenticator Attachment for Passkeys. This is the type of authenticator that will be used to create Passkeys. It can be empty or it can have the values `platform`, `cross-platform` or `any`. */
"passkeys.authenticatorAttachment"?: string;
/** Indicates whether credentials must be discoverable by the authenticator. It can be empty or it can have the values `required`, `preferred` or `discouraged`. */
"passkeys.discoverableCredentials"?: string;
/** The User Verification for Passkeys. This is the type of user verification that will be used to create Passkeys. It can be empty or it can have the values `required`, `preferred` or `discouraged`. */
"passkeys.userVerification"?: string;
/** Whether to allow verifications from the service to reach the stream-events sinks if configured */
verifyEventSubscriptionEnabled?: boolean;
}
/**
* Options to pass to each
*/
export interface ServiceListInstanceEachOptions {
/** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
pageSize?: number;
/** Function to process each record. If this and a positional callback are passed, this one will be used */
callback?: (item: ServiceInstance, done: (err?: Error) => void) => void;
/** Function to be called upon completion of streaming */
done?: Function;
/** Upper limit for the number of records to return. each() guarantees never to return more than limit. Default is no limit */
limit?: number;
}
/**
* Options to pass to list
*/
export interface ServiceListInstanceOptions {
/** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
pageSize?: number;
/** Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit */
limit?: number;
}
/**
* Options to pass to page
*/
export interface ServiceListInstancePageOptions {
/** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
pageSize?: number;
/** Page Number, this value is simply for client state */
pageNumber?: number;
/** PageToken provided by the API */
pageToken?: string;
}
export interface ServiceContext {
accessTokens: AccessTokenListInstance;
approveChallenge: ApproveChallengeListInstance;
entities: EntityListInstance;
messagingConfigurations: MessagingConfigurationListInstance;
newChallenge: NewChallengeListInstance;
newFactors: NewFactorListInstance;
newVerifyFactors: NewVerifyFactorListInstance;
rateLimits: RateLimitListInstance;
verifications: VerificationListInstance;
verificationChecks: VerificationCheckListInstance;
webhooks: WebhookListInstance;
/**
* Remove a ServiceInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a ServiceInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean with HTTP metadata
*/
removeWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
/**
* Fetch a ServiceInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ServiceInstance
*/
fetch(callback?: (error: Error | null, item?: ServiceInstance) => any): Promise<ServiceInstance>;
/**
* Fetch a ServiceInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ServiceInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<ServiceInstance>) => any): Promise<ApiResponse<ServiceInstance>>;
/**
* Update a ServiceInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ServiceInstance
*/
update(callback?: (error: Error | null, item?: ServiceInstance) => any): Promise<ServiceInstance>;
/**
* Update a ServiceInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ServiceInstance
*/
update(params: ServiceContextUpdateOptions, callback?: (error: Error | null, item?: ServiceInstance) => any): Promise<ServiceInstance>;
/**
* Update a ServiceInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ServiceInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<ServiceInstance>) => any): Promise<ApiResponse<ServiceInstance>>;
/**
* Update a ServiceInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ServiceInstance with HTTP metadata
*/
updateWithHttpInfo(params: ServiceContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<ServiceInstance>) => any): Promise<ApiResponse<ServiceInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface ServiceContextSolution {
sid: string;
}
export declare class ServiceContextImpl implements ServiceContext {
protected _version: V2;
protected _solution: ServiceContextSolution;
protected _uri: string;
protected _accessTokens?: AccessTokenListInstance;
protected _approveChallenge?: ApproveChallengeListInstance;
protected _entities?: EntityListInstance;
protected _messagingConfigurations?: MessagingConfigurationListInstance;
protected _newChallenge?: NewChallengeListInstance;
protected _newFactors?: NewFactorListInstance;
protected _newVerifyFactors?: NewVerifyFactorListInstance;
protected _rateLimits?: RateLimitListInstance;
protected _verifications?: VerificationListInstance;
protected _verificationChecks?: VerificationCheckListInstance;
protected _webhooks?: WebhookListInstance;
constructor(_version: V2, sid: string);
get accessTokens(): AccessTokenListInstance;
get approveChallenge(): ApproveChallengeListInstance;
get entities(): EntityListInstance;
get messagingConfigurations(): MessagingConfigurationListInstance;
get newChallenge(): NewChallengeListInstance;
get newFactors(): NewFactorListInstance;
get newVerifyFactors(): NewVerifyFactorListInstance;
get rateLimits(): RateLimitListInstance;
get verifications(): VerificationListInstance;
get verificationChecks(): VerificationCheckListInstance;
get webhooks(): WebhookListInstance;
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
removeWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
fetch(callback?: (error: Error | null, item?: ServiceInstance) => any): Promise<ServiceInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<ServiceInstance>) => any): Promise<ApiResponse<ServiceInstance>>;
update(params?: ServiceContextUpdateOptions | ((error: Error | null, item?: ServiceInstance) => any), callback?: (error: Error | null, item?: ServiceInstance) => any): Promise<ServiceInstance>;
updateWithHttpInfo(params?: ServiceContextUpdateOptions | ((error: Error | null, item?: ApiResponse<ServiceInstance>) => any), callback?: (error: Error | null, item?: ApiResponse<ServiceInstance>) => any): Promise<ApiResponse<ServiceInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): ServiceContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface ServicePayload extends TwilioResponsePayload {
services: ServiceResource[];
}
interface ServiceResource {
sid: string;
account_sid: string;
friendly_name: string;
code_length: number;
lookup_enabled: boolean;
psd2_enabled: boolean;
skip_sms_to_landlines: boolean;
dtmf_input_required: boolean;
tts_name: string;
do_not_share_warning_enabled: boolean;
custom_code_enabled: boolean;
push: any;
totp: any;
default_template_sid: string;
whatsapp: any;
passkeys: any;
verify_event_subscription_enabled: boolean;
date_created: Date;
date_updated: Date;
url: string;
links: Record<string, string>;
}
export declare class ServiceInstance {
protected _version: V2;
protected _solution: ServiceContextSolution;
protected _context?: ServiceContext;
constructor(_version: V2, payload: ServiceResource, sid?: string);
/**
* The unique string that we created to identify the Service resource.
*/
sid: string;
/**
* The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Service resource.
*/
accountSid: string;
/**
* The name that appears in the body of your verification messages. It can be up to 30 characters long and can include letters, numbers, spaces, dashes, underscores. Phone numbers, special characters or links are NOT allowed. It cannot contain more than 4 (consecutive or non-consecutive) digits. **This value should not contain PII.**
*/
friendlyName: string;
/**
* The length of the verification code to generate.
*/
codeLength: number;
/**
* Whether to perform a lookup with each verification started and return info about the phone number.
*/
lookupEnabled: boolean;
/**
* Whether to pass PSD2 transaction parameters when starting a verification.
*/
psd2Enabled: boolean;
/**
* Whether to skip sending SMS verifications to landlines. Requires `lookup_enabled`.
*/
skipSmsToLandlines: boolean;
/**
* Whether to ask the user to press a number before delivering the verify code in a phone call.
*/
dtmfInputRequired: boolean;
/**
* The name of an alternative text-to-speech service to use in phone calls. Applies only to TTS languages.
*/
ttsName: string;
/**
* Whether to add a security warning at the end of an SMS verification body. Disabled by default and applies only to SMS. Example SMS body: `Your AppName verification code is: 1234. Dont share this code with anyone; our employees will never ask for the code`
*/
doNotShareWarningEnabled: boolean;
/**
* Whether to allow sending verifications with a custom code instead of a randomly generated one.
*/
customCodeEnabled: boolean;
/**
* Configurations for the Push factors (channel) created under this Service.
*/
push: any;
/**
* Configurations for the TOTP factors (channel) created under this Service.
*/
totp: any;
defaultTemplateSid: string;
whatsapp: any;
passkeys: any;
/**
* Whether to allow verifications from the service to reach the stream-events sinks if configured
*/
verifyEventSubscriptionEnabled: boolean;
/**
* The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
*/
dateCreated: Date;
/**
* The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
*/
dateUpdated: Date;
/**
* The absolute URL of the resource.
*/
url: string;
/**
* The URLs of related resources.
*/
links: Record<string, string>;
private get _proxy();
/**
* Remove a ServiceInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a ServiceInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean with HTTP metadata
*/
removeWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
/**
* Fetch a ServiceInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ServiceInstance
*/
fetch(callback?: (error: Error | null, item?: ServiceInstance) => any): Promise<ServiceInstance>;
/**
* Fetch a ServiceInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ServiceInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<ServiceInstance>) => any): Promise<ApiResponse<ServiceInstance>>;
/**
* Update a ServiceInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ServiceInstance
*/
update(callback?: (error: Error | null, item?: ServiceInstance) => any): Promise<ServiceInstance>;
/**
* Update a ServiceInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ServiceInstance
*/
update(params: ServiceContextUpdateOptions, callback?: (error: Error | null, item?: ServiceInstance) => any): Promise<ServiceInstance>;
/**
* Update a ServiceInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ServiceInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<ServiceInstance>) => any): Promise<ApiResponse<ServiceInstance>>;
/**
* Update a ServiceInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ServiceInstance with HTTP metadata
*/
updateWithHttpInfo(params: ServiceContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<ServiceInstance>) => any): Promise<ApiResponse<ServiceInstance>>;
/**
* Access the accessTokens.
*/
accessTokens(): AccessTokenListInstance;
/**
* Access the approveChallenge.
*/
approveChallenge(): ApproveChallengeListInstance;
/**
* Access the entities.
*/
entities(): EntityListInstance;
/**
* Access the messagingConfigurations.
*/
messagingConfigurations(): MessagingConfigurationListInstance;
/**
* Access the newChallenge.
*/
newChallenge(): NewChallengeListInstance;
/**
* Access the newFactors.
*/
newFactors(): NewFactorListInstance;
/**
* Access the newVerifyFactors.
*/
newVerifyFactors(): NewVerifyFactorListInstance;
/**
* Access the rateLimits.
*/
rateLimits(): RateLimitListInstance;
/**
* Access the verifications.
*/
verifications(): VerificationListInstance;
/**
* Access the verificationChecks.
*/
verificationChecks(): VerificationCheckListInstance;
/**
* Access the webhooks.
*/
webhooks(): WebhookListInstance;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
accountSid: string;
friendlyName: string;
codeLength: number;
lookupEnabled: boolean;
psd2Enabled: boolean;
skipSmsToLandlines: boolean;
dtmfInputRequired: boolean;
ttsName: string;
doNotShareWarningEnabled: boolean;
customCodeEnabled: boolean;
push: any;
totp: any;
defaultTemplateSid: string;
whatsapp: any;
passkeys: any;
verifyEventSubscriptionEnabled: boolean;
dateCreated: Date;
dateUpdated: Date;
url: string;
links: Record<string, string>;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface ServiceSolution {
}
export interface ServiceListInstance {
_version: V2;
_solution: ServiceSolution;
_uri: string;
(sid: string): ServiceContext;
get(sid: string): ServiceContext;
/**
* Create a ServiceInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ServiceInstance
*/
create(params: ServiceListInstanceCreateOptions, callback?: (error: Error | null, item?: ServiceInstance) => any): Promise<ServiceInstance>;
/**
* Create a ServiceInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ServiceInstance with HTTP metadata
*/
createWithHttpInfo(params: ServiceListInstanceCreateOptions, callback?: (error: Error | null, item?: ApiResponse<ServiceInstance>) => any): Promise<ApiResponse<ServiceInstance>>;
/**
* Streams ServiceInstance records from the API.
*
* This operation lazily loads records as efficiently as possible until the limit
* is reached.
*
* The results are passed into the callback function, so this operation is memory
* efficient.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { ServiceListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: ServiceInstance, done: (err?: Error) => void) => void): void;
each(params: ServiceListInstanceEachOptions, callback?: (item: ServiceInstance, done: (err?: Error) => void) => void): void;
/**
* Streams ServiceInstance records from the API with HTTP metadata captured per page.
*
* This operation lazily loads records as efficiently as possible until the limit
* is reached. HTTP metadata (status code, headers) is captured for each page request.
*
* The results are passed into the callback function, so this operation is memory
* efficient.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { ServiceListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: ServiceInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: ServiceListInstanceEachOptions, callback?: (item: ServiceInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of ServiceInstance records from the API.
*
* The request is executed immediately.
*
* @param { string } [targetUrl] - API-generated URL for the requested results page
* @param { function } [callback] - Callback to handle list of records
*/
getPage(targetUrl: string, callback?: (error: Error | null, items: ServicePage) => any): Promise<ServicePage>;
/**
* Retrieve a single target page of ServiceInstance records from the API with HTTP metadata.
*
* The request is executed immediately.
*
* @param { string } [targetUrl] - API-generated URL for the requested results page
* @param { function } [callback] - Callback to handle list of records with metadata
*/
getPageWithHttpInfo(targetUrl: string, callback?: (error: Error | null, items: ApiResponse<ServicePage>) => any): Promise<ApiResponse<ServicePage>>;
/**
* Lists ServiceInstance records from the API as a list.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { ServiceListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: ServiceInstance[]) => any): Promise<ServiceInstance[]>;
list(params: ServiceListInstanceOptions, callback?: (error: Error | null, items: ServiceInstance[]) => any): Promise<ServiceInstance[]>;
/**
* Lists ServiceInstance records from the API as a list with HTTP metadata.
*
* Returns all records along with HTTP metadata from the first page fetched.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { ServiceListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<ServiceInstance[]>) => any): Promise<ApiResponse<ServiceInstance[]>>;
listWithHttpInfo(params: ServiceListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<ServiceInstance[]>) => any): Promise<ApiResponse<ServiceInstance[]>>;
/**
* Retrieve a single page of ServiceInstance records from the API.
*
* The request is executed immediately.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { ServiceListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: ServicePage) => any): Promise<ServicePage>;
page(params: ServiceListInstancePageOptions, callback?: (error: Error | null, items: ServicePage) => any): Promise<ServicePage>;
/**
* Retrieve a single page of ServiceInstance records from the API with HTTP metadata.
*
* The request is executed immediately.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { ServiceListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<ServicePage>) => any): Promise<ApiResponse<ServicePage>>;
pageWithHttpInfo(params: ServiceListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<ServicePage>) => any): Promise<ApiResponse<ServicePage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function ServiceListInstance(version: V2): ServiceListInstance;
export declare class ServicePage extends Page<V2, ServicePayload, ServiceResource, ServiceInstance> {
/**
* Initialize the ServicePage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V2, response: Response<string>, solution: ServiceSolution);
/**
* Build an instance of ServiceInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: ServiceResource): ServiceInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

805
node_modules/twilio/lib/rest/verify/v2/service.js generated vendored Normal file
View File

@@ -0,0 +1,805 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Verify
* 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.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ServicePage = exports.ServiceInstance = exports.ServiceContextImpl = void 0;
exports.ServiceListInstance = ServiceListInstance;
const util_1 = require("util");
const Page_1 = __importDefault(require("../../../base/Page"));
const deserialize = require("../../../base/deserialize");
const serialize = require("../../../base/serialize");
const utility_1 = require("../../../base/utility");
const accessToken_1 = require("./service/accessToken");
const approveChallenge_1 = require("./service/approveChallenge");
const entity_1 = require("./service/entity");
const messagingConfiguration_1 = require("./service/messagingConfiguration");
const newChallenge_1 = require("./service/newChallenge");
const newFactor_1 = require("./service/newFactor");
const newVerifyFactor_1 = require("./service/newVerifyFactor");
const rateLimit_1 = require("./service/rateLimit");
const verification_1 = require("./service/verification");
const verificationCheck_1 = require("./service/verificationCheck");
const webhook_1 = require("./service/webhook");
class ServiceContextImpl {
constructor(_version, sid) {
this._version = _version;
if (!(0, utility_1.isValidPathParam)(sid)) {
throw new Error("Parameter 'sid' is not valid.");
}
this._solution = { sid };
this._uri = `/Services/${sid}`;
}
get accessTokens() {
this._accessTokens =
this._accessTokens ||
(0, accessToken_1.AccessTokenListInstance)(this._version, this._solution.sid);
return this._accessTokens;
}
get approveChallenge() {
this._approveChallenge =
this._approveChallenge ||
(0, approveChallenge_1.ApproveChallengeListInstance)(this._version, this._solution.sid);
return this._approveChallenge;
}
get entities() {
this._entities =
this._entities || (0, entity_1.EntityListInstance)(this._version, this._solution.sid);
return this._entities;
}
get messagingConfigurations() {
this._messagingConfigurations =
this._messagingConfigurations ||
(0, messagingConfiguration_1.MessagingConfigurationListInstance)(this._version, this._solution.sid);
return this._messagingConfigurations;
}
get newChallenge() {
this._newChallenge =
this._newChallenge ||
(0, newChallenge_1.NewChallengeListInstance)(this._version, this._solution.sid);
return this._newChallenge;
}
get newFactors() {
this._newFactors =
this._newFactors ||
(0, newFactor_1.NewFactorListInstance)(this._version, this._solution.sid);
return this._newFactors;
}
get newVerifyFactors() {
this._newVerifyFactors =
this._newVerifyFactors ||
(0, newVerifyFactor_1.NewVerifyFactorListInstance)(this._version, this._solution.sid);
return this._newVerifyFactors;
}
get rateLimits() {
this._rateLimits =
this._rateLimits ||
(0, rateLimit_1.RateLimitListInstance)(this._version, this._solution.sid);
return this._rateLimits;
}
get verifications() {
this._verifications =
this._verifications ||
(0, verification_1.VerificationListInstance)(this._version, this._solution.sid);
return this._verifications;
}
get verificationChecks() {
this._verificationChecks =
this._verificationChecks ||
(0, verificationCheck_1.VerificationCheckListInstance)(this._version, this._solution.sid);
return this._verificationChecks;
}
get webhooks() {
this._webhooks =
this._webhooks || (0, webhook_1.WebhookListInstance)(this._version, this._solution.sid);
return this._webhooks;
}
remove(callback) {
const headers = {};
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.remove({
uri: instance._uri,
method: "delete",
headers,
});
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
removeWithHttpInfo(callback) {
const headers = {};
const instance = this;
let operationVersion = instance._version;
// DELETE operation - returns boolean based on status code
let operationPromise = operationVersion
.removeWithResponseInfo({ uri: instance._uri, method: "delete", headers })
.then((response) => ({
...response,
body: response.statusCode === 204,
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
fetch(callback) {
const headers = {};
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.fetch({
uri: instance._uri,
method: "get",
headers,
});
operationPromise = operationPromise.then((payload) => new ServiceInstance(operationVersion, payload, instance._solution.sid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
fetchWithHttpInfo(callback) {
const headers = {};
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.fetchWithResponseInfo({
uri: instance._uri,
method: "get",
headers,
})
.then((response) => ({
...response,
body: new ServiceInstance(operationVersion, response.body, instance._solution.sid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
update(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
if (params["codeLength"] !== undefined)
data["CodeLength"] = params["codeLength"];
if (params["lookupEnabled"] !== undefined)
data["LookupEnabled"] = serialize.bool(params["lookupEnabled"]);
if (params["skipSmsToLandlines"] !== undefined)
data["SkipSmsToLandlines"] = serialize.bool(params["skipSmsToLandlines"]);
if (params["dtmfInputRequired"] !== undefined)
data["DtmfInputRequired"] = serialize.bool(params["dtmfInputRequired"]);
if (params["ttsName"] !== undefined)
data["TtsName"] = params["ttsName"];
if (params["psd2Enabled"] !== undefined)
data["Psd2Enabled"] = serialize.bool(params["psd2Enabled"]);
if (params["doNotShareWarningEnabled"] !== undefined)
data["DoNotShareWarningEnabled"] = serialize.bool(params["doNotShareWarningEnabled"]);
if (params["customCodeEnabled"] !== undefined)
data["CustomCodeEnabled"] = serialize.bool(params["customCodeEnabled"]);
if (params["push.includeDate"] !== undefined)
data["Push.IncludeDate"] = serialize.bool(params["push.includeDate"]);
if (params["push.apnCredentialSid"] !== undefined)
data["Push.ApnCredentialSid"] = params["push.apnCredentialSid"];
if (params["push.fcmCredentialSid"] !== undefined)
data["Push.FcmCredentialSid"] = params["push.fcmCredentialSid"];
if (params["totp.issuer"] !== undefined)
data["Totp.Issuer"] = params["totp.issuer"];
if (params["totp.timeStep"] !== undefined)
data["Totp.TimeStep"] = params["totp.timeStep"];
if (params["totp.codeLength"] !== undefined)
data["Totp.CodeLength"] = params["totp.codeLength"];
if (params["totp.skew"] !== undefined)
data["Totp.Skew"] = params["totp.skew"];
if (params["defaultTemplateSid"] !== undefined)
data["DefaultTemplateSid"] = params["defaultTemplateSid"];
if (params["whatsapp.msgServiceSid"] !== undefined)
data["Whatsapp.MsgServiceSid"] = params["whatsapp.msgServiceSid"];
if (params["whatsapp.from"] !== undefined)
data["Whatsapp.From"] = params["whatsapp.from"];
if (params["passkeys.relyingParty.id"] !== undefined)
data["Passkeys.RelyingParty.Id"] = params["passkeys.relyingParty.id"];
if (params["passkeys.relyingParty.name"] !== undefined)
data["Passkeys.RelyingParty.Name"] = params["passkeys.relyingParty.name"];
if (params["passkeys.relyingParty.origins"] !== undefined)
data["Passkeys.RelyingParty.Origins"] =
params["passkeys.relyingParty.origins"];
if (params["passkeys.authenticatorAttachment"] !== undefined)
data["Passkeys.AuthenticatorAttachment"] =
params["passkeys.authenticatorAttachment"];
if (params["passkeys.discoverableCredentials"] !== undefined)
data["Passkeys.DiscoverableCredentials"] =
params["passkeys.discoverableCredentials"];
if (params["passkeys.userVerification"] !== undefined)
data["Passkeys.UserVerification"] = params["passkeys.userVerification"];
if (params["verifyEventSubscriptionEnabled"] !== undefined)
data["VerifyEventSubscriptionEnabled"] = serialize.bool(params["verifyEventSubscriptionEnabled"]);
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.update({
uri: instance._uri,
method: "post",
data,
headers,
});
operationPromise = operationPromise.then((payload) => new ServiceInstance(operationVersion, payload, instance._solution.sid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
updateWithHttpInfo(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
if (params["codeLength"] !== undefined)
data["CodeLength"] = params["codeLength"];
if (params["lookupEnabled"] !== undefined)
data["LookupEnabled"] = serialize.bool(params["lookupEnabled"]);
if (params["skipSmsToLandlines"] !== undefined)
data["SkipSmsToLandlines"] = serialize.bool(params["skipSmsToLandlines"]);
if (params["dtmfInputRequired"] !== undefined)
data["DtmfInputRequired"] = serialize.bool(params["dtmfInputRequired"]);
if (params["ttsName"] !== undefined)
data["TtsName"] = params["ttsName"];
if (params["psd2Enabled"] !== undefined)
data["Psd2Enabled"] = serialize.bool(params["psd2Enabled"]);
if (params["doNotShareWarningEnabled"] !== undefined)
data["DoNotShareWarningEnabled"] = serialize.bool(params["doNotShareWarningEnabled"]);
if (params["customCodeEnabled"] !== undefined)
data["CustomCodeEnabled"] = serialize.bool(params["customCodeEnabled"]);
if (params["push.includeDate"] !== undefined)
data["Push.IncludeDate"] = serialize.bool(params["push.includeDate"]);
if (params["push.apnCredentialSid"] !== undefined)
data["Push.ApnCredentialSid"] = params["push.apnCredentialSid"];
if (params["push.fcmCredentialSid"] !== undefined)
data["Push.FcmCredentialSid"] = params["push.fcmCredentialSid"];
if (params["totp.issuer"] !== undefined)
data["Totp.Issuer"] = params["totp.issuer"];
if (params["totp.timeStep"] !== undefined)
data["Totp.TimeStep"] = params["totp.timeStep"];
if (params["totp.codeLength"] !== undefined)
data["Totp.CodeLength"] = params["totp.codeLength"];
if (params["totp.skew"] !== undefined)
data["Totp.Skew"] = params["totp.skew"];
if (params["defaultTemplateSid"] !== undefined)
data["DefaultTemplateSid"] = params["defaultTemplateSid"];
if (params["whatsapp.msgServiceSid"] !== undefined)
data["Whatsapp.MsgServiceSid"] = params["whatsapp.msgServiceSid"];
if (params["whatsapp.from"] !== undefined)
data["Whatsapp.From"] = params["whatsapp.from"];
if (params["passkeys.relyingParty.id"] !== undefined)
data["Passkeys.RelyingParty.Id"] = params["passkeys.relyingParty.id"];
if (params["passkeys.relyingParty.name"] !== undefined)
data["Passkeys.RelyingParty.Name"] = params["passkeys.relyingParty.name"];
if (params["passkeys.relyingParty.origins"] !== undefined)
data["Passkeys.RelyingParty.Origins"] =
params["passkeys.relyingParty.origins"];
if (params["passkeys.authenticatorAttachment"] !== undefined)
data["Passkeys.AuthenticatorAttachment"] =
params["passkeys.authenticatorAttachment"];
if (params["passkeys.discoverableCredentials"] !== undefined)
data["Passkeys.DiscoverableCredentials"] =
params["passkeys.discoverableCredentials"];
if (params["passkeys.userVerification"] !== undefined)
data["Passkeys.UserVerification"] = params["passkeys.userVerification"];
if (params["verifyEventSubscriptionEnabled"] !== undefined)
data["VerifyEventSubscriptionEnabled"] = serialize.bool(params["verifyEventSubscriptionEnabled"]);
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.updateWithResponseInfo({
uri: instance._uri,
method: "post",
data,
headers,
})
.then((response) => ({
...response,
body: new ServiceInstance(operationVersion, response.body, instance._solution.sid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return this._solution;
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.ServiceContextImpl = ServiceContextImpl;
class ServiceInstance {
constructor(_version, payload, sid) {
this._version = _version;
this.sid = payload.sid;
this.accountSid = payload.account_sid;
this.friendlyName = payload.friendly_name;
this.codeLength = deserialize.integer(payload.code_length);
this.lookupEnabled = payload.lookup_enabled;
this.psd2Enabled = payload.psd2_enabled;
this.skipSmsToLandlines = payload.skip_sms_to_landlines;
this.dtmfInputRequired = payload.dtmf_input_required;
this.ttsName = payload.tts_name;
this.doNotShareWarningEnabled = payload.do_not_share_warning_enabled;
this.customCodeEnabled = payload.custom_code_enabled;
this.push = payload.push;
this.totp = payload.totp;
this.defaultTemplateSid = payload.default_template_sid;
this.whatsapp = payload.whatsapp;
this.passkeys = payload.passkeys;
this.verifyEventSubscriptionEnabled =
payload.verify_event_subscription_enabled;
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.url = payload.url;
this.links = payload.links;
this._solution = { sid: sid || this.sid };
}
get _proxy() {
this._context =
this._context ||
new ServiceContextImpl(this._version, this._solution.sid);
return this._context;
}
/**
* Remove a ServiceInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback) {
return this._proxy.remove(callback);
}
/**
* Remove a ServiceInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean with HTTP metadata
*/
removeWithHttpInfo(callback) {
return this._proxy.removeWithHttpInfo(callback);
}
/**
* Fetch a ServiceInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ServiceInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a ServiceInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ServiceInstance with HTTP metadata
*/
fetchWithHttpInfo(callback) {
return this._proxy.fetchWithHttpInfo(callback);
}
update(params, callback) {
return this._proxy.update(params, callback);
}
updateWithHttpInfo(params, callback) {
return this._proxy.updateWithHttpInfo(params, callback);
}
/**
* Access the accessTokens.
*/
accessTokens() {
return this._proxy.accessTokens;
}
/**
* Access the approveChallenge.
*/
approveChallenge() {
return this._proxy.approveChallenge;
}
/**
* Access the entities.
*/
entities() {
return this._proxy.entities;
}
/**
* Access the messagingConfigurations.
*/
messagingConfigurations() {
return this._proxy.messagingConfigurations;
}
/**
* Access the newChallenge.
*/
newChallenge() {
return this._proxy.newChallenge;
}
/**
* Access the newFactors.
*/
newFactors() {
return this._proxy.newFactors;
}
/**
* Access the newVerifyFactors.
*/
newVerifyFactors() {
return this._proxy.newVerifyFactors;
}
/**
* Access the rateLimits.
*/
rateLimits() {
return this._proxy.rateLimits;
}
/**
* Access the verifications.
*/
verifications() {
return this._proxy.verifications;
}
/**
* Access the verificationChecks.
*/
verificationChecks() {
return this._proxy.verificationChecks;
}
/**
* Access the webhooks.
*/
webhooks() {
return this._proxy.webhooks;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
sid: this.sid,
accountSid: this.accountSid,
friendlyName: this.friendlyName,
codeLength: this.codeLength,
lookupEnabled: this.lookupEnabled,
psd2Enabled: this.psd2Enabled,
skipSmsToLandlines: this.skipSmsToLandlines,
dtmfInputRequired: this.dtmfInputRequired,
ttsName: this.ttsName,
doNotShareWarningEnabled: this.doNotShareWarningEnabled,
customCodeEnabled: this.customCodeEnabled,
push: this.push,
totp: this.totp,
defaultTemplateSid: this.defaultTemplateSid,
whatsapp: this.whatsapp,
passkeys: this.passkeys,
verifyEventSubscriptionEnabled: this.verifyEventSubscriptionEnabled,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
url: this.url,
links: this.links,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.ServiceInstance = ServiceInstance;
function ServiceListInstance(version) {
const instance = ((sid) => instance.get(sid));
instance.get = function get(sid) {
return new ServiceContextImpl(version, sid);
};
instance._version = version;
instance._solution = {};
instance._uri = `/Services`;
instance.create = function create(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["friendlyName"] === null ||
params["friendlyName"] === undefined) {
throw new Error("Required parameter \"params['friendlyName']\" missing.");
}
let data = {};
data["FriendlyName"] = params["friendlyName"];
if (params["codeLength"] !== undefined)
data["CodeLength"] = params["codeLength"];
if (params["lookupEnabled"] !== undefined)
data["LookupEnabled"] = serialize.bool(params["lookupEnabled"]);
if (params["skipSmsToLandlines"] !== undefined)
data["SkipSmsToLandlines"] = serialize.bool(params["skipSmsToLandlines"]);
if (params["dtmfInputRequired"] !== undefined)
data["DtmfInputRequired"] = serialize.bool(params["dtmfInputRequired"]);
if (params["ttsName"] !== undefined)
data["TtsName"] = params["ttsName"];
if (params["psd2Enabled"] !== undefined)
data["Psd2Enabled"] = serialize.bool(params["psd2Enabled"]);
if (params["doNotShareWarningEnabled"] !== undefined)
data["DoNotShareWarningEnabled"] = serialize.bool(params["doNotShareWarningEnabled"]);
if (params["customCodeEnabled"] !== undefined)
data["CustomCodeEnabled"] = serialize.bool(params["customCodeEnabled"]);
if (params["push.includeDate"] !== undefined)
data["Push.IncludeDate"] = serialize.bool(params["push.includeDate"]);
if (params["push.apnCredentialSid"] !== undefined)
data["Push.ApnCredentialSid"] = params["push.apnCredentialSid"];
if (params["push.fcmCredentialSid"] !== undefined)
data["Push.FcmCredentialSid"] = params["push.fcmCredentialSid"];
if (params["totp.issuer"] !== undefined)
data["Totp.Issuer"] = params["totp.issuer"];
if (params["totp.timeStep"] !== undefined)
data["Totp.TimeStep"] = params["totp.timeStep"];
if (params["totp.codeLength"] !== undefined)
data["Totp.CodeLength"] = params["totp.codeLength"];
if (params["totp.skew"] !== undefined)
data["Totp.Skew"] = params["totp.skew"];
if (params["defaultTemplateSid"] !== undefined)
data["DefaultTemplateSid"] = params["defaultTemplateSid"];
if (params["whatsapp.msgServiceSid"] !== undefined)
data["Whatsapp.MsgServiceSid"] = params["whatsapp.msgServiceSid"];
if (params["whatsapp.from"] !== undefined)
data["Whatsapp.From"] = params["whatsapp.from"];
if (params["passkeys.relyingParty.id"] !== undefined)
data["Passkeys.RelyingParty.Id"] = params["passkeys.relyingParty.id"];
if (params["passkeys.relyingParty.name"] !== undefined)
data["Passkeys.RelyingParty.Name"] = params["passkeys.relyingParty.name"];
if (params["passkeys.relyingParty.origins"] !== undefined)
data["Passkeys.RelyingParty.Origins"] =
params["passkeys.relyingParty.origins"];
if (params["passkeys.authenticatorAttachment"] !== undefined)
data["Passkeys.AuthenticatorAttachment"] =
params["passkeys.authenticatorAttachment"];
if (params["passkeys.discoverableCredentials"] !== undefined)
data["Passkeys.DiscoverableCredentials"] =
params["passkeys.discoverableCredentials"];
if (params["passkeys.userVerification"] !== undefined)
data["Passkeys.UserVerification"] = params["passkeys.userVerification"];
if (params["verifyEventSubscriptionEnabled"] !== undefined)
data["VerifyEventSubscriptionEnabled"] = serialize.bool(params["verifyEventSubscriptionEnabled"]);
const headers = {};
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 ServiceInstance(operationVersion, payload));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.createWithHttpInfo = function createWithHttpInfo(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["friendlyName"] === null ||
params["friendlyName"] === undefined) {
throw new Error("Required parameter \"params['friendlyName']\" missing.");
}
let data = {};
data["FriendlyName"] = params["friendlyName"];
if (params["codeLength"] !== undefined)
data["CodeLength"] = params["codeLength"];
if (params["lookupEnabled"] !== undefined)
data["LookupEnabled"] = serialize.bool(params["lookupEnabled"]);
if (params["skipSmsToLandlines"] !== undefined)
data["SkipSmsToLandlines"] = serialize.bool(params["skipSmsToLandlines"]);
if (params["dtmfInputRequired"] !== undefined)
data["DtmfInputRequired"] = serialize.bool(params["dtmfInputRequired"]);
if (params["ttsName"] !== undefined)
data["TtsName"] = params["ttsName"];
if (params["psd2Enabled"] !== undefined)
data["Psd2Enabled"] = serialize.bool(params["psd2Enabled"]);
if (params["doNotShareWarningEnabled"] !== undefined)
data["DoNotShareWarningEnabled"] = serialize.bool(params["doNotShareWarningEnabled"]);
if (params["customCodeEnabled"] !== undefined)
data["CustomCodeEnabled"] = serialize.bool(params["customCodeEnabled"]);
if (params["push.includeDate"] !== undefined)
data["Push.IncludeDate"] = serialize.bool(params["push.includeDate"]);
if (params["push.apnCredentialSid"] !== undefined)
data["Push.ApnCredentialSid"] = params["push.apnCredentialSid"];
if (params["push.fcmCredentialSid"] !== undefined)
data["Push.FcmCredentialSid"] = params["push.fcmCredentialSid"];
if (params["totp.issuer"] !== undefined)
data["Totp.Issuer"] = params["totp.issuer"];
if (params["totp.timeStep"] !== undefined)
data["Totp.TimeStep"] = params["totp.timeStep"];
if (params["totp.codeLength"] !== undefined)
data["Totp.CodeLength"] = params["totp.codeLength"];
if (params["totp.skew"] !== undefined)
data["Totp.Skew"] = params["totp.skew"];
if (params["defaultTemplateSid"] !== undefined)
data["DefaultTemplateSid"] = params["defaultTemplateSid"];
if (params["whatsapp.msgServiceSid"] !== undefined)
data["Whatsapp.MsgServiceSid"] = params["whatsapp.msgServiceSid"];
if (params["whatsapp.from"] !== undefined)
data["Whatsapp.From"] = params["whatsapp.from"];
if (params["passkeys.relyingParty.id"] !== undefined)
data["Passkeys.RelyingParty.Id"] = params["passkeys.relyingParty.id"];
if (params["passkeys.relyingParty.name"] !== undefined)
data["Passkeys.RelyingParty.Name"] = params["passkeys.relyingParty.name"];
if (params["passkeys.relyingParty.origins"] !== undefined)
data["Passkeys.RelyingParty.Origins"] =
params["passkeys.relyingParty.origins"];
if (params["passkeys.authenticatorAttachment"] !== undefined)
data["Passkeys.AuthenticatorAttachment"] =
params["passkeys.authenticatorAttachment"];
if (params["passkeys.discoverableCredentials"] !== undefined)
data["Passkeys.DiscoverableCredentials"] =
params["passkeys.discoverableCredentials"];
if (params["passkeys.userVerification"] !== undefined)
data["Passkeys.UserVerification"] = params["passkeys.userVerification"];
if (params["verifyEventSubscriptionEnabled"] !== undefined)
data["VerifyEventSubscriptionEnabled"] = serialize.bool(params["verifyEventSubscriptionEnabled"]);
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
let operationVersion = version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.createWithResponseInfo({
uri: instance._uri,
method: "post",
data,
headers,
})
.then((response) => ({
...response,
body: new ServiceInstance(operationVersion, response.body),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.page = function page(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["pageSize"] !== undefined)
data["PageSize"] = params["pageSize"];
if (params.pageNumber !== undefined)
data["Page"] = params.pageNumber;
if (params.pageToken !== undefined)
data["PageToken"] = params.pageToken;
const headers = {};
headers["Accept"] = "application/json";
let operationVersion = version, operationPromise = operationVersion.page({
uri: instance._uri,
method: "get",
params: data,
headers,
});
operationPromise = operationPromise.then((payload) => new ServicePage(operationVersion, payload, instance._solution));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.each = instance._version.each;
instance.list = instance._version.list;
instance.getPage = function getPage(targetUrl, callback) {
const operationPromise = instance._version._domain.twilio.request({
method: "get",
uri: targetUrl,
});
let pagePromise = operationPromise.then((payload) => new ServicePage(instance._version, payload, instance._solution));
pagePromise = instance._version.setPromiseCallback(pagePromise, callback);
return pagePromise;
};
instance.pageWithHttpInfo = function pageWithHttpInfo(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["pageSize"] !== undefined)
data["PageSize"] = params["pageSize"];
if (params.pageNumber !== undefined)
data["Page"] = params.pageNumber;
if (params.pageToken !== undefined)
data["PageToken"] = params.pageToken;
const headers = {};
headers["Accept"] = "application/json";
let operationVersion = version;
// For page operations, use page() directly as it already returns { statusCode, body, headers }
// IMPORTANT: Pass full response to Page constructor, not response.body
let operationPromise = operationVersion
.page({ uri: instance._uri, method: "get", params: data, headers })
.then((response) => ({
statusCode: response.statusCode,
headers: response.headers,
body: new ServicePage(operationVersion, response, instance._solution),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.each = instance._version.each;
instance.eachWithHttpInfo = instance._version.eachWithHttpInfo;
instance.list = instance._version.list;
instance.listWithHttpInfo = instance._version.listWithHttpInfo;
instance.getPageWithHttpInfo = function getPageWithHttpInfo(targetUrl, callback) {
// Use request() directly as it already returns { statusCode, body, headers }
const operationPromise = instance._version._domain.twilio.request({
method: "get",
uri: targetUrl,
});
let pagePromise = operationPromise.then((response) => ({
statusCode: response.statusCode,
headers: response.headers,
body: new ServicePage(instance._version, response, instance._solution),
}));
pagePromise = instance._version.setPromiseCallback(pagePromise, callback);
return pagePromise;
};
instance.toJSON = function toJSON() {
return instance._solution;
};
instance[util_1.inspect.custom] = function inspectImpl(_depth, options) {
return (0, util_1.inspect)(instance.toJSON(), options);
};
return instance;
}
class ServicePage extends Page_1.default {
/**
* Initialize the ServicePage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version, response, solution) {
super(version, response, solution);
}
/**
* Build an instance of ServiceInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new ServiceInstance(this._version, payload);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.ServicePage = ServicePage;

View File

@@ -0,0 +1,187 @@
import { inspect, InspectOptions } from "util";
import V2 from "../../V2";
import { ApiResponse } from "../../../../base/ApiResponse";
/**
* The Type of the Factor. Currently only `push` is supported.
*/
export type AccessTokenFactorTypes = "push";
/**
* Options to pass to create a AccessTokenInstance
*/
export interface AccessTokenListInstanceCreateOptions {
/** The unique external identifier for the Entity of the Service. This identifier should be immutable, not PII, and generated by your external system, such as your user\\\'s UUID, GUID, or SID. */
identity: string;
/** */
factorType: AccessTokenFactorTypes;
/** The friendly name of the factor that is going to be created with this access token */
factorFriendlyName?: string;
/** How long, in seconds, the access token is valid. Can be an integer between 60 and 300. Default is 60. */
ttl?: number;
}
export interface AccessTokenContext {
/**
* Fetch a AccessTokenInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed AccessTokenInstance
*/
fetch(callback?: (error: Error | null, item?: AccessTokenInstance) => any): Promise<AccessTokenInstance>;
/**
* Fetch a AccessTokenInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed AccessTokenInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<AccessTokenInstance>) => any): Promise<ApiResponse<AccessTokenInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface AccessTokenContextSolution {
serviceSid: string;
sid: string;
}
export declare class AccessTokenContextImpl implements AccessTokenContext {
protected _version: V2;
protected _solution: AccessTokenContextSolution;
protected _uri: string;
constructor(_version: V2, serviceSid: string, sid: string);
fetch(callback?: (error: Error | null, item?: AccessTokenInstance) => any): Promise<AccessTokenInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<AccessTokenInstance>) => any): Promise<ApiResponse<AccessTokenInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): AccessTokenContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface AccessTokenResource {
sid: string;
account_sid: string;
service_sid: string;
entity_identity: string;
factor_type: AccessTokenFactorTypes;
factor_friendly_name: string;
token: string;
url: string;
ttl: number;
date_created: Date;
}
export declare class AccessTokenInstance {
protected _version: V2;
protected _solution: AccessTokenContextSolution;
protected _context?: AccessTokenContext;
constructor(_version: V2, payload: AccessTokenResource, serviceSid: string, sid?: string);
/**
* A 34 character string that uniquely identifies this Access Token.
*/
sid: string;
/**
* The unique SID identifier of the Account.
*/
accountSid: string;
/**
* The unique SID identifier of the Verify Service.
*/
serviceSid: string;
/**
* The unique external identifier for the Entity of the Service.
*/
entityIdentity: string;
factorType: AccessTokenFactorTypes;
/**
* A human readable description of this factor, up to 64 characters. For a push factor, this can be the device\'s name.
*/
factorFriendlyName: string;
/**
* The access token generated for enrollment, this is an encrypted json web token.
*/
token: string;
/**
* The URL of this resource.
*/
url: string;
/**
* How long, in seconds, the access token is valid. Max: 5 minutes
*/
ttl: number;
/**
* The date that this access token was created, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateCreated: Date;
private get _proxy();
/**
* Fetch a AccessTokenInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed AccessTokenInstance
*/
fetch(callback?: (error: Error | null, item?: AccessTokenInstance) => any): Promise<AccessTokenInstance>;
/**
* Fetch a AccessTokenInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed AccessTokenInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<AccessTokenInstance>) => any): Promise<ApiResponse<AccessTokenInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
accountSid: string;
serviceSid: string;
entityIdentity: string;
factorType: "push";
factorFriendlyName: string;
token: string;
url: string;
ttl: number;
dateCreated: Date;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface AccessTokenSolution {
serviceSid: string;
}
export interface AccessTokenListInstance {
_version: V2;
_solution: AccessTokenSolution;
_uri: string;
(sid: string): AccessTokenContext;
get(sid: string): AccessTokenContext;
/**
* Create a AccessTokenInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed AccessTokenInstance
*/
create(params: AccessTokenListInstanceCreateOptions, callback?: (error: Error | null, item?: AccessTokenInstance) => any): Promise<AccessTokenInstance>;
/**
* Create a AccessTokenInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed AccessTokenInstance with HTTP metadata
*/
createWithHttpInfo(params: AccessTokenListInstanceCreateOptions, callback?: (error: Error | null, item?: ApiResponse<AccessTokenInstance>) => any): Promise<ApiResponse<AccessTokenInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function AccessTokenListInstance(version: V2, serviceSid: string): AccessTokenListInstance;
export {};

View File

@@ -0,0 +1,228 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Verify
* 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.AccessTokenInstance = exports.AccessTokenContextImpl = void 0;
exports.AccessTokenListInstance = AccessTokenListInstance;
const util_1 = require("util");
const deserialize = require("../../../../base/deserialize");
const serialize = require("../../../../base/serialize");
const utility_1 = require("../../../../base/utility");
class AccessTokenContextImpl {
constructor(_version, serviceSid, sid) {
this._version = _version;
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(sid)) {
throw new Error("Parameter 'sid' is not valid.");
}
this._solution = { serviceSid, sid };
this._uri = `/Services/${serviceSid}/AccessTokens/${sid}`;
}
fetch(callback) {
const headers = {};
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.fetch({
uri: instance._uri,
method: "get",
headers,
});
operationPromise = operationPromise.then((payload) => new AccessTokenInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.sid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
fetchWithHttpInfo(callback) {
const headers = {};
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.fetchWithResponseInfo({
uri: instance._uri,
method: "get",
headers,
})
.then((response) => ({
...response,
body: new AccessTokenInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.sid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return this._solution;
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.AccessTokenContextImpl = AccessTokenContextImpl;
class AccessTokenInstance {
constructor(_version, payload, serviceSid, sid) {
this._version = _version;
this.sid = payload.sid;
this.accountSid = payload.account_sid;
this.serviceSid = payload.service_sid;
this.entityIdentity = payload.entity_identity;
this.factorType = payload.factor_type;
this.factorFriendlyName = payload.factor_friendly_name;
this.token = payload.token;
this.url = payload.url;
this.ttl = deserialize.integer(payload.ttl);
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this._solution = { serviceSid, sid: sid || this.sid };
}
get _proxy() {
this._context =
this._context ||
new AccessTokenContextImpl(this._version, this._solution.serviceSid, this._solution.sid);
return this._context;
}
/**
* Fetch a AccessTokenInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed AccessTokenInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a AccessTokenInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed AccessTokenInstance with HTTP metadata
*/
fetchWithHttpInfo(callback) {
return this._proxy.fetchWithHttpInfo(callback);
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
sid: this.sid,
accountSid: this.accountSid,
serviceSid: this.serviceSid,
entityIdentity: this.entityIdentity,
factorType: this.factorType,
factorFriendlyName: this.factorFriendlyName,
token: this.token,
url: this.url,
ttl: this.ttl,
dateCreated: this.dateCreated,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.AccessTokenInstance = AccessTokenInstance;
function AccessTokenListInstance(version, serviceSid) {
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
const instance = ((sid) => instance.get(sid));
instance.get = function get(sid) {
return new AccessTokenContextImpl(version, serviceSid, sid);
};
instance._version = version;
instance._solution = { serviceSid };
instance._uri = `/Services/${serviceSid}/AccessTokens`;
instance.create = function create(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["identity"] === null || params["identity"] === undefined) {
throw new Error("Required parameter \"params['identity']\" missing.");
}
if (params["factorType"] === null || params["factorType"] === undefined) {
throw new Error("Required parameter \"params['factorType']\" missing.");
}
let data = {};
data["Identity"] = params["identity"];
data["FactorType"] = params["factorType"];
if (params["factorFriendlyName"] !== undefined)
data["FactorFriendlyName"] = params["factorFriendlyName"];
if (params["ttl"] !== undefined)
data["Ttl"] = params["ttl"];
const headers = {};
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 AccessTokenInstance(operationVersion, payload, instance._solution.serviceSid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.createWithHttpInfo = function createWithHttpInfo(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["identity"] === null || params["identity"] === undefined) {
throw new Error("Required parameter \"params['identity']\" missing.");
}
if (params["factorType"] === null || params["factorType"] === undefined) {
throw new Error("Required parameter \"params['factorType']\" missing.");
}
let data = {};
data["Identity"] = params["identity"];
data["FactorType"] = params["factorType"];
if (params["factorFriendlyName"] !== undefined)
data["FactorFriendlyName"] = params["factorFriendlyName"];
if (params["ttl"] !== undefined)
data["Ttl"] = params["ttl"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
let operationVersion = version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.createWithResponseInfo({
uri: instance._uri,
method: "post",
data,
headers,
})
.then((response) => ({
...response,
body: new AccessTokenInstance(operationVersion, response.body, instance._solution.serviceSid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.toJSON = function toJSON() {
return instance._solution;
};
instance[util_1.inspect.custom] = function inspectImpl(_depth, options) {
return (0, util_1.inspect)(instance.toJSON(), options);
};
return instance;
}

View File

@@ -0,0 +1,215 @@
import { inspect, InspectOptions } from "util";
import V2 from "../../V2";
import { ApiResponse } from "../../../../base/ApiResponse";
export declare class ApprovePasskeysChallengeRequest {
/**
* A [base64url](https://base64.guru/standards/base64url) encoded representation of `rawId`.
*/
"id": string;
/**
* The globally unique identifier for this `PublicKeyCredential`.
*/
"rawId": string;
/**
* A string that indicates the mechanism by which the WebAuthn implementation is attached to the authenticator at the time the associated `navigator.credentials.create()` or `navigator.credentials.get()` call completes.
*/
"authenticatorAttachment": string;
/**
* The valid credential types supported by the API. The values of this enumeration are used for versioning the `AuthenticatorAssertion` and `AuthenticatorAttestation` structures according to the type of the authenticator.
*/
"type"?: string;
"response": ApprovePasskeysChallengeRequestResponse;
constructor(payload: any);
}
/**
* The result of a WebAuthn authentication via a `navigator.credentials.get()` request, as specified in [AuthenticatorAttestationResponse](https://developer.mozilla.org/en-US/docs/Web/API/AuthenticatorAttestationResponse).
*/
export declare class ApprovePasskeysChallengeRequestResponse {
/**
* The [authenticator data](https://developer.mozilla.org/en-US/docs/Web/API/Web_Authentication_API/Authenticator_data) structure contains information from the authenticator about the processing of a credential creation or authentication request.
*/
"authenticatorData": string;
/**
* This property contains the JSON-compatible serialization of the data passed from the browser to the authenticator in order to generate this credential.
*/
"clientDataJSON": string;
/**
* An assertion signature over `authenticatorData` and `clientDataJSON`. The assertion signature is created with the private key of the key pair that was created during the originating `navigator.credentials.create()` call and verified using the public key of that same key pair.
*/
"signature": string;
/**
* The user handle stored in the authenticator, specified as `user.id` in the options passed to the originating `navigator.credentials.create()` call. This property should contain a base64url-encoded entity SID.
*/
"userHandle"?: string;
constructor(payload: any);
}
/**
* Options to pass to update a ApproveChallengeInstance
*/
export interface ApproveChallengeListInstanceUpdateOptions {
/** */
approvePasskeysChallengeRequest: ApprovePasskeysChallengeRequest;
}
export interface ApproveChallengeSolution {
serviceSid: string;
}
export interface ApproveChallengeListInstance {
_version: V2;
_solution: ApproveChallengeSolution;
_uri: string;
/**
* Update a ApproveChallengeInstance
*
* @param params - Body for request
* @param headers - header params for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ApproveChallengeInstance
*/
update(params: ApprovePasskeysChallengeRequest, headers?: any, callback?: (error: Error | null, item?: ApproveChallengeInstance) => any): Promise<ApproveChallengeInstance>;
/**
* Update a ApproveChallengeInstance and return HTTP info
*
* @param params - Body for request
* @param headers - header params for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ApproveChallengeInstance with HTTP metadata
*/
updateWithHttpInfo(params: ApprovePasskeysChallengeRequest, headers?: any, callback?: (error: Error | null, item?: ApiResponse<ApproveChallengeInstance>) => any): Promise<ApiResponse<ApproveChallengeInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function ApproveChallengeListInstance(version: V2, serviceSid: string): ApproveChallengeListInstance;
interface ApproveChallengeResource {
options: Record<string, object>;
sid: string;
account_sid: string;
service_sid: string;
entity_sid: string;
identity: string;
factor_sid: string;
date_created: Date;
date_updated: Date;
date_responded: Date;
expiration_date: Date;
status: string;
responded_reason: string;
details: any;
hidden_details: any;
metadata: any;
factor_type: string;
url: string;
links: Record<string, string>;
}
export declare class ApproveChallengeInstance {
protected _version: V2;
constructor(_version: V2, payload: ApproveChallengeResource, serviceSid: string);
/**
* An object that contains challenge options. Currently only used for `passkeys`.
*/
options: Record<string, object>;
/**
* A 34 character string that uniquely identifies this Challenge.
*/
sid: string;
/**
* The unique SID identifier of the Account.
*/
accountSid: string;
/**
* The unique SID identifier of the Service.
*/
serviceSid: string;
/**
* The unique SID identifier of the Entity.
*/
entitySid: string;
/**
* Customer unique identity for the Entity owner of the Challenge.
*/
identity: string;
/**
* The unique SID identifier of the Factor.
*/
factorSid: string;
/**
* The date that this Challenge was created, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateCreated: Date;
/**
* The date that this Challenge was updated, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateUpdated: Date;
/**
* The date that this Challenge was responded, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateResponded: Date;
/**
* The date-time when this Challenge expires, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
expirationDate: Date;
/**
* The Status of this Challenge. One of `pending`, `expired`, `approved` or `denied`.
*/
status: string;
/**
* Reason for the Challenge to be in certain `status`. One of `none`, `not_needed` or `not_requested`.
*/
respondedReason: string;
/**
* Details provided to give context about the Challenge.
*/
details: any;
/**
* Details provided to give context about the Challenge.
*/
hiddenDetails: any;
/**
* Custom metadata associated with the challenge.
*/
metadata: any;
/**
* The Factor Type of this Challenge. Currently `push` and `totp` are supported.
*/
factorType: string;
/**
* The URL of this resource.
*/
url: string;
/**
* Contains a dictionary of URL links to nested resources of this Challenge.
*/
links: Record<string, string>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
options: Record<string, object>;
sid: string;
accountSid: string;
serviceSid: string;
entitySid: string;
identity: string;
factorSid: string;
dateCreated: Date;
dateUpdated: Date;
dateResponded: Date;
expirationDate: Date;
status: string;
respondedReason: string;
details: any;
hiddenDetails: any;
metadata: any;
factorType: string;
url: string;
links: Record<string, string>;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export {};

View File

@@ -0,0 +1,163 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Verify
* 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.ApproveChallengeInstance = exports.ApprovePasskeysChallengeRequestResponse = exports.ApprovePasskeysChallengeRequest = void 0;
exports.ApproveChallengeListInstance = ApproveChallengeListInstance;
const util_1 = require("util");
const deserialize = require("../../../../base/deserialize");
const serialize = require("../../../../base/serialize");
const utility_1 = require("../../../../base/utility");
class ApprovePasskeysChallengeRequest {
constructor(payload) {
this.id = payload["id"];
this.rawId = payload["rawId"];
this.authenticatorAttachment = payload["authenticatorAttachment"];
this.type = payload["type"];
this.response = payload["response"];
}
}
exports.ApprovePasskeysChallengeRequest = ApprovePasskeysChallengeRequest;
/**
* The result of a WebAuthn authentication via a `navigator.credentials.get()` request, as specified in [AuthenticatorAttestationResponse](https://developer.mozilla.org/en-US/docs/Web/API/AuthenticatorAttestationResponse).
*/
class ApprovePasskeysChallengeRequestResponse {
constructor(payload) {
this.authenticatorData = payload["authenticatorData"];
this.clientDataJSON = payload["clientDataJSON"];
this.signature = payload["signature"];
this.userHandle = payload["userHandle"];
}
}
exports.ApprovePasskeysChallengeRequestResponse = ApprovePasskeysChallengeRequestResponse;
function ApproveChallengeListInstance(version, serviceSid) {
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
const instance = {};
instance._version = version;
instance._solution = { serviceSid };
instance._uri = `/Services/${serviceSid}/Passkeys/ApproveChallenge`;
instance.update = function update(params, headers, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
let data = {};
data = params;
if (headers === null || headers === undefined) {
headers = {};
}
headers["Content-Type"] = "application/json";
headers["Accept"] = "application/json";
let operationVersion = version, operationPromise = operationVersion.update({
uri: instance._uri,
method: "post",
data,
headers,
});
operationPromise = operationPromise.then((payload) => new ApproveChallengeInstance(operationVersion, payload, instance._solution.serviceSid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.updateWithHttpInfo = function updateWithHttpInfo(params, headers, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
let data = {};
data = params;
if (headers === null || headers === undefined) {
headers = {};
}
headers["Content-Type"] = "application/json";
headers["Accept"] = "application/json";
let operationVersion = version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.updateWithResponseInfo({
uri: instance._uri,
method: "post",
data,
headers,
})
.then((response) => ({
...response,
body: new ApproveChallengeInstance(operationVersion, response.body, instance._solution.serviceSid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.toJSON = function toJSON() {
return instance._solution;
};
instance[util_1.inspect.custom] = function inspectImpl(_depth, options) {
return (0, util_1.inspect)(instance.toJSON(), options);
};
return instance;
}
class ApproveChallengeInstance {
constructor(_version, payload, serviceSid) {
this._version = _version;
this.options = payload.options;
this.sid = payload.sid;
this.accountSid = payload.account_sid;
this.serviceSid = payload.service_sid;
this.entitySid = payload.entity_sid;
this.identity = payload.identity;
this.factorSid = payload.factor_sid;
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.dateResponded = deserialize.iso8601DateTime(payload.date_responded);
this.expirationDate = deserialize.iso8601DateTime(payload.expiration_date);
this.status = payload.status;
this.respondedReason = payload.responded_reason;
this.details = payload.details;
this.hiddenDetails = payload.hidden_details;
this.metadata = payload.metadata;
this.factorType = payload.factor_type;
this.url = payload.url;
this.links = payload.links;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
options: this.options,
sid: this.sid,
accountSid: this.accountSid,
serviceSid: this.serviceSid,
entitySid: this.entitySid,
identity: this.identity,
factorSid: this.factorSid,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
dateResponded: this.dateResponded,
expirationDate: this.expirationDate,
status: this.status,
respondedReason: this.respondedReason,
details: this.details,
hiddenDetails: this.hiddenDetails,
metadata: this.metadata,
factorType: this.factorType,
url: this.url,
links: this.links,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.ApproveChallengeInstance = ApproveChallengeInstance;

View File

@@ -0,0 +1,383 @@
import { inspect, InspectOptions } from "util";
import Page, { TwilioResponsePayload } from "../../../../base/Page";
import Response from "../../../../http/response";
import V2 from "../../V2";
import { ApiResponse } from "../../../../base/ApiResponse";
import { ChallengeListInstance } from "./entity/challenge";
import { FactorListInstance } from "./entity/factor";
import { NewFactorListInstance } from "./entity/newFactor";
/**
* Options to pass to create a EntityInstance
*/
export interface EntityListInstanceCreateOptions {
/** The unique external identifier for the Entity of the Service. This identifier should be immutable, not PII, length between 8 and 64 characters, and generated by your external system, such as your user\\\'s UUID, GUID, or SID. It can only contain dash (-) separated alphanumeric characters. */
identity: string;
}
/**
* Options to pass to each
*/
export interface EntityListInstanceEachOptions {
/** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
pageSize?: number;
/** Function to process each record. If this and a positional callback are passed, this one will be used */
callback?: (item: EntityInstance, done: (err?: Error) => void) => void;
/** Function to be called upon completion of streaming */
done?: Function;
/** Upper limit for the number of records to return. each() guarantees never to return more than limit. Default is no limit */
limit?: number;
}
/**
* Options to pass to list
*/
export interface EntityListInstanceOptions {
/** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
pageSize?: number;
/** Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit */
limit?: number;
}
/**
* Options to pass to page
*/
export interface EntityListInstancePageOptions {
/** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
pageSize?: number;
/** Page Number, this value is simply for client state */
pageNumber?: number;
/** PageToken provided by the API */
pageToken?: string;
}
export interface EntityContext {
challenges: ChallengeListInstance;
factors: FactorListInstance;
newFactors: NewFactorListInstance;
/**
* Remove a EntityInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a EntityInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean with HTTP metadata
*/
removeWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
/**
* Fetch a EntityInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed EntityInstance
*/
fetch(callback?: (error: Error | null, item?: EntityInstance) => any): Promise<EntityInstance>;
/**
* Fetch a EntityInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed EntityInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<EntityInstance>) => any): Promise<ApiResponse<EntityInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface EntityContextSolution {
serviceSid: string;
identity: string;
}
export declare class EntityContextImpl implements EntityContext {
protected _version: V2;
protected _solution: EntityContextSolution;
protected _uri: string;
protected _challenges?: ChallengeListInstance;
protected _factors?: FactorListInstance;
protected _newFactors?: NewFactorListInstance;
constructor(_version: V2, serviceSid: string, identity: string);
get challenges(): ChallengeListInstance;
get factors(): FactorListInstance;
get newFactors(): NewFactorListInstance;
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
removeWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
fetch(callback?: (error: Error | null, item?: EntityInstance) => any): Promise<EntityInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<EntityInstance>) => any): Promise<ApiResponse<EntityInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): EntityContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface EntityPayload extends TwilioResponsePayload {
entities: EntityResource[];
}
interface EntityResource {
sid: string;
identity: string;
account_sid: string;
service_sid: string;
date_created: Date;
date_updated: Date;
url: string;
links: Record<string, string>;
}
export declare class EntityInstance {
protected _version: V2;
protected _solution: EntityContextSolution;
protected _context?: EntityContext;
constructor(_version: V2, payload: EntityResource, serviceSid: string, identity?: string);
/**
* A 34 character string that uniquely identifies this Entity.
*/
sid: string;
/**
* The unique external identifier for the Entity of the Service. This identifier should be immutable, not PII, length between 8 and 64 characters, and generated by your external system, such as your user\'s UUID, GUID, or SID. It can only contain dash (-) separated alphanumeric characters.
*/
identity: string;
/**
* The unique SID identifier of the Account.
*/
accountSid: string;
/**
* The unique SID identifier of the Service.
*/
serviceSid: string;
/**
* The date that this Entity was created, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateCreated: Date;
/**
* The date that this Entity was updated, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateUpdated: Date;
/**
* The URL of this resource.
*/
url: string;
/**
* Contains a dictionary of URL links to nested resources of this Entity.
*/
links: Record<string, string>;
private get _proxy();
/**
* Remove a EntityInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a EntityInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean with HTTP metadata
*/
removeWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
/**
* Fetch a EntityInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed EntityInstance
*/
fetch(callback?: (error: Error | null, item?: EntityInstance) => any): Promise<EntityInstance>;
/**
* Fetch a EntityInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed EntityInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<EntityInstance>) => any): Promise<ApiResponse<EntityInstance>>;
/**
* Access the challenges.
*/
challenges(): ChallengeListInstance;
/**
* Access the factors.
*/
factors(): FactorListInstance;
/**
* Access the newFactors.
*/
newFactors(): NewFactorListInstance;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
identity: string;
accountSid: string;
serviceSid: string;
dateCreated: Date;
dateUpdated: Date;
url: string;
links: Record<string, string>;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface EntitySolution {
serviceSid: string;
}
export interface EntityListInstance {
_version: V2;
_solution: EntitySolution;
_uri: string;
(identity: string): EntityContext;
get(identity: string): EntityContext;
/**
* Create a EntityInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed EntityInstance
*/
create(params: EntityListInstanceCreateOptions, callback?: (error: Error | null, item?: EntityInstance) => any): Promise<EntityInstance>;
/**
* Create a EntityInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed EntityInstance with HTTP metadata
*/
createWithHttpInfo(params: EntityListInstanceCreateOptions, callback?: (error: Error | null, item?: ApiResponse<EntityInstance>) => any): Promise<ApiResponse<EntityInstance>>;
/**
* Streams EntityInstance records from the API.
*
* This operation lazily loads records as efficiently as possible until the limit
* is reached.
*
* The results are passed into the callback function, so this operation is memory
* efficient.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { EntityListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: EntityInstance, done: (err?: Error) => void) => void): void;
each(params: EntityListInstanceEachOptions, callback?: (item: EntityInstance, done: (err?: Error) => void) => void): void;
/**
* Streams EntityInstance records from the API with HTTP metadata captured per page.
*
* This operation lazily loads records as efficiently as possible until the limit
* is reached. HTTP metadata (status code, headers) is captured for each page request.
*
* The results are passed into the callback function, so this operation is memory
* efficient.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { EntityListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: EntityInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: EntityListInstanceEachOptions, callback?: (item: EntityInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of EntityInstance records from the API.
*
* The request is executed immediately.
*
* @param { string } [targetUrl] - API-generated URL for the requested results page
* @param { function } [callback] - Callback to handle list of records
*/
getPage(targetUrl: string, callback?: (error: Error | null, items: EntityPage) => any): Promise<EntityPage>;
/**
* Retrieve a single target page of EntityInstance records from the API with HTTP metadata.
*
* The request is executed immediately.
*
* @param { string } [targetUrl] - API-generated URL for the requested results page
* @param { function } [callback] - Callback to handle list of records with metadata
*/
getPageWithHttpInfo(targetUrl: string, callback?: (error: Error | null, items: ApiResponse<EntityPage>) => any): Promise<ApiResponse<EntityPage>>;
/**
* Lists EntityInstance records from the API as a list.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { EntityListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: EntityInstance[]) => any): Promise<EntityInstance[]>;
list(params: EntityListInstanceOptions, callback?: (error: Error | null, items: EntityInstance[]) => any): Promise<EntityInstance[]>;
/**
* Lists EntityInstance records from the API as a list with HTTP metadata.
*
* Returns all records along with HTTP metadata from the first page fetched.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { EntityListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<EntityInstance[]>) => any): Promise<ApiResponse<EntityInstance[]>>;
listWithHttpInfo(params: EntityListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<EntityInstance[]>) => any): Promise<ApiResponse<EntityInstance[]>>;
/**
* Retrieve a single page of EntityInstance records from the API.
*
* The request is executed immediately.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { EntityListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: EntityPage) => any): Promise<EntityPage>;
page(params: EntityListInstancePageOptions, callback?: (error: Error | null, items: EntityPage) => any): Promise<EntityPage>;
/**
* Retrieve a single page of EntityInstance records from the API with HTTP metadata.
*
* The request is executed immediately.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { EntityListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<EntityPage>) => any): Promise<ApiResponse<EntityPage>>;
pageWithHttpInfo(params: EntityListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<EntityPage>) => any): Promise<ApiResponse<EntityPage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function EntityListInstance(version: V2, serviceSid: string): EntityListInstance;
export declare class EntityPage extends Page<V2, EntityPayload, EntityResource, EntityInstance> {
/**
* Initialize the EntityPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V2, response: Response<string>, solution: EntitySolution);
/**
* Build an instance of EntityInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: EntityResource): EntityInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

View File

@@ -0,0 +1,406 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Verify
* 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.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.EntityPage = exports.EntityInstance = exports.EntityContextImpl = void 0;
exports.EntityListInstance = EntityListInstance;
const util_1 = require("util");
const Page_1 = __importDefault(require("../../../../base/Page"));
const deserialize = require("../../../../base/deserialize");
const serialize = require("../../../../base/serialize");
const utility_1 = require("../../../../base/utility");
const challenge_1 = require("./entity/challenge");
const factor_1 = require("./entity/factor");
const newFactor_1 = require("./entity/newFactor");
class EntityContextImpl {
constructor(_version, serviceSid, identity) {
this._version = _version;
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(identity)) {
throw new Error("Parameter 'identity' is not valid.");
}
this._solution = { serviceSid, identity };
this._uri = `/Services/${serviceSid}/Entities/${identity}`;
}
get challenges() {
this._challenges =
this._challenges ||
(0, challenge_1.ChallengeListInstance)(this._version, this._solution.serviceSid, this._solution.identity);
return this._challenges;
}
get factors() {
this._factors =
this._factors ||
(0, factor_1.FactorListInstance)(this._version, this._solution.serviceSid, this._solution.identity);
return this._factors;
}
get newFactors() {
this._newFactors =
this._newFactors ||
(0, newFactor_1.NewFactorListInstance)(this._version, this._solution.serviceSid, this._solution.identity);
return this._newFactors;
}
remove(callback) {
const headers = {};
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.remove({
uri: instance._uri,
method: "delete",
headers,
});
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
removeWithHttpInfo(callback) {
const headers = {};
const instance = this;
let operationVersion = instance._version;
// DELETE operation - returns boolean based on status code
let operationPromise = operationVersion
.removeWithResponseInfo({ uri: instance._uri, method: "delete", headers })
.then((response) => ({
...response,
body: response.statusCode === 204,
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
fetch(callback) {
const headers = {};
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.fetch({
uri: instance._uri,
method: "get",
headers,
});
operationPromise = operationPromise.then((payload) => new EntityInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.identity));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
fetchWithHttpInfo(callback) {
const headers = {};
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.fetchWithResponseInfo({
uri: instance._uri,
method: "get",
headers,
})
.then((response) => ({
...response,
body: new EntityInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.identity),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return this._solution;
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.EntityContextImpl = EntityContextImpl;
class EntityInstance {
constructor(_version, payload, serviceSid, identity) {
this._version = _version;
this.sid = payload.sid;
this.identity = payload.identity;
this.accountSid = payload.account_sid;
this.serviceSid = payload.service_sid;
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.url = payload.url;
this.links = payload.links;
this._solution = { serviceSid, identity: identity || this.identity };
}
get _proxy() {
this._context =
this._context ||
new EntityContextImpl(this._version, this._solution.serviceSid, this._solution.identity);
return this._context;
}
/**
* Remove a EntityInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback) {
return this._proxy.remove(callback);
}
/**
* Remove a EntityInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean with HTTP metadata
*/
removeWithHttpInfo(callback) {
return this._proxy.removeWithHttpInfo(callback);
}
/**
* Fetch a EntityInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed EntityInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a EntityInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed EntityInstance with HTTP metadata
*/
fetchWithHttpInfo(callback) {
return this._proxy.fetchWithHttpInfo(callback);
}
/**
* Access the challenges.
*/
challenges() {
return this._proxy.challenges;
}
/**
* Access the factors.
*/
factors() {
return this._proxy.factors;
}
/**
* Access the newFactors.
*/
newFactors() {
return this._proxy.newFactors;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
sid: this.sid,
identity: this.identity,
accountSid: this.accountSid,
serviceSid: this.serviceSid,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
url: this.url,
links: this.links,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.EntityInstance = EntityInstance;
function EntityListInstance(version, serviceSid) {
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
const instance = ((identity) => instance.get(identity));
instance.get = function get(identity) {
return new EntityContextImpl(version, serviceSid, identity);
};
instance._version = version;
instance._solution = { serviceSid };
instance._uri = `/Services/${serviceSid}/Entities`;
instance.create = function create(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["identity"] === null || params["identity"] === undefined) {
throw new Error("Required parameter \"params['identity']\" missing.");
}
let data = {};
data["Identity"] = params["identity"];
const headers = {};
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 EntityInstance(operationVersion, payload, instance._solution.serviceSid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.createWithHttpInfo = function createWithHttpInfo(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["identity"] === null || params["identity"] === undefined) {
throw new Error("Required parameter \"params['identity']\" missing.");
}
let data = {};
data["Identity"] = params["identity"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
let operationVersion = version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.createWithResponseInfo({
uri: instance._uri,
method: "post",
data,
headers,
})
.then((response) => ({
...response,
body: new EntityInstance(operationVersion, response.body, instance._solution.serviceSid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.page = function page(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["pageSize"] !== undefined)
data["PageSize"] = params["pageSize"];
if (params.pageNumber !== undefined)
data["Page"] = params.pageNumber;
if (params.pageToken !== undefined)
data["PageToken"] = params.pageToken;
const headers = {};
headers["Accept"] = "application/json";
let operationVersion = version, operationPromise = operationVersion.page({
uri: instance._uri,
method: "get",
params: data,
headers,
});
operationPromise = operationPromise.then((payload) => new EntityPage(operationVersion, payload, instance._solution));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.each = instance._version.each;
instance.list = instance._version.list;
instance.getPage = function getPage(targetUrl, callback) {
const operationPromise = instance._version._domain.twilio.request({
method: "get",
uri: targetUrl,
});
let pagePromise = operationPromise.then((payload) => new EntityPage(instance._version, payload, instance._solution));
pagePromise = instance._version.setPromiseCallback(pagePromise, callback);
return pagePromise;
};
instance.pageWithHttpInfo = function pageWithHttpInfo(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["pageSize"] !== undefined)
data["PageSize"] = params["pageSize"];
if (params.pageNumber !== undefined)
data["Page"] = params.pageNumber;
if (params.pageToken !== undefined)
data["PageToken"] = params.pageToken;
const headers = {};
headers["Accept"] = "application/json";
let operationVersion = version;
// For page operations, use page() directly as it already returns { statusCode, body, headers }
// IMPORTANT: Pass full response to Page constructor, not response.body
let operationPromise = operationVersion
.page({ uri: instance._uri, method: "get", params: data, headers })
.then((response) => ({
statusCode: response.statusCode,
headers: response.headers,
body: new EntityPage(operationVersion, response, instance._solution),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.each = instance._version.each;
instance.eachWithHttpInfo = instance._version.eachWithHttpInfo;
instance.list = instance._version.list;
instance.listWithHttpInfo = instance._version.listWithHttpInfo;
instance.getPageWithHttpInfo = function getPageWithHttpInfo(targetUrl, callback) {
// Use request() directly as it already returns { statusCode, body, headers }
const operationPromise = instance._version._domain.twilio.request({
method: "get",
uri: targetUrl,
});
let pagePromise = operationPromise.then((response) => ({
statusCode: response.statusCode,
headers: response.headers,
body: new EntityPage(instance._version, response, instance._solution),
}));
pagePromise = instance._version.setPromiseCallback(pagePromise, callback);
return pagePromise;
};
instance.toJSON = function toJSON() {
return instance._solution;
};
instance[util_1.inspect.custom] = function inspectImpl(_depth, options) {
return (0, util_1.inspect)(instance.toJSON(), options);
};
return instance;
}
class EntityPage extends Page_1.default {
/**
* Initialize the EntityPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version, response, solution) {
super(version, response, solution);
}
/**
* Build an instance of EntityInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new EntityInstance(this._version, payload, this._solution.serviceSid);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.EntityPage = EntityPage;

View File

@@ -0,0 +1,506 @@
import { inspect, InspectOptions } from "util";
import Page, { TwilioResponsePayload } from "../../../../../base/Page";
import Response from "../../../../../http/response";
import V2 from "../../../V2";
import { ApiResponse } from "../../../../../base/ApiResponse";
import { NotificationListInstance } from "./challenge/notification";
/**
* Reason for the Challenge to be in certain `status`. One of `none`, `not_needed` or `not_requested`.
*/
export type ChallengeChallengeReasons = "none" | "not_needed" | "not_requested";
/**
* The Status of this Challenge. One of `pending`, `expired`, `approved` or `denied`.
*/
export type ChallengeChallengeStatuses = "pending" | "expired" | "approved" | "denied";
/**
* The Factor Type of this Challenge. Currently `push` and `totp` are supported.
*/
export type ChallengeFactorTypes = "push" | "totp" | "passkeys";
export type ChallengeListOrders = "asc" | "desc";
/**
* Options to pass to update a ChallengeInstance
*/
export interface ChallengeContextUpdateOptions {
/** The optional payload needed to verify the Challenge. E.g., a TOTP would use the numeric code. For `TOTP` this value must be between 3 and 8 characters long. For `Push` this value can be up to 5456 characters in length */
authPayload?: string;
/** Custom metadata associated with the challenge. This is added by the Device/SDK directly to allow for the inclusion of device information. It must be a stringified JSON with only strings values eg. `{\\\"os\\\": \\\"Android\\\"}`. Can be up to 1024 characters in length. */
metadata?: any;
}
/**
* Options to pass to create a ChallengeInstance
*/
export interface ChallengeListInstanceCreateOptions {
/** The unique SID identifier of the Factor. */
factorSid: string;
/** The date-time when this Challenge expires, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. The default value is five (5) minutes after Challenge creation. The max value is sixty (60) minutes after creation. */
expirationDate?: Date;
/** Shown to the user when the push notification arrives. Required when `factor_type` is `push`. Can be up to 256 characters in length */
"details.message"?: string;
/** A list of objects that describe the Fields included in the Challenge. Each object contains the label and value of the field, the label can be up to 36 characters in length and the value can be up to 128 characters in length. Used when `factor_type` is `push`. There can be up to 20 details fields. */
"details.fields"?: Array<any>;
/** Details provided to give context about the Challenge. Not shown to the end user. It must be a stringified JSON with only strings values eg. `{\\\"ip\\\": \\\"172.168.1.234\\\"}`. Can be up to 1024 characters in length */
hiddenDetails?: any;
/** Optional payload used to verify the Challenge upon creation. Only used with a Factor of type `totp` to carry the TOTP code that needs to be verified. For `TOTP` this value must be between 3 and 8 characters long. */
authPayload?: string;
}
/**
* Options to pass to each
*/
export interface ChallengeListInstanceEachOptions {
/** The unique SID identifier of the Factor. */
factorSid?: string;
/** The Status of the Challenges to fetch. One of `pending`, `expired`, `approved` or `denied`. */
status?: ChallengeChallengeStatuses;
/** The desired sort order of the Challenges list. One of `asc` or `desc` for ascending and descending respectively. Defaults to `asc`. */
order?: ChallengeListOrders;
/** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
pageSize?: number;
/** Function to process each record. If this and a positional callback are passed, this one will be used */
callback?: (item: ChallengeInstance, done: (err?: Error) => void) => void;
/** Function to be called upon completion of streaming */
done?: Function;
/** Upper limit for the number of records to return. each() guarantees never to return more than limit. Default is no limit */
limit?: number;
}
/**
* Options to pass to list
*/
export interface ChallengeListInstanceOptions {
/** The unique SID identifier of the Factor. */
factorSid?: string;
/** The Status of the Challenges to fetch. One of `pending`, `expired`, `approved` or `denied`. */
status?: ChallengeChallengeStatuses;
/** The desired sort order of the Challenges list. One of `asc` or `desc` for ascending and descending respectively. Defaults to `asc`. */
order?: ChallengeListOrders;
/** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
pageSize?: number;
/** Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit */
limit?: number;
}
/**
* Options to pass to page
*/
export interface ChallengeListInstancePageOptions {
/** The unique SID identifier of the Factor. */
factorSid?: string;
/** The Status of the Challenges to fetch. One of `pending`, `expired`, `approved` or `denied`. */
status?: ChallengeChallengeStatuses;
/** The desired sort order of the Challenges list. One of `asc` or `desc` for ascending and descending respectively. Defaults to `asc`. */
order?: ChallengeListOrders;
/** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
pageSize?: number;
/** Page Number, this value is simply for client state */
pageNumber?: number;
/** PageToken provided by the API */
pageToken?: string;
}
export interface ChallengeContext {
notifications: NotificationListInstance;
/**
* Fetch a ChallengeInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChallengeInstance
*/
fetch(callback?: (error: Error | null, item?: ChallengeInstance) => any): Promise<ChallengeInstance>;
/**
* Fetch a ChallengeInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChallengeInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<ChallengeInstance>) => any): Promise<ApiResponse<ChallengeInstance>>;
/**
* Update a ChallengeInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChallengeInstance
*/
update(callback?: (error: Error | null, item?: ChallengeInstance) => any): Promise<ChallengeInstance>;
/**
* Update a ChallengeInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChallengeInstance
*/
update(params: ChallengeContextUpdateOptions, callback?: (error: Error | null, item?: ChallengeInstance) => any): Promise<ChallengeInstance>;
/**
* Update a ChallengeInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChallengeInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<ChallengeInstance>) => any): Promise<ApiResponse<ChallengeInstance>>;
/**
* Update a ChallengeInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChallengeInstance with HTTP metadata
*/
updateWithHttpInfo(params: ChallengeContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<ChallengeInstance>) => any): Promise<ApiResponse<ChallengeInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface ChallengeContextSolution {
serviceSid: string;
identity: string;
sid: string;
}
export declare class ChallengeContextImpl implements ChallengeContext {
protected _version: V2;
protected _solution: ChallengeContextSolution;
protected _uri: string;
protected _notifications?: NotificationListInstance;
constructor(_version: V2, serviceSid: string, identity: string, sid: string);
get notifications(): NotificationListInstance;
fetch(callback?: (error: Error | null, item?: ChallengeInstance) => any): Promise<ChallengeInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<ChallengeInstance>) => any): Promise<ApiResponse<ChallengeInstance>>;
update(params?: ChallengeContextUpdateOptions | ((error: Error | null, item?: ChallengeInstance) => any), callback?: (error: Error | null, item?: ChallengeInstance) => any): Promise<ChallengeInstance>;
updateWithHttpInfo(params?: ChallengeContextUpdateOptions | ((error: Error | null, item?: ApiResponse<ChallengeInstance>) => any), callback?: (error: Error | null, item?: ApiResponse<ChallengeInstance>) => any): Promise<ApiResponse<ChallengeInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): ChallengeContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface ChallengePayload extends TwilioResponsePayload {
challenges: ChallengeResource[];
}
interface ChallengeResource {
sid: string;
account_sid: string;
service_sid: string;
entity_sid: string;
identity: string;
factor_sid: string;
date_created: Date;
date_updated: Date;
date_responded: Date;
expiration_date: Date;
status: ChallengeChallengeStatuses;
responded_reason: ChallengeChallengeReasons;
details: any;
hidden_details: any;
metadata: any;
factor_type: ChallengeFactorTypes;
url: string;
links: Record<string, string>;
}
export declare class ChallengeInstance {
protected _version: V2;
protected _solution: ChallengeContextSolution;
protected _context?: ChallengeContext;
constructor(_version: V2, payload: ChallengeResource, serviceSid: string, identity: string, sid?: string);
/**
* A 34 character string that uniquely identifies this Challenge.
*/
sid: string;
/**
* The unique SID identifier of the Account.
*/
accountSid: string;
/**
* The unique SID identifier of the Service.
*/
serviceSid: string;
/**
* The unique SID identifier of the Entity.
*/
entitySid: string;
/**
* Customer unique identity for the Entity owner of the Challenge. This identifier should be immutable, not PII, length between 8 and 64 characters, and generated by your external system, such as your user\'s UUID, GUID, or SID. It can only contain dash (-) separated alphanumeric characters.
*/
identity: string;
/**
* The unique SID identifier of the Factor.
*/
factorSid: string;
/**
* The date that this Challenge was created, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateCreated: Date;
/**
* The date that this Challenge was updated, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateUpdated: Date;
/**
* The date that this Challenge was responded, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateResponded: Date;
/**
* The date-time when this Challenge expires, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. The default value is five (5) minutes after Challenge creation. The max value is sixty (60) minutes after creation.
*/
expirationDate: Date;
status: ChallengeChallengeStatuses;
respondedReason: ChallengeChallengeReasons;
/**
* Details provided to give context about the Challenge. Intended to be shown to the end user.
*/
details: any;
/**
* Details provided to give context about the Challenge. Intended to be hidden from the end user. It must be a stringified JSON with only strings values eg. `{\"ip\": \"172.168.1.234\"}`
*/
hiddenDetails: any;
/**
* Custom metadata associated with the challenge. This is added by the Device/SDK directly to allow for the inclusion of device information. It must be a stringified JSON with only strings values eg. `{\"os\": \"Android\"}`. Can be up to 1024 characters in length.
*/
metadata: any;
factorType: ChallengeFactorTypes;
/**
* The URL of this resource.
*/
url: string;
/**
* Contains a dictionary of URL links to nested resources of this Challenge.
*/
links: Record<string, string>;
private get _proxy();
/**
* Fetch a ChallengeInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChallengeInstance
*/
fetch(callback?: (error: Error | null, item?: ChallengeInstance) => any): Promise<ChallengeInstance>;
/**
* Fetch a ChallengeInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChallengeInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<ChallengeInstance>) => any): Promise<ApiResponse<ChallengeInstance>>;
/**
* Update a ChallengeInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChallengeInstance
*/
update(callback?: (error: Error | null, item?: ChallengeInstance) => any): Promise<ChallengeInstance>;
/**
* Update a ChallengeInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChallengeInstance
*/
update(params: ChallengeContextUpdateOptions, callback?: (error: Error | null, item?: ChallengeInstance) => any): Promise<ChallengeInstance>;
/**
* Update a ChallengeInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChallengeInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<ChallengeInstance>) => any): Promise<ApiResponse<ChallengeInstance>>;
/**
* Update a ChallengeInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChallengeInstance with HTTP metadata
*/
updateWithHttpInfo(params: ChallengeContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<ChallengeInstance>) => any): Promise<ApiResponse<ChallengeInstance>>;
/**
* Access the notifications.
*/
notifications(): NotificationListInstance;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
accountSid: string;
serviceSid: string;
entitySid: string;
identity: string;
factorSid: string;
dateCreated: Date;
dateUpdated: Date;
dateResponded: Date;
expirationDate: Date;
status: ChallengeChallengeStatuses;
respondedReason: ChallengeChallengeReasons;
details: any;
hiddenDetails: any;
metadata: any;
factorType: ChallengeFactorTypes;
url: string;
links: Record<string, string>;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface ChallengeSolution {
serviceSid: string;
identity: string;
}
export interface ChallengeListInstance {
_version: V2;
_solution: ChallengeSolution;
_uri: string;
(sid: string): ChallengeContext;
get(sid: string): ChallengeContext;
/**
* Create a ChallengeInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChallengeInstance
*/
create(params: ChallengeListInstanceCreateOptions, callback?: (error: Error | null, item?: ChallengeInstance) => any): Promise<ChallengeInstance>;
/**
* Create a ChallengeInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChallengeInstance with HTTP metadata
*/
createWithHttpInfo(params: ChallengeListInstanceCreateOptions, callback?: (error: Error | null, item?: ApiResponse<ChallengeInstance>) => any): Promise<ApiResponse<ChallengeInstance>>;
/**
* Streams ChallengeInstance records from the API.
*
* This operation lazily loads records as efficiently as possible until the limit
* is reached.
*
* The results are passed into the callback function, so this operation is memory
* efficient.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { ChallengeListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: ChallengeInstance, done: (err?: Error) => void) => void): void;
each(params: ChallengeListInstanceEachOptions, callback?: (item: ChallengeInstance, done: (err?: Error) => void) => void): void;
/**
* Streams ChallengeInstance records from the API with HTTP metadata captured per page.
*
* This operation lazily loads records as efficiently as possible until the limit
* is reached. HTTP metadata (status code, headers) is captured for each page request.
*
* The results are passed into the callback function, so this operation is memory
* efficient.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { ChallengeListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: ChallengeInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: ChallengeListInstanceEachOptions, callback?: (item: ChallengeInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of ChallengeInstance records from the API.
*
* The request is executed immediately.
*
* @param { string } [targetUrl] - API-generated URL for the requested results page
* @param { function } [callback] - Callback to handle list of records
*/
getPage(targetUrl: string, callback?: (error: Error | null, items: ChallengePage) => any): Promise<ChallengePage>;
/**
* Retrieve a single target page of ChallengeInstance records from the API with HTTP metadata.
*
* The request is executed immediately.
*
* @param { string } [targetUrl] - API-generated URL for the requested results page
* @param { function } [callback] - Callback to handle list of records with metadata
*/
getPageWithHttpInfo(targetUrl: string, callback?: (error: Error | null, items: ApiResponse<ChallengePage>) => any): Promise<ApiResponse<ChallengePage>>;
/**
* Lists ChallengeInstance records from the API as a list.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { ChallengeListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: ChallengeInstance[]) => any): Promise<ChallengeInstance[]>;
list(params: ChallengeListInstanceOptions, callback?: (error: Error | null, items: ChallengeInstance[]) => any): Promise<ChallengeInstance[]>;
/**
* Lists ChallengeInstance records from the API as a list with HTTP metadata.
*
* Returns all records along with HTTP metadata from the first page fetched.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { ChallengeListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<ChallengeInstance[]>) => any): Promise<ApiResponse<ChallengeInstance[]>>;
listWithHttpInfo(params: ChallengeListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<ChallengeInstance[]>) => any): Promise<ApiResponse<ChallengeInstance[]>>;
/**
* Retrieve a single page of ChallengeInstance records from the API.
*
* The request is executed immediately.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { ChallengeListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: ChallengePage) => any): Promise<ChallengePage>;
page(params: ChallengeListInstancePageOptions, callback?: (error: Error | null, items: ChallengePage) => any): Promise<ChallengePage>;
/**
* Retrieve a single page of ChallengeInstance records from the API with HTTP metadata.
*
* The request is executed immediately.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { ChallengeListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<ChallengePage>) => any): Promise<ApiResponse<ChallengePage>>;
pageWithHttpInfo(params: ChallengeListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<ChallengePage>) => any): Promise<ApiResponse<ChallengePage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function ChallengeListInstance(version: V2, serviceSid: string, identity: string): ChallengeListInstance;
export declare class ChallengePage extends Page<V2, ChallengePayload, ChallengeResource, ChallengeInstance> {
/**
* Initialize the ChallengePage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V2, response: Response<string>, solution: ChallengeSolution);
/**
* Build an instance of ChallengeInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: ChallengeResource): ChallengeInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

View File

@@ -0,0 +1,459 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Verify
* 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.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChallengePage = exports.ChallengeInstance = exports.ChallengeContextImpl = void 0;
exports.ChallengeListInstance = ChallengeListInstance;
const util_1 = require("util");
const Page_1 = __importDefault(require("../../../../../base/Page"));
const deserialize = require("../../../../../base/deserialize");
const serialize = require("../../../../../base/serialize");
const utility_1 = require("../../../../../base/utility");
const notification_1 = require("./challenge/notification");
class ChallengeContextImpl {
constructor(_version, serviceSid, identity, sid) {
this._version = _version;
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(identity)) {
throw new Error("Parameter 'identity' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(sid)) {
throw new Error("Parameter 'sid' is not valid.");
}
this._solution = { serviceSid, identity, sid };
this._uri = `/Services/${serviceSid}/Entities/${identity}/Challenges/${sid}`;
}
get notifications() {
this._notifications =
this._notifications ||
(0, notification_1.NotificationListInstance)(this._version, this._solution.serviceSid, this._solution.identity, this._solution.sid);
return this._notifications;
}
fetch(callback) {
const headers = {};
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.fetch({
uri: instance._uri,
method: "get",
headers,
});
operationPromise = operationPromise.then((payload) => new ChallengeInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.identity, instance._solution.sid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
fetchWithHttpInfo(callback) {
const headers = {};
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.fetchWithResponseInfo({
uri: instance._uri,
method: "get",
headers,
})
.then((response) => ({
...response,
body: new ChallengeInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.identity, instance._solution.sid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
update(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["authPayload"] !== undefined)
data["AuthPayload"] = params["authPayload"];
if (params["metadata"] !== undefined)
data["Metadata"] = serialize.object(params["metadata"]);
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.update({
uri: instance._uri,
method: "post",
data,
headers,
});
operationPromise = operationPromise.then((payload) => new ChallengeInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.identity, instance._solution.sid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
updateWithHttpInfo(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["authPayload"] !== undefined)
data["AuthPayload"] = params["authPayload"];
if (params["metadata"] !== undefined)
data["Metadata"] = serialize.object(params["metadata"]);
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.updateWithResponseInfo({
uri: instance._uri,
method: "post",
data,
headers,
})
.then((response) => ({
...response,
body: new ChallengeInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.identity, instance._solution.sid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return this._solution;
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.ChallengeContextImpl = ChallengeContextImpl;
class ChallengeInstance {
constructor(_version, payload, serviceSid, identity, sid) {
this._version = _version;
this.sid = payload.sid;
this.accountSid = payload.account_sid;
this.serviceSid = payload.service_sid;
this.entitySid = payload.entity_sid;
this.identity = payload.identity;
this.factorSid = payload.factor_sid;
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.dateResponded = deserialize.iso8601DateTime(payload.date_responded);
this.expirationDate = deserialize.iso8601DateTime(payload.expiration_date);
this.status = payload.status;
this.respondedReason = payload.responded_reason;
this.details = payload.details;
this.hiddenDetails = payload.hidden_details;
this.metadata = payload.metadata;
this.factorType = payload.factor_type;
this.url = payload.url;
this.links = payload.links;
this._solution = { serviceSid, identity, sid: sid || this.sid };
}
get _proxy() {
this._context =
this._context ||
new ChallengeContextImpl(this._version, this._solution.serviceSid, this._solution.identity, this._solution.sid);
return this._context;
}
/**
* Fetch a ChallengeInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChallengeInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a ChallengeInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed ChallengeInstance with HTTP metadata
*/
fetchWithHttpInfo(callback) {
return this._proxy.fetchWithHttpInfo(callback);
}
update(params, callback) {
return this._proxy.update(params, callback);
}
updateWithHttpInfo(params, callback) {
return this._proxy.updateWithHttpInfo(params, callback);
}
/**
* Access the notifications.
*/
notifications() {
return this._proxy.notifications;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
sid: this.sid,
accountSid: this.accountSid,
serviceSid: this.serviceSid,
entitySid: this.entitySid,
identity: this.identity,
factorSid: this.factorSid,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
dateResponded: this.dateResponded,
expirationDate: this.expirationDate,
status: this.status,
respondedReason: this.respondedReason,
details: this.details,
hiddenDetails: this.hiddenDetails,
metadata: this.metadata,
factorType: this.factorType,
url: this.url,
links: this.links,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.ChallengeInstance = ChallengeInstance;
function ChallengeListInstance(version, serviceSid, identity) {
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(identity)) {
throw new Error("Parameter 'identity' is not valid.");
}
const instance = ((sid) => instance.get(sid));
instance.get = function get(sid) {
return new ChallengeContextImpl(version, serviceSid, identity, sid);
};
instance._version = version;
instance._solution = { serviceSid, identity };
instance._uri = `/Services/${serviceSid}/Entities/${identity}/Challenges`;
instance.create = function create(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["factorSid"] === null || params["factorSid"] === undefined) {
throw new Error("Required parameter \"params['factorSid']\" missing.");
}
let data = {};
data["FactorSid"] = params["factorSid"];
if (params["expirationDate"] !== undefined)
data["ExpirationDate"] = serialize.iso8601DateTime(params["expirationDate"]);
if (params["details.message"] !== undefined)
data["Details.Message"] = params["details.message"];
if (params["details.fields"] !== undefined)
data["Details.Fields"] = serialize.map(params["details.fields"], (e) => serialize.object(e));
if (params["hiddenDetails"] !== undefined)
data["HiddenDetails"] = serialize.object(params["hiddenDetails"]);
if (params["authPayload"] !== undefined)
data["AuthPayload"] = params["authPayload"];
const headers = {};
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 ChallengeInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.identity));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.createWithHttpInfo = function createWithHttpInfo(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["factorSid"] === null || params["factorSid"] === undefined) {
throw new Error("Required parameter \"params['factorSid']\" missing.");
}
let data = {};
data["FactorSid"] = params["factorSid"];
if (params["expirationDate"] !== undefined)
data["ExpirationDate"] = serialize.iso8601DateTime(params["expirationDate"]);
if (params["details.message"] !== undefined)
data["Details.Message"] = params["details.message"];
if (params["details.fields"] !== undefined)
data["Details.Fields"] = serialize.map(params["details.fields"], (e) => serialize.object(e));
if (params["hiddenDetails"] !== undefined)
data["HiddenDetails"] = serialize.object(params["hiddenDetails"]);
if (params["authPayload"] !== undefined)
data["AuthPayload"] = params["authPayload"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
let operationVersion = version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.createWithResponseInfo({
uri: instance._uri,
method: "post",
data,
headers,
})
.then((response) => ({
...response,
body: new ChallengeInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.identity),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.page = function page(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["factorSid"] !== undefined)
data["FactorSid"] = params["factorSid"];
if (params["status"] !== undefined)
data["Status"] = params["status"];
if (params["order"] !== undefined)
data["Order"] = params["order"];
if (params["pageSize"] !== undefined)
data["PageSize"] = params["pageSize"];
if (params.pageNumber !== undefined)
data["Page"] = params.pageNumber;
if (params.pageToken !== undefined)
data["PageToken"] = params.pageToken;
const headers = {};
headers["Accept"] = "application/json";
let operationVersion = version, operationPromise = operationVersion.page({
uri: instance._uri,
method: "get",
params: data,
headers,
});
operationPromise = operationPromise.then((payload) => new ChallengePage(operationVersion, payload, instance._solution));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.each = instance._version.each;
instance.list = instance._version.list;
instance.getPage = function getPage(targetUrl, callback) {
const operationPromise = instance._version._domain.twilio.request({
method: "get",
uri: targetUrl,
});
let pagePromise = operationPromise.then((payload) => new ChallengePage(instance._version, payload, instance._solution));
pagePromise = instance._version.setPromiseCallback(pagePromise, callback);
return pagePromise;
};
instance.pageWithHttpInfo = function pageWithHttpInfo(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["factorSid"] !== undefined)
data["FactorSid"] = params["factorSid"];
if (params["status"] !== undefined)
data["Status"] = params["status"];
if (params["order"] !== undefined)
data["Order"] = params["order"];
if (params["pageSize"] !== undefined)
data["PageSize"] = params["pageSize"];
if (params.pageNumber !== undefined)
data["Page"] = params.pageNumber;
if (params.pageToken !== undefined)
data["PageToken"] = params.pageToken;
const headers = {};
headers["Accept"] = "application/json";
let operationVersion = version;
// For page operations, use page() directly as it already returns { statusCode, body, headers }
// IMPORTANT: Pass full response to Page constructor, not response.body
let operationPromise = operationVersion
.page({ uri: instance._uri, method: "get", params: data, headers })
.then((response) => ({
statusCode: response.statusCode,
headers: response.headers,
body: new ChallengePage(operationVersion, response, instance._solution),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.each = instance._version.each;
instance.eachWithHttpInfo = instance._version.eachWithHttpInfo;
instance.list = instance._version.list;
instance.listWithHttpInfo = instance._version.listWithHttpInfo;
instance.getPageWithHttpInfo = function getPageWithHttpInfo(targetUrl, callback) {
// Use request() directly as it already returns { statusCode, body, headers }
const operationPromise = instance._version._domain.twilio.request({
method: "get",
uri: targetUrl,
});
let pagePromise = operationPromise.then((response) => ({
statusCode: response.statusCode,
headers: response.headers,
body: new ChallengePage(instance._version, response, instance._solution),
}));
pagePromise = instance._version.setPromiseCallback(pagePromise, callback);
return pagePromise;
};
instance.toJSON = function toJSON() {
return instance._solution;
};
instance[util_1.inspect.custom] = function inspectImpl(_depth, options) {
return (0, util_1.inspect)(instance.toJSON(), options);
};
return instance;
}
class ChallengePage extends Page_1.default {
/**
* Initialize the ChallengePage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version, response, solution) {
super(version, response, solution);
}
/**
* Build an instance of ChallengeInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new ChallengeInstance(this._version, payload, this._solution.serviceSid, this._solution.identity);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.ChallengePage = ChallengePage;

View File

@@ -0,0 +1,129 @@
import { inspect, InspectOptions } from "util";
import V2 from "../../../../V2";
import { ApiResponse } from "../../../../../../base/ApiResponse";
/**
* Options to pass to create a NotificationInstance
*/
export interface NotificationListInstanceCreateOptions {
/** How long, in seconds, the notification is valid. Can be an integer between 0 and 300. Default is 300. Delivery is attempted until the TTL elapses, even if the device is offline. 0 means that the notification delivery is attempted immediately, only once, and is not stored for future delivery. */
ttl?: number;
}
export interface NotificationSolution {
serviceSid: string;
identity: string;
challengeSid: string;
}
export interface NotificationListInstance {
_version: V2;
_solution: NotificationSolution;
_uri: string;
/**
* Create a NotificationInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed NotificationInstance
*/
create(callback?: (error: Error | null, item?: NotificationInstance) => any): Promise<NotificationInstance>;
/**
* Create a NotificationInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed NotificationInstance
*/
create(params: NotificationListInstanceCreateOptions, callback?: (error: Error | null, item?: NotificationInstance) => any): Promise<NotificationInstance>;
/**
* Create a NotificationInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed NotificationInstance with HTTP metadata
*/
createWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<NotificationInstance>) => any): Promise<ApiResponse<NotificationInstance>>;
/**
* Create a NotificationInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed NotificationInstance with HTTP metadata
*/
createWithHttpInfo(params: NotificationListInstanceCreateOptions, callback?: (error: Error | null, item?: ApiResponse<NotificationInstance>) => any): Promise<ApiResponse<NotificationInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function NotificationListInstance(version: V2, serviceSid: string, identity: string, challengeSid: string): NotificationListInstance;
interface NotificationResource {
sid: string;
account_sid: string;
service_sid: string;
entity_sid: string;
identity: string;
challenge_sid: string;
priority: string;
ttl: number;
date_created: Date;
}
export declare class NotificationInstance {
protected _version: V2;
constructor(_version: V2, payload: NotificationResource, serviceSid: string, identity: string, challengeSid: string);
/**
* A 34 character string that uniquely identifies this Notification.
*/
sid: string;
/**
* The unique SID identifier of the Account.
*/
accountSid: string;
/**
* The unique SID identifier of the Service.
*/
serviceSid: string;
/**
* The unique SID identifier of the Entity.
*/
entitySid: string;
/**
* Customer unique identity for the Entity owner of the Challenge. This identifier should be immutable, not PII, length between 8 and 64 characters, and generated by your external system, such as your user\'s UUID, GUID, or SID. It can only contain dash (-) separated alphanumeric characters.
*/
identity: string;
/**
* The unique SID identifier of the Challenge.
*/
challengeSid: string;
/**
* The priority of the notification. For `push` Challenges it\'s always `high` which sends the notification immediately, and can wake up a sleeping device.
*/
priority: string;
/**
* How long, in seconds, the notification is valid. Max: 5 minutes
*/
ttl: number;
/**
* The date that this Notification was created, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateCreated: Date;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
accountSid: string;
serviceSid: string;
entitySid: string;
identity: string;
challengeSid: string;
priority: string;
ttl: number;
dateCreated: Date;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export {};

View File

@@ -0,0 +1,133 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Verify
* 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.NotificationInstance = void 0;
exports.NotificationListInstance = NotificationListInstance;
const util_1 = require("util");
const deserialize = require("../../../../../../base/deserialize");
const serialize = require("../../../../../../base/serialize");
const utility_1 = require("../../../../../../base/utility");
function NotificationListInstance(version, serviceSid, identity, challengeSid) {
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(identity)) {
throw new Error("Parameter 'identity' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(challengeSid)) {
throw new Error("Parameter 'challengeSid' is not valid.");
}
const instance = {};
instance._version = version;
instance._solution = { serviceSid, identity, challengeSid };
instance._uri = `/Services/${serviceSid}/Entities/${identity}/Challenges/${challengeSid}/Notifications`;
instance.create = function create(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["ttl"] !== undefined)
data["Ttl"] = params["ttl"];
const headers = {};
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 NotificationInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.identity, instance._solution.challengeSid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.createWithHttpInfo = function createWithHttpInfo(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["ttl"] !== undefined)
data["Ttl"] = params["ttl"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
let operationVersion = version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.createWithResponseInfo({
uri: instance._uri,
method: "post",
data,
headers,
})
.then((response) => ({
...response,
body: new NotificationInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.identity, instance._solution.challengeSid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.toJSON = function toJSON() {
return instance._solution;
};
instance[util_1.inspect.custom] = function inspectImpl(_depth, options) {
return (0, util_1.inspect)(instance.toJSON(), options);
};
return instance;
}
class NotificationInstance {
constructor(_version, payload, serviceSid, identity, challengeSid) {
this._version = _version;
this.sid = payload.sid;
this.accountSid = payload.account_sid;
this.serviceSid = payload.service_sid;
this.entitySid = payload.entity_sid;
this.identity = payload.identity;
this.challengeSid = payload.challenge_sid;
this.priority = payload.priority;
this.ttl = deserialize.integer(payload.ttl);
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
sid: this.sid,
accountSid: this.accountSid,
serviceSid: this.serviceSid,
entitySid: this.entitySid,
identity: this.identity,
challengeSid: this.challengeSid,
priority: this.priority,
ttl: this.ttl,
dateCreated: this.dateCreated,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.NotificationInstance = NotificationInstance;

View File

@@ -0,0 +1,462 @@
import { inspect, InspectOptions } from "util";
import Page, { TwilioResponsePayload } from "../../../../../base/Page";
import Response from "../../../../../http/response";
import V2 from "../../../V2";
import { ApiResponse } from "../../../../../base/ApiResponse";
/**
* The Status of this Factor. One of `unverified` or `verified`.
*/
export type FactorFactorStatuses = "unverified" | "verified";
/**
* The Type of this Factor. Currently `push` and `totp` are supported.
*/
export type FactorFactorTypes = "push" | "totp" | "passkeys";
export type FactorTotpAlgorithms = "sha1" | "sha256" | "sha512";
/**
* Options to pass to update a FactorInstance
*/
export interface FactorContextUpdateOptions {
/** The optional payload needed to verify the Factor for the first time. E.g. for a TOTP, the numeric code. */
authPayload?: string;
/** The new friendly name of this Factor. It can be up to 64 characters. */
friendlyName?: string;
/** For APN, the device token. For FCM, the registration token. It is used to send the push notifications. Required when `factor_type` is `push`. If specified, this value must be between 32 and 255 characters long. */
"config.notificationToken"?: string;
/** The Verify Push SDK version used to configure the factor */
"config.sdkVersion"?: string;
/** Defines how often, in seconds, are TOTP codes generated. i.e, a new TOTP code is generated every time_step seconds. Must be between 20 and 60 seconds, inclusive */
"config.timeStep"?: number;
/** The number of time-steps, past and future, that are valid for validation of TOTP codes. Must be between 0 and 2, inclusive */
"config.skew"?: number;
/** Number of digits for generated TOTP codes. Must be between 3 and 8, inclusive */
"config.codeLength"?: number;
/** */
"config.alg"?: FactorTotpAlgorithms;
/** The transport technology used to generate the Notification Token. Can be `apn`, `fcm` or `none`. Required when `factor_type` is `push`. */
"config.notificationPlatform"?: string;
}
/**
* Options to pass to each
*/
export interface FactorListInstanceEachOptions {
/** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
pageSize?: number;
/** Function to process each record. If this and a positional callback are passed, this one will be used */
callback?: (item: FactorInstance, done: (err?: Error) => void) => void;
/** Function to be called upon completion of streaming */
done?: Function;
/** Upper limit for the number of records to return. each() guarantees never to return more than limit. Default is no limit */
limit?: number;
}
/**
* Options to pass to list
*/
export interface FactorListInstanceOptions {
/** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
pageSize?: number;
/** Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit */
limit?: number;
}
/**
* Options to pass to page
*/
export interface FactorListInstancePageOptions {
/** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
pageSize?: number;
/** Page Number, this value is simply for client state */
pageNumber?: number;
/** PageToken provided by the API */
pageToken?: string;
}
export interface FactorContext {
/**
* Remove a FactorInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a FactorInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean with HTTP metadata
*/
removeWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
/**
* Fetch a FactorInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed FactorInstance
*/
fetch(callback?: (error: Error | null, item?: FactorInstance) => any): Promise<FactorInstance>;
/**
* Fetch a FactorInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed FactorInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<FactorInstance>) => any): Promise<ApiResponse<FactorInstance>>;
/**
* Update a FactorInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed FactorInstance
*/
update(callback?: (error: Error | null, item?: FactorInstance) => any): Promise<FactorInstance>;
/**
* Update a FactorInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed FactorInstance
*/
update(params: FactorContextUpdateOptions, callback?: (error: Error | null, item?: FactorInstance) => any): Promise<FactorInstance>;
/**
* Update a FactorInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed FactorInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<FactorInstance>) => any): Promise<ApiResponse<FactorInstance>>;
/**
* Update a FactorInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed FactorInstance with HTTP metadata
*/
updateWithHttpInfo(params: FactorContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<FactorInstance>) => any): Promise<ApiResponse<FactorInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface FactorContextSolution {
serviceSid: string;
identity: string;
sid: string;
}
export declare class FactorContextImpl implements FactorContext {
protected _version: V2;
protected _solution: FactorContextSolution;
protected _uri: string;
constructor(_version: V2, serviceSid: string, identity: string, sid: string);
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
removeWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
fetch(callback?: (error: Error | null, item?: FactorInstance) => any): Promise<FactorInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<FactorInstance>) => any): Promise<ApiResponse<FactorInstance>>;
update(params?: FactorContextUpdateOptions | ((error: Error | null, item?: FactorInstance) => any), callback?: (error: Error | null, item?: FactorInstance) => any): Promise<FactorInstance>;
updateWithHttpInfo(params?: FactorContextUpdateOptions | ((error: Error | null, item?: ApiResponse<FactorInstance>) => any), callback?: (error: Error | null, item?: ApiResponse<FactorInstance>) => any): Promise<ApiResponse<FactorInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): FactorContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface FactorPayload extends TwilioResponsePayload {
factors: FactorResource[];
}
interface FactorResource {
sid: string;
account_sid: string;
service_sid: string;
entity_sid: string;
identity: string;
date_created: Date;
date_updated: Date;
friendly_name: string;
status: FactorFactorStatuses;
factor_type: FactorFactorTypes;
config: any;
metadata: any;
url: string;
}
export declare class FactorInstance {
protected _version: V2;
protected _solution: FactorContextSolution;
protected _context?: FactorContext;
constructor(_version: V2, payload: FactorResource, serviceSid: string, identity: string, sid?: string);
/**
* A 34 character string that uniquely identifies this Factor.
*/
sid: string;
/**
* The unique SID identifier of the Account.
*/
accountSid: string;
/**
* The unique SID identifier of the Service.
*/
serviceSid: string;
/**
* The unique SID identifier of the Entity.
*/
entitySid: string;
/**
* Customer unique identity for the Entity owner of the Factor. This identifier should be immutable, not PII, length between 8 and 64 characters, and generated by your external system, such as your user\'s UUID, GUID, or SID. It can only contain dash (-) separated alphanumeric characters.
*/
identity: string;
/**
* The date that this Factor was created, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateCreated: Date;
/**
* The date that this Factor was updated, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateUpdated: Date;
/**
* A human readable description of this resource, up to 64 characters. For a push factor, this can be the device\'s name.
*/
friendlyName: string;
status: FactorFactorStatuses;
factorType: FactorFactorTypes;
/**
* An object that contains configurations specific to a `factor_type`.
*/
config: any;
/**
* Custom metadata associated with the factor. This is added by the Device/SDK directly to allow for the inclusion of device information. It must be a stringified JSON with only strings values eg. `{\"os\": \"Android\"}`. Can be up to 1024 characters in length.
*/
metadata: any;
/**
* The URL of this resource.
*/
url: string;
private get _proxy();
/**
* Remove a FactorInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a FactorInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean with HTTP metadata
*/
removeWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
/**
* Fetch a FactorInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed FactorInstance
*/
fetch(callback?: (error: Error | null, item?: FactorInstance) => any): Promise<FactorInstance>;
/**
* Fetch a FactorInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed FactorInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<FactorInstance>) => any): Promise<ApiResponse<FactorInstance>>;
/**
* Update a FactorInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed FactorInstance
*/
update(callback?: (error: Error | null, item?: FactorInstance) => any): Promise<FactorInstance>;
/**
* Update a FactorInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed FactorInstance
*/
update(params: FactorContextUpdateOptions, callback?: (error: Error | null, item?: FactorInstance) => any): Promise<FactorInstance>;
/**
* Update a FactorInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed FactorInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<FactorInstance>) => any): Promise<ApiResponse<FactorInstance>>;
/**
* Update a FactorInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed FactorInstance with HTTP metadata
*/
updateWithHttpInfo(params: FactorContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<FactorInstance>) => any): Promise<ApiResponse<FactorInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
accountSid: string;
serviceSid: string;
entitySid: string;
identity: string;
dateCreated: Date;
dateUpdated: Date;
friendlyName: string;
status: FactorFactorStatuses;
factorType: FactorFactorTypes;
config: any;
metadata: any;
url: string;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface FactorSolution {
serviceSid: string;
identity: string;
}
export interface FactorListInstance {
_version: V2;
_solution: FactorSolution;
_uri: string;
(sid: string): FactorContext;
get(sid: string): FactorContext;
/**
* Streams FactorInstance records from the API.
*
* This operation lazily loads records as efficiently as possible until the limit
* is reached.
*
* The results are passed into the callback function, so this operation is memory
* efficient.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { FactorListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: FactorInstance, done: (err?: Error) => void) => void): void;
each(params: FactorListInstanceEachOptions, callback?: (item: FactorInstance, done: (err?: Error) => void) => void): void;
/**
* Streams FactorInstance records from the API with HTTP metadata captured per page.
*
* This operation lazily loads records as efficiently as possible until the limit
* is reached. HTTP metadata (status code, headers) is captured for each page request.
*
* The results are passed into the callback function, so this operation is memory
* efficient.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { FactorListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: FactorInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: FactorListInstanceEachOptions, callback?: (item: FactorInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of FactorInstance records from the API.
*
* The request is executed immediately.
*
* @param { string } [targetUrl] - API-generated URL for the requested results page
* @param { function } [callback] - Callback to handle list of records
*/
getPage(targetUrl: string, callback?: (error: Error | null, items: FactorPage) => any): Promise<FactorPage>;
/**
* Retrieve a single target page of FactorInstance records from the API with HTTP metadata.
*
* The request is executed immediately.
*
* @param { string } [targetUrl] - API-generated URL for the requested results page
* @param { function } [callback] - Callback to handle list of records with metadata
*/
getPageWithHttpInfo(targetUrl: string, callback?: (error: Error | null, items: ApiResponse<FactorPage>) => any): Promise<ApiResponse<FactorPage>>;
/**
* Lists FactorInstance records from the API as a list.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { FactorListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: FactorInstance[]) => any): Promise<FactorInstance[]>;
list(params: FactorListInstanceOptions, callback?: (error: Error | null, items: FactorInstance[]) => any): Promise<FactorInstance[]>;
/**
* Lists FactorInstance records from the API as a list with HTTP metadata.
*
* Returns all records along with HTTP metadata from the first page fetched.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { FactorListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<FactorInstance[]>) => any): Promise<ApiResponse<FactorInstance[]>>;
listWithHttpInfo(params: FactorListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<FactorInstance[]>) => any): Promise<ApiResponse<FactorInstance[]>>;
/**
* Retrieve a single page of FactorInstance records from the API.
*
* The request is executed immediately.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { FactorListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: FactorPage) => any): Promise<FactorPage>;
page(params: FactorListInstancePageOptions, callback?: (error: Error | null, items: FactorPage) => any): Promise<FactorPage>;
/**
* Retrieve a single page of FactorInstance records from the API with HTTP metadata.
*
* The request is executed immediately.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { FactorListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<FactorPage>) => any): Promise<ApiResponse<FactorPage>>;
pageWithHttpInfo(params: FactorListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<FactorPage>) => any): Promise<ApiResponse<FactorPage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function FactorListInstance(version: V2, serviceSid: string, identity: string): FactorListInstance;
export declare class FactorPage extends Page<V2, FactorPayload, FactorResource, FactorInstance> {
/**
* Initialize the FactorPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V2, response: Response<string>, solution: FactorSolution);
/**
* Build an instance of FactorInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: FactorResource): FactorInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

View File

@@ -0,0 +1,429 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Verify
* 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.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FactorPage = exports.FactorInstance = exports.FactorContextImpl = void 0;
exports.FactorListInstance = FactorListInstance;
const util_1 = require("util");
const Page_1 = __importDefault(require("../../../../../base/Page"));
const deserialize = require("../../../../../base/deserialize");
const serialize = require("../../../../../base/serialize");
const utility_1 = require("../../../../../base/utility");
class FactorContextImpl {
constructor(_version, serviceSid, identity, sid) {
this._version = _version;
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(identity)) {
throw new Error("Parameter 'identity' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(sid)) {
throw new Error("Parameter 'sid' is not valid.");
}
this._solution = { serviceSid, identity, sid };
this._uri = `/Services/${serviceSid}/Entities/${identity}/Factors/${sid}`;
}
remove(callback) {
const headers = {};
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.remove({
uri: instance._uri,
method: "delete",
headers,
});
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
removeWithHttpInfo(callback) {
const headers = {};
const instance = this;
let operationVersion = instance._version;
// DELETE operation - returns boolean based on status code
let operationPromise = operationVersion
.removeWithResponseInfo({ uri: instance._uri, method: "delete", headers })
.then((response) => ({
...response,
body: response.statusCode === 204,
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
fetch(callback) {
const headers = {};
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.fetch({
uri: instance._uri,
method: "get",
headers,
});
operationPromise = operationPromise.then((payload) => new FactorInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.identity, instance._solution.sid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
fetchWithHttpInfo(callback) {
const headers = {};
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.fetchWithResponseInfo({
uri: instance._uri,
method: "get",
headers,
})
.then((response) => ({
...response,
body: new FactorInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.identity, instance._solution.sid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
update(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["authPayload"] !== undefined)
data["AuthPayload"] = params["authPayload"];
if (params["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
if (params["config.notificationToken"] !== undefined)
data["Config.NotificationToken"] = params["config.notificationToken"];
if (params["config.sdkVersion"] !== undefined)
data["Config.SdkVersion"] = params["config.sdkVersion"];
if (params["config.timeStep"] !== undefined)
data["Config.TimeStep"] = params["config.timeStep"];
if (params["config.skew"] !== undefined)
data["Config.Skew"] = params["config.skew"];
if (params["config.codeLength"] !== undefined)
data["Config.CodeLength"] = params["config.codeLength"];
if (params["config.alg"] !== undefined)
data["Config.Alg"] = params["config.alg"];
if (params["config.notificationPlatform"] !== undefined)
data["Config.NotificationPlatform"] =
params["config.notificationPlatform"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.update({
uri: instance._uri,
method: "post",
data,
headers,
});
operationPromise = operationPromise.then((payload) => new FactorInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.identity, instance._solution.sid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
updateWithHttpInfo(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["authPayload"] !== undefined)
data["AuthPayload"] = params["authPayload"];
if (params["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
if (params["config.notificationToken"] !== undefined)
data["Config.NotificationToken"] = params["config.notificationToken"];
if (params["config.sdkVersion"] !== undefined)
data["Config.SdkVersion"] = params["config.sdkVersion"];
if (params["config.timeStep"] !== undefined)
data["Config.TimeStep"] = params["config.timeStep"];
if (params["config.skew"] !== undefined)
data["Config.Skew"] = params["config.skew"];
if (params["config.codeLength"] !== undefined)
data["Config.CodeLength"] = params["config.codeLength"];
if (params["config.alg"] !== undefined)
data["Config.Alg"] = params["config.alg"];
if (params["config.notificationPlatform"] !== undefined)
data["Config.NotificationPlatform"] =
params["config.notificationPlatform"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.updateWithResponseInfo({
uri: instance._uri,
method: "post",
data,
headers,
})
.then((response) => ({
...response,
body: new FactorInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.identity, instance._solution.sid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return this._solution;
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.FactorContextImpl = FactorContextImpl;
class FactorInstance {
constructor(_version, payload, serviceSid, identity, sid) {
this._version = _version;
this.sid = payload.sid;
this.accountSid = payload.account_sid;
this.serviceSid = payload.service_sid;
this.entitySid = payload.entity_sid;
this.identity = payload.identity;
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.friendlyName = payload.friendly_name;
this.status = payload.status;
this.factorType = payload.factor_type;
this.config = payload.config;
this.metadata = payload.metadata;
this.url = payload.url;
this._solution = { serviceSid, identity, sid: sid || this.sid };
}
get _proxy() {
this._context =
this._context ||
new FactorContextImpl(this._version, this._solution.serviceSid, this._solution.identity, this._solution.sid);
return this._context;
}
/**
* Remove a FactorInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback) {
return this._proxy.remove(callback);
}
/**
* Remove a FactorInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean with HTTP metadata
*/
removeWithHttpInfo(callback) {
return this._proxy.removeWithHttpInfo(callback);
}
/**
* Fetch a FactorInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed FactorInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a FactorInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed FactorInstance with HTTP metadata
*/
fetchWithHttpInfo(callback) {
return this._proxy.fetchWithHttpInfo(callback);
}
update(params, callback) {
return this._proxy.update(params, callback);
}
updateWithHttpInfo(params, callback) {
return this._proxy.updateWithHttpInfo(params, callback);
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
sid: this.sid,
accountSid: this.accountSid,
serviceSid: this.serviceSid,
entitySid: this.entitySid,
identity: this.identity,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
friendlyName: this.friendlyName,
status: this.status,
factorType: this.factorType,
config: this.config,
metadata: this.metadata,
url: this.url,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.FactorInstance = FactorInstance;
function FactorListInstance(version, serviceSid, identity) {
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(identity)) {
throw new Error("Parameter 'identity' is not valid.");
}
const instance = ((sid) => instance.get(sid));
instance.get = function get(sid) {
return new FactorContextImpl(version, serviceSid, identity, sid);
};
instance._version = version;
instance._solution = { serviceSid, identity };
instance._uri = `/Services/${serviceSid}/Entities/${identity}/Factors`;
instance.page = function page(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["pageSize"] !== undefined)
data["PageSize"] = params["pageSize"];
if (params.pageNumber !== undefined)
data["Page"] = params.pageNumber;
if (params.pageToken !== undefined)
data["PageToken"] = params.pageToken;
const headers = {};
headers["Accept"] = "application/json";
let operationVersion = version, operationPromise = operationVersion.page({
uri: instance._uri,
method: "get",
params: data,
headers,
});
operationPromise = operationPromise.then((payload) => new FactorPage(operationVersion, payload, instance._solution));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.each = instance._version.each;
instance.list = instance._version.list;
instance.getPage = function getPage(targetUrl, callback) {
const operationPromise = instance._version._domain.twilio.request({
method: "get",
uri: targetUrl,
});
let pagePromise = operationPromise.then((payload) => new FactorPage(instance._version, payload, instance._solution));
pagePromise = instance._version.setPromiseCallback(pagePromise, callback);
return pagePromise;
};
instance.pageWithHttpInfo = function pageWithHttpInfo(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["pageSize"] !== undefined)
data["PageSize"] = params["pageSize"];
if (params.pageNumber !== undefined)
data["Page"] = params.pageNumber;
if (params.pageToken !== undefined)
data["PageToken"] = params.pageToken;
const headers = {};
headers["Accept"] = "application/json";
let operationVersion = version;
// For page operations, use page() directly as it already returns { statusCode, body, headers }
// IMPORTANT: Pass full response to Page constructor, not response.body
let operationPromise = operationVersion
.page({ uri: instance._uri, method: "get", params: data, headers })
.then((response) => ({
statusCode: response.statusCode,
headers: response.headers,
body: new FactorPage(operationVersion, response, instance._solution),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.each = instance._version.each;
instance.eachWithHttpInfo = instance._version.eachWithHttpInfo;
instance.list = instance._version.list;
instance.listWithHttpInfo = instance._version.listWithHttpInfo;
instance.getPageWithHttpInfo = function getPageWithHttpInfo(targetUrl, callback) {
// Use request() directly as it already returns { statusCode, body, headers }
const operationPromise = instance._version._domain.twilio.request({
method: "get",
uri: targetUrl,
});
let pagePromise = operationPromise.then((response) => ({
statusCode: response.statusCode,
headers: response.headers,
body: new FactorPage(instance._version, response, instance._solution),
}));
pagePromise = instance._version.setPromiseCallback(pagePromise, callback);
return pagePromise;
};
instance.toJSON = function toJSON() {
return instance._solution;
};
instance[util_1.inspect.custom] = function inspectImpl(_depth, options) {
return (0, util_1.inspect)(instance.toJSON(), options);
};
return instance;
}
class FactorPage extends Page_1.default {
/**
* Initialize the FactorPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version, response, solution) {
super(version, response, solution);
}
/**
* Build an instance of FactorInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new FactorInstance(this._version, payload, this._solution.serviceSid, this._solution.identity);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.FactorPage = FactorPage;

View File

@@ -0,0 +1,175 @@
import { inspect, InspectOptions } from "util";
import V2 from "../../../V2";
import { ApiResponse } from "../../../../../base/ApiResponse";
/**
* The Status of this Factor. One of `unverified` or `verified`.
*/
export type NewFactorFactorStatuses = "unverified" | "verified";
/**
* The Type of this Factor. Currently `push` and `totp` are supported.
*/
export type NewFactorFactorTypes = "push" | "totp" | "passkeys";
export type NewFactorNotificationPlatforms = "apn" | "fcm" | "none";
export type NewFactorTotpAlgorithms = "sha1" | "sha256" | "sha512";
/**
* Options to pass to create a NewFactorInstance
*/
export interface NewFactorListInstanceCreateOptions {
/** The friendly name of this Factor. This can be any string up to 64 characters, meant for humans to distinguish between Factors. For `factor_type` `push`, this could be a device name. For `factor_type` `totp`, this value is used as the “account name” in constructing the `binding.uri` property. At the same time, we recommend avoiding providing PII. */
friendlyName: string;
/** */
factorType: NewFactorFactorTypes;
/** The algorithm used when `factor_type` is `push`. Algorithm supported: `ES256` */
"binding.alg"?: string;
/** The Ecdsa public key in PKIX, ASN.1 DER format encoded in Base64. Required when `factor_type` is `push` */
"binding.publicKey"?: string;
/** The ID that uniquely identifies your app in the Google or Apple store, such as `com.example.myapp`. It can be up to 100 characters long. Required when `factor_type` is `push`. */
"config.appId"?: string;
/** */
"config.notificationPlatform"?: NewFactorNotificationPlatforms;
/** For APN, the device token. For FCM, the registration token. It is used to send the push notifications. Must be between 32 and 255 characters long. Required when `factor_type` is `push`. */
"config.notificationToken"?: string;
/** The Verify Push SDK version used to configure the factor Required when `factor_type` is `push` */
"config.sdkVersion"?: string;
/** The shared secret for TOTP factors encoded in Base32. This can be provided when creating the Factor, otherwise it will be generated. Used when `factor_type` is `totp` */
"binding.secret"?: string;
/** Defines how often, in seconds, are TOTP codes generated. i.e, a new TOTP code is generated every time_step seconds. Must be between 20 and 60 seconds, inclusive. The default value is defined at the service level in the property `totp.time_step`. Defaults to 30 seconds if not configured. Used when `factor_type` is `totp` */
"config.timeStep"?: number;
/** The number of time-steps, past and future, that are valid for validation of TOTP codes. Must be between 0 and 2, inclusive. The default value is defined at the service level in the property `totp.skew`. If not configured defaults to 1. Used when `factor_type` is `totp` */
"config.skew"?: number;
/** Number of digits for generated TOTP codes. Must be between 3 and 8, inclusive. The default value is defined at the service level in the property `totp.code_length`. If not configured defaults to 6. Used when `factor_type` is `totp` */
"config.codeLength"?: number;
/** */
"config.alg"?: NewFactorTotpAlgorithms;
/** Custom metadata associated with the factor. This is added by the Device/SDK directly to allow for the inclusion of device information. It must be a stringified JSON with only strings values eg. `{\\\"os\\\": \\\"Android\\\"}`. Can be up to 1024 characters in length. */
metadata?: any;
}
export interface NewFactorSolution {
serviceSid: string;
identity: string;
}
export interface NewFactorListInstance {
_version: V2;
_solution: NewFactorSolution;
_uri: string;
/**
* Create a NewFactorInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed NewFactorInstance
*/
create(params: NewFactorListInstanceCreateOptions, callback?: (error: Error | null, item?: NewFactorInstance) => any): Promise<NewFactorInstance>;
/**
* Create a NewFactorInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed NewFactorInstance with HTTP metadata
*/
createWithHttpInfo(params: NewFactorListInstanceCreateOptions, callback?: (error: Error | null, item?: ApiResponse<NewFactorInstance>) => any): Promise<ApiResponse<NewFactorInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function NewFactorListInstance(version: V2, serviceSid: string, identity: string): NewFactorListInstance;
interface NewFactorResource {
sid: string;
account_sid: string;
service_sid: string;
entity_sid: string;
identity: string;
binding: any;
options: any;
date_created: Date;
date_updated: Date;
friendly_name: string;
status: NewFactorFactorStatuses;
factor_type: NewFactorFactorTypes;
config: any;
metadata: any;
url: string;
}
export declare class NewFactorInstance {
protected _version: V2;
constructor(_version: V2, payload: NewFactorResource, serviceSid: string, identity: string);
/**
* A 34 character string that uniquely identifies this Factor.
*/
sid: string;
/**
* The unique SID identifier of the Account.
*/
accountSid: string;
/**
* The unique SID identifier of the Service.
*/
serviceSid: string;
/**
* The unique SID identifier of the Entity.
*/
entitySid: string;
/**
* Customer unique identity for the Entity owner of the Factor. This identifier should be immutable, not PII, length between 8 and 64 characters, and generated by your external system, such as your user\'s UUID, GUID, or SID. It can only contain dash (-) separated alphanumeric characters.
*/
identity: string;
/**
* Contains the `factor_type` specific secret and metadata. For push, this is `binding.public_key` and `binding.alg`. For totp, this is `binding.secret` and `binding.uri`. The `binding.uri` property is generated following the [google authenticator key URI format](https://github.com/google/google-authenticator/wiki/Key-Uri-Format), and `Factor.friendly_name` is used for the “accountname” value and `Service.friendly_name` or `Service.totp.issuer` is used for the `issuer` value. The Binding property is ONLY returned upon Factor creation.
*/
binding: any;
options: any;
/**
* The date that this Factor was created, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateCreated: Date;
/**
* The date that this Factor was updated, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateUpdated: Date;
/**
* The friendly name of this Factor. This can be any string up to 64 characters, meant for humans to distinguish between Factors. For `factor_type` `push`, this could be a device name. For `factor_type` `totp`, this value is used as the “account name” in constructing the `binding.uri` property. At the same time, we recommend avoiding providing PII.
*/
friendlyName: string;
status: NewFactorFactorStatuses;
factorType: NewFactorFactorTypes;
/**
* An object that contains configurations specific to a `factor_type`.
*/
config: any;
/**
* Custom metadata associated with the factor. This is added by the Device/SDK directly to allow for the inclusion of device information. It must be a stringified JSON with only strings values eg. `{\"os\": \"Android\"}`. Can be up to 1024 characters in length.
*/
metadata: any;
/**
* The URL of this resource.
*/
url: string;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
accountSid: string;
serviceSid: string;
entitySid: string;
identity: string;
binding: any;
options: any;
dateCreated: Date;
dateUpdated: Date;
friendlyName: string;
status: NewFactorFactorStatuses;
factorType: NewFactorFactorTypes;
config: any;
metadata: any;
url: string;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export {};

View File

@@ -0,0 +1,198 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Verify
* 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.NewFactorInstance = void 0;
exports.NewFactorListInstance = NewFactorListInstance;
const util_1 = require("util");
const deserialize = require("../../../../../base/deserialize");
const serialize = require("../../../../../base/serialize");
const utility_1 = require("../../../../../base/utility");
function NewFactorListInstance(version, serviceSid, identity) {
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(identity)) {
throw new Error("Parameter 'identity' is not valid.");
}
const instance = {};
instance._version = version;
instance._solution = { serviceSid, identity };
instance._uri = `/Services/${serviceSid}/Entities/${identity}/Factors`;
instance.create = function create(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["friendlyName"] === null ||
params["friendlyName"] === undefined) {
throw new Error("Required parameter \"params['friendlyName']\" missing.");
}
if (params["factorType"] === null || params["factorType"] === undefined) {
throw new Error("Required parameter \"params['factorType']\" missing.");
}
let data = {};
data["FriendlyName"] = params["friendlyName"];
data["FactorType"] = params["factorType"];
if (params["binding.alg"] !== undefined)
data["Binding.Alg"] = params["binding.alg"];
if (params["binding.publicKey"] !== undefined)
data["Binding.PublicKey"] = params["binding.publicKey"];
if (params["config.appId"] !== undefined)
data["Config.AppId"] = params["config.appId"];
if (params["config.notificationPlatform"] !== undefined)
data["Config.NotificationPlatform"] =
params["config.notificationPlatform"];
if (params["config.notificationToken"] !== undefined)
data["Config.NotificationToken"] = params["config.notificationToken"];
if (params["config.sdkVersion"] !== undefined)
data["Config.SdkVersion"] = params["config.sdkVersion"];
if (params["binding.secret"] !== undefined)
data["Binding.Secret"] = params["binding.secret"];
if (params["config.timeStep"] !== undefined)
data["Config.TimeStep"] = params["config.timeStep"];
if (params["config.skew"] !== undefined)
data["Config.Skew"] = params["config.skew"];
if (params["config.codeLength"] !== undefined)
data["Config.CodeLength"] = params["config.codeLength"];
if (params["config.alg"] !== undefined)
data["Config.Alg"] = params["config.alg"];
if (params["metadata"] !== undefined)
data["Metadata"] = serialize.object(params["metadata"]);
const headers = {};
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 NewFactorInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.identity));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.createWithHttpInfo = function createWithHttpInfo(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["friendlyName"] === null ||
params["friendlyName"] === undefined) {
throw new Error("Required parameter \"params['friendlyName']\" missing.");
}
if (params["factorType"] === null || params["factorType"] === undefined) {
throw new Error("Required parameter \"params['factorType']\" missing.");
}
let data = {};
data["FriendlyName"] = params["friendlyName"];
data["FactorType"] = params["factorType"];
if (params["binding.alg"] !== undefined)
data["Binding.Alg"] = params["binding.alg"];
if (params["binding.publicKey"] !== undefined)
data["Binding.PublicKey"] = params["binding.publicKey"];
if (params["config.appId"] !== undefined)
data["Config.AppId"] = params["config.appId"];
if (params["config.notificationPlatform"] !== undefined)
data["Config.NotificationPlatform"] =
params["config.notificationPlatform"];
if (params["config.notificationToken"] !== undefined)
data["Config.NotificationToken"] = params["config.notificationToken"];
if (params["config.sdkVersion"] !== undefined)
data["Config.SdkVersion"] = params["config.sdkVersion"];
if (params["binding.secret"] !== undefined)
data["Binding.Secret"] = params["binding.secret"];
if (params["config.timeStep"] !== undefined)
data["Config.TimeStep"] = params["config.timeStep"];
if (params["config.skew"] !== undefined)
data["Config.Skew"] = params["config.skew"];
if (params["config.codeLength"] !== undefined)
data["Config.CodeLength"] = params["config.codeLength"];
if (params["config.alg"] !== undefined)
data["Config.Alg"] = params["config.alg"];
if (params["metadata"] !== undefined)
data["Metadata"] = serialize.object(params["metadata"]);
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
let operationVersion = version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.createWithResponseInfo({
uri: instance._uri,
method: "post",
data,
headers,
})
.then((response) => ({
...response,
body: new NewFactorInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.identity),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.toJSON = function toJSON() {
return instance._solution;
};
instance[util_1.inspect.custom] = function inspectImpl(_depth, options) {
return (0, util_1.inspect)(instance.toJSON(), options);
};
return instance;
}
class NewFactorInstance {
constructor(_version, payload, serviceSid, identity) {
this._version = _version;
this.sid = payload.sid;
this.accountSid = payload.account_sid;
this.serviceSid = payload.service_sid;
this.entitySid = payload.entity_sid;
this.identity = payload.identity;
this.binding = payload.binding;
this.options = payload.options;
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.friendlyName = payload.friendly_name;
this.status = payload.status;
this.factorType = payload.factor_type;
this.config = payload.config;
this.metadata = payload.metadata;
this.url = payload.url;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
sid: this.sid,
accountSid: this.accountSid,
serviceSid: this.serviceSid,
entitySid: this.entitySid,
identity: this.identity,
binding: this.binding,
options: this.options,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
friendlyName: this.friendlyName,
status: this.status,
factorType: this.factorType,
config: this.config,
metadata: this.metadata,
url: this.url,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.NewFactorInstance = NewFactorInstance;

View File

@@ -0,0 +1,400 @@
import { inspect, InspectOptions } from "util";
import Page, { TwilioResponsePayload } from "../../../../base/Page";
import Response from "../../../../http/response";
import V2 from "../../V2";
import { ApiResponse } from "../../../../base/ApiResponse";
/**
* Options to pass to update a MessagingConfigurationInstance
*/
export interface MessagingConfigurationContextUpdateOptions {
/** The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) to be used to send SMS to the country of this configuration. */
messagingServiceSid: string;
}
/**
* Options to pass to create a MessagingConfigurationInstance
*/
export interface MessagingConfigurationListInstanceCreateOptions {
/** The [ISO-3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code of the country this configuration will be applied to. If this is a global configuration, Country will take the value `all`. */
country: string;
/** The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) to be used to send SMS to the country of this configuration. */
messagingServiceSid: string;
}
/**
* Options to pass to each
*/
export interface MessagingConfigurationListInstanceEachOptions {
/** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
pageSize?: number;
/** Function to process each record. If this and a positional callback are passed, this one will be used */
callback?: (item: MessagingConfigurationInstance, done: (err?: Error) => void) => void;
/** Function to be called upon completion of streaming */
done?: Function;
/** Upper limit for the number of records to return. each() guarantees never to return more than limit. Default is no limit */
limit?: number;
}
/**
* Options to pass to list
*/
export interface MessagingConfigurationListInstanceOptions {
/** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
pageSize?: number;
/** Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit */
limit?: number;
}
/**
* Options to pass to page
*/
export interface MessagingConfigurationListInstancePageOptions {
/** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
pageSize?: number;
/** Page Number, this value is simply for client state */
pageNumber?: number;
/** PageToken provided by the API */
pageToken?: string;
}
export interface MessagingConfigurationContext {
/**
* Remove a MessagingConfigurationInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a MessagingConfigurationInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean with HTTP metadata
*/
removeWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
/**
* Fetch a MessagingConfigurationInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessagingConfigurationInstance
*/
fetch(callback?: (error: Error | null, item?: MessagingConfigurationInstance) => any): Promise<MessagingConfigurationInstance>;
/**
* Fetch a MessagingConfigurationInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessagingConfigurationInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<MessagingConfigurationInstance>) => any): Promise<ApiResponse<MessagingConfigurationInstance>>;
/**
* Update a MessagingConfigurationInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessagingConfigurationInstance
*/
update(params: MessagingConfigurationContextUpdateOptions, callback?: (error: Error | null, item?: MessagingConfigurationInstance) => any): Promise<MessagingConfigurationInstance>;
/**
* Update a MessagingConfigurationInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessagingConfigurationInstance with HTTP metadata
*/
updateWithHttpInfo(params: MessagingConfigurationContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<MessagingConfigurationInstance>) => any): Promise<ApiResponse<MessagingConfigurationInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface MessagingConfigurationContextSolution {
serviceSid: string;
country: string;
}
export declare class MessagingConfigurationContextImpl implements MessagingConfigurationContext {
protected _version: V2;
protected _solution: MessagingConfigurationContextSolution;
protected _uri: string;
constructor(_version: V2, serviceSid: string, country: string);
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
removeWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
fetch(callback?: (error: Error | null, item?: MessagingConfigurationInstance) => any): Promise<MessagingConfigurationInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<MessagingConfigurationInstance>) => any): Promise<ApiResponse<MessagingConfigurationInstance>>;
update(params: MessagingConfigurationContextUpdateOptions, callback?: (error: Error | null, item?: MessagingConfigurationInstance) => any): Promise<MessagingConfigurationInstance>;
updateWithHttpInfo(params: MessagingConfigurationContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<MessagingConfigurationInstance>) => any): Promise<ApiResponse<MessagingConfigurationInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): MessagingConfigurationContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface MessagingConfigurationPayload extends TwilioResponsePayload {
messaging_configurations: MessagingConfigurationResource[];
}
interface MessagingConfigurationResource {
account_sid: string;
service_sid: string;
country: string;
messaging_service_sid: string;
date_created: Date;
date_updated: Date;
url: string;
}
export declare class MessagingConfigurationInstance {
protected _version: V2;
protected _solution: MessagingConfigurationContextSolution;
protected _context?: MessagingConfigurationContext;
constructor(_version: V2, payload: MessagingConfigurationResource, serviceSid: string, country?: string);
/**
* The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Service resource.
*/
accountSid: string;
/**
* The SID of the [Service](https://www.twilio.com/docs/verify/api/service) that the resource is associated with.
*/
serviceSid: string;
/**
* The [ISO-3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code of the country this configuration will be applied to. If this is a global configuration, Country will take the value `all`.
*/
country: string;
/**
* The SID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) to be used to send SMS to the country of this configuration.
*/
messagingServiceSid: string;
/**
* The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
*/
dateCreated: Date;
/**
* The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
*/
dateUpdated: Date;
/**
* The URL of this resource.
*/
url: string;
private get _proxy();
/**
* Remove a MessagingConfigurationInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a MessagingConfigurationInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean with HTTP metadata
*/
removeWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
/**
* Fetch a MessagingConfigurationInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessagingConfigurationInstance
*/
fetch(callback?: (error: Error | null, item?: MessagingConfigurationInstance) => any): Promise<MessagingConfigurationInstance>;
/**
* Fetch a MessagingConfigurationInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessagingConfigurationInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<MessagingConfigurationInstance>) => any): Promise<ApiResponse<MessagingConfigurationInstance>>;
/**
* Update a MessagingConfigurationInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessagingConfigurationInstance
*/
update(params: MessagingConfigurationContextUpdateOptions, callback?: (error: Error | null, item?: MessagingConfigurationInstance) => any): Promise<MessagingConfigurationInstance>;
/**
* Update a MessagingConfigurationInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessagingConfigurationInstance with HTTP metadata
*/
updateWithHttpInfo(params: MessagingConfigurationContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<MessagingConfigurationInstance>) => any): Promise<ApiResponse<MessagingConfigurationInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
accountSid: string;
serviceSid: string;
country: string;
messagingServiceSid: string;
dateCreated: Date;
dateUpdated: Date;
url: string;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface MessagingConfigurationSolution {
serviceSid: string;
}
export interface MessagingConfigurationListInstance {
_version: V2;
_solution: MessagingConfigurationSolution;
_uri: string;
(country: string): MessagingConfigurationContext;
get(country: string): MessagingConfigurationContext;
/**
* Create a MessagingConfigurationInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessagingConfigurationInstance
*/
create(params: MessagingConfigurationListInstanceCreateOptions, callback?: (error: Error | null, item?: MessagingConfigurationInstance) => any): Promise<MessagingConfigurationInstance>;
/**
* Create a MessagingConfigurationInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessagingConfigurationInstance with HTTP metadata
*/
createWithHttpInfo(params: MessagingConfigurationListInstanceCreateOptions, callback?: (error: Error | null, item?: ApiResponse<MessagingConfigurationInstance>) => any): Promise<ApiResponse<MessagingConfigurationInstance>>;
/**
* Streams MessagingConfigurationInstance records from the API.
*
* This operation lazily loads records as efficiently as possible until the limit
* is reached.
*
* The results are passed into the callback function, so this operation is memory
* efficient.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { MessagingConfigurationListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: MessagingConfigurationInstance, done: (err?: Error) => void) => void): void;
each(params: MessagingConfigurationListInstanceEachOptions, callback?: (item: MessagingConfigurationInstance, done: (err?: Error) => void) => void): void;
/**
* Streams MessagingConfigurationInstance records from the API with HTTP metadata captured per page.
*
* This operation lazily loads records as efficiently as possible until the limit
* is reached. HTTP metadata (status code, headers) is captured for each page request.
*
* The results are passed into the callback function, so this operation is memory
* efficient.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { MessagingConfigurationListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: MessagingConfigurationInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: MessagingConfigurationListInstanceEachOptions, callback?: (item: MessagingConfigurationInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of MessagingConfigurationInstance records from the API.
*
* The request is executed immediately.
*
* @param { string } [targetUrl] - API-generated URL for the requested results page
* @param { function } [callback] - Callback to handle list of records
*/
getPage(targetUrl: string, callback?: (error: Error | null, items: MessagingConfigurationPage) => any): Promise<MessagingConfigurationPage>;
/**
* Retrieve a single target page of MessagingConfigurationInstance records from the API with HTTP metadata.
*
* The request is executed immediately.
*
* @param { string } [targetUrl] - API-generated URL for the requested results page
* @param { function } [callback] - Callback to handle list of records with metadata
*/
getPageWithHttpInfo(targetUrl: string, callback?: (error: Error | null, items: ApiResponse<MessagingConfigurationPage>) => any): Promise<ApiResponse<MessagingConfigurationPage>>;
/**
* Lists MessagingConfigurationInstance records from the API as a list.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { MessagingConfigurationListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: MessagingConfigurationInstance[]) => any): Promise<MessagingConfigurationInstance[]>;
list(params: MessagingConfigurationListInstanceOptions, callback?: (error: Error | null, items: MessagingConfigurationInstance[]) => any): Promise<MessagingConfigurationInstance[]>;
/**
* Lists MessagingConfigurationInstance records from the API as a list with HTTP metadata.
*
* Returns all records along with HTTP metadata from the first page fetched.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { MessagingConfigurationListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<MessagingConfigurationInstance[]>) => any): Promise<ApiResponse<MessagingConfigurationInstance[]>>;
listWithHttpInfo(params: MessagingConfigurationListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<MessagingConfigurationInstance[]>) => any): Promise<ApiResponse<MessagingConfigurationInstance[]>>;
/**
* Retrieve a single page of MessagingConfigurationInstance records from the API.
*
* The request is executed immediately.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { MessagingConfigurationListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: MessagingConfigurationPage) => any): Promise<MessagingConfigurationPage>;
page(params: MessagingConfigurationListInstancePageOptions, callback?: (error: Error | null, items: MessagingConfigurationPage) => any): Promise<MessagingConfigurationPage>;
/**
* Retrieve a single page of MessagingConfigurationInstance records from the API with HTTP metadata.
*
* The request is executed immediately.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { MessagingConfigurationListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<MessagingConfigurationPage>) => any): Promise<ApiResponse<MessagingConfigurationPage>>;
pageWithHttpInfo(params: MessagingConfigurationListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<MessagingConfigurationPage>) => any): Promise<ApiResponse<MessagingConfigurationPage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function MessagingConfigurationListInstance(version: V2, serviceSid: string): MessagingConfigurationListInstance;
export declare class MessagingConfigurationPage extends Page<V2, MessagingConfigurationPayload, MessagingConfigurationResource, MessagingConfigurationInstance> {
/**
* Initialize the MessagingConfigurationPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V2, response: Response<string>, solution: MessagingConfigurationSolution);
/**
* Build an instance of MessagingConfigurationInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: MessagingConfigurationResource): MessagingConfigurationInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

View File

@@ -0,0 +1,435 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Verify
* 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.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MessagingConfigurationPage = exports.MessagingConfigurationInstance = exports.MessagingConfigurationContextImpl = void 0;
exports.MessagingConfigurationListInstance = MessagingConfigurationListInstance;
const util_1 = require("util");
const Page_1 = __importDefault(require("../../../../base/Page"));
const deserialize = require("../../../../base/deserialize");
const serialize = require("../../../../base/serialize");
const utility_1 = require("../../../../base/utility");
class MessagingConfigurationContextImpl {
constructor(_version, serviceSid, country) {
this._version = _version;
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(country)) {
throw new Error("Parameter 'country' is not valid.");
}
this._solution = { serviceSid, country };
this._uri = `/Services/${serviceSid}/MessagingConfigurations/${country}`;
}
remove(callback) {
const headers = {};
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.remove({
uri: instance._uri,
method: "delete",
headers,
});
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
removeWithHttpInfo(callback) {
const headers = {};
const instance = this;
let operationVersion = instance._version;
// DELETE operation - returns boolean based on status code
let operationPromise = operationVersion
.removeWithResponseInfo({ uri: instance._uri, method: "delete", headers })
.then((response) => ({
...response,
body: response.statusCode === 204,
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
fetch(callback) {
const headers = {};
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.fetch({
uri: instance._uri,
method: "get",
headers,
});
operationPromise = operationPromise.then((payload) => new MessagingConfigurationInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.country));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
fetchWithHttpInfo(callback) {
const headers = {};
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.fetchWithResponseInfo({
uri: instance._uri,
method: "get",
headers,
})
.then((response) => ({
...response,
body: new MessagingConfigurationInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.country),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
update(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["messagingServiceSid"] === null ||
params["messagingServiceSid"] === undefined) {
throw new Error("Required parameter \"params['messagingServiceSid']\" missing.");
}
let data = {};
data["MessagingServiceSid"] = params["messagingServiceSid"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.update({
uri: instance._uri,
method: "post",
data,
headers,
});
operationPromise = operationPromise.then((payload) => new MessagingConfigurationInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.country));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
updateWithHttpInfo(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["messagingServiceSid"] === null ||
params["messagingServiceSid"] === undefined) {
throw new Error("Required parameter \"params['messagingServiceSid']\" missing.");
}
let data = {};
data["MessagingServiceSid"] = params["messagingServiceSid"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.updateWithResponseInfo({
uri: instance._uri,
method: "post",
data,
headers,
})
.then((response) => ({
...response,
body: new MessagingConfigurationInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.country),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return this._solution;
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.MessagingConfigurationContextImpl = MessagingConfigurationContextImpl;
class MessagingConfigurationInstance {
constructor(_version, payload, serviceSid, country) {
this._version = _version;
this.accountSid = payload.account_sid;
this.serviceSid = payload.service_sid;
this.country = payload.country;
this.messagingServiceSid = payload.messaging_service_sid;
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.url = payload.url;
this._solution = { serviceSid, country: country || this.country };
}
get _proxy() {
this._context =
this._context ||
new MessagingConfigurationContextImpl(this._version, this._solution.serviceSid, this._solution.country);
return this._context;
}
/**
* Remove a MessagingConfigurationInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback) {
return this._proxy.remove(callback);
}
/**
* Remove a MessagingConfigurationInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean with HTTP metadata
*/
removeWithHttpInfo(callback) {
return this._proxy.removeWithHttpInfo(callback);
}
/**
* Fetch a MessagingConfigurationInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessagingConfigurationInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a MessagingConfigurationInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed MessagingConfigurationInstance with HTTP metadata
*/
fetchWithHttpInfo(callback) {
return this._proxy.fetchWithHttpInfo(callback);
}
update(params, callback) {
return this._proxy.update(params, callback);
}
updateWithHttpInfo(params, callback) {
return this._proxy.updateWithHttpInfo(params, callback);
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
accountSid: this.accountSid,
serviceSid: this.serviceSid,
country: this.country,
messagingServiceSid: this.messagingServiceSid,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
url: this.url,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.MessagingConfigurationInstance = MessagingConfigurationInstance;
function MessagingConfigurationListInstance(version, serviceSid) {
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
const instance = ((country) => instance.get(country));
instance.get = function get(country) {
return new MessagingConfigurationContextImpl(version, serviceSid, country);
};
instance._version = version;
instance._solution = { serviceSid };
instance._uri = `/Services/${serviceSid}/MessagingConfigurations`;
instance.create = function create(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["country"] === null || params["country"] === undefined) {
throw new Error("Required parameter \"params['country']\" missing.");
}
if (params["messagingServiceSid"] === null ||
params["messagingServiceSid"] === undefined) {
throw new Error("Required parameter \"params['messagingServiceSid']\" missing.");
}
let data = {};
data["Country"] = params["country"];
data["MessagingServiceSid"] = params["messagingServiceSid"];
const headers = {};
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 MessagingConfigurationInstance(operationVersion, payload, instance._solution.serviceSid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.createWithHttpInfo = function createWithHttpInfo(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["country"] === null || params["country"] === undefined) {
throw new Error("Required parameter \"params['country']\" missing.");
}
if (params["messagingServiceSid"] === null ||
params["messagingServiceSid"] === undefined) {
throw new Error("Required parameter \"params['messagingServiceSid']\" missing.");
}
let data = {};
data["Country"] = params["country"];
data["MessagingServiceSid"] = params["messagingServiceSid"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
let operationVersion = version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.createWithResponseInfo({
uri: instance._uri,
method: "post",
data,
headers,
})
.then((response) => ({
...response,
body: new MessagingConfigurationInstance(operationVersion, response.body, instance._solution.serviceSid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.page = function page(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["pageSize"] !== undefined)
data["PageSize"] = params["pageSize"];
if (params.pageNumber !== undefined)
data["Page"] = params.pageNumber;
if (params.pageToken !== undefined)
data["PageToken"] = params.pageToken;
const headers = {};
headers["Accept"] = "application/json";
let operationVersion = version, operationPromise = operationVersion.page({
uri: instance._uri,
method: "get",
params: data,
headers,
});
operationPromise = operationPromise.then((payload) => new MessagingConfigurationPage(operationVersion, payload, instance._solution));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.each = instance._version.each;
instance.list = instance._version.list;
instance.getPage = function getPage(targetUrl, callback) {
const operationPromise = instance._version._domain.twilio.request({
method: "get",
uri: targetUrl,
});
let pagePromise = operationPromise.then((payload) => new MessagingConfigurationPage(instance._version, payload, instance._solution));
pagePromise = instance._version.setPromiseCallback(pagePromise, callback);
return pagePromise;
};
instance.pageWithHttpInfo = function pageWithHttpInfo(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["pageSize"] !== undefined)
data["PageSize"] = params["pageSize"];
if (params.pageNumber !== undefined)
data["Page"] = params.pageNumber;
if (params.pageToken !== undefined)
data["PageToken"] = params.pageToken;
const headers = {};
headers["Accept"] = "application/json";
let operationVersion = version;
// For page operations, use page() directly as it already returns { statusCode, body, headers }
// IMPORTANT: Pass full response to Page constructor, not response.body
let operationPromise = operationVersion
.page({ uri: instance._uri, method: "get", params: data, headers })
.then((response) => ({
statusCode: response.statusCode,
headers: response.headers,
body: new MessagingConfigurationPage(operationVersion, response, instance._solution),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.each = instance._version.each;
instance.eachWithHttpInfo = instance._version.eachWithHttpInfo;
instance.list = instance._version.list;
instance.listWithHttpInfo = instance._version.listWithHttpInfo;
instance.getPageWithHttpInfo = function getPageWithHttpInfo(targetUrl, callback) {
// Use request() directly as it already returns { statusCode, body, headers }
const operationPromise = instance._version._domain.twilio.request({
method: "get",
uri: targetUrl,
});
let pagePromise = operationPromise.then((response) => ({
statusCode: response.statusCode,
headers: response.headers,
body: new MessagingConfigurationPage(instance._version, response, instance._solution),
}));
pagePromise = instance._version.setPromiseCallback(pagePromise, callback);
return pagePromise;
};
instance.toJSON = function toJSON() {
return instance._solution;
};
instance[util_1.inspect.custom] = function inspectImpl(_depth, options) {
return (0, util_1.inspect)(instance.toJSON(), options);
};
return instance;
}
class MessagingConfigurationPage extends Page_1.default {
/**
* Initialize the MessagingConfigurationPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version, response, solution) {
super(version, response, solution);
}
/**
* Build an instance of MessagingConfigurationInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new MessagingConfigurationInstance(this._version, payload, this._solution.serviceSid);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.MessagingConfigurationPage = MessagingConfigurationPage;

View File

@@ -0,0 +1,228 @@
import { inspect, InspectOptions } from "util";
import V2 from "../../V2";
import { ApiResponse } from "../../../../base/ApiResponse";
export declare class CreatePasskeysChallengeRequest {
"identity"?: string;
"factorSid"?: string;
constructor(payload: any);
}
/**
* Options to pass to create a NewChallengeInstance
*/
export interface NewChallengeContextCreateOptions {
/** */
createPasskeysChallengeRequest: CreatePasskeysChallengeRequest;
}
export interface NewChallengeContext {
/**
* Create a NewChallengeInstance
*
* @param params - Body for request
* @param headers - header params for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed NewChallengeInstance
*/
create(params: CreatePasskeysChallengeRequest, headers?: any, callback?: (error: Error | null, item?: NewChallengeInstance) => any): Promise<NewChallengeInstance>;
/**
* Create a NewChallengeInstance and return HTTP info
*
* @param params - Body for request
* @param headers - header params for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed NewChallengeInstance with HTTP metadata
*/
createWithHttpInfo(params: CreatePasskeysChallengeRequest, headers?: any, callback?: (error: Error | null, item?: ApiResponse<NewChallengeInstance>) => any): Promise<ApiResponse<NewChallengeInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface NewChallengeContextSolution {
serviceSid: string;
}
export declare class NewChallengeContextImpl implements NewChallengeContext {
protected _version: V2;
protected _solution: NewChallengeContextSolution;
protected _uri: string;
constructor(_version: V2, serviceSid: string);
create(params: CreatePasskeysChallengeRequest, headers?: any, callback?: (error: Error | null, item?: NewChallengeInstance) => any): Promise<NewChallengeInstance>;
createWithHttpInfo(params: CreatePasskeysChallengeRequest, headers?: any, callback?: (error: Error | null, item?: ApiResponse<NewChallengeInstance>) => any): Promise<ApiResponse<NewChallengeInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): NewChallengeContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface NewChallengeResource {
options: Record<string, object>;
sid: string;
account_sid: string;
service_sid: string;
entity_sid: string;
identity: string;
factor_sid: string;
date_created: Date;
date_updated: Date;
date_responded: Date;
expiration_date: Date;
status: string;
responded_reason: string;
details: any;
hidden_details: any;
metadata: any;
factor_type: string;
url: string;
links: Record<string, string>;
}
export declare class NewChallengeInstance {
protected _version: V2;
protected _solution: NewChallengeContextSolution;
protected _context?: NewChallengeContext;
constructor(_version: V2, payload: NewChallengeResource, serviceSid: string);
/**
* An object that contains challenge options. Currently only used for `passkeys`.
*/
options: Record<string, object>;
/**
* A 34 character string that uniquely identifies this Challenge.
*/
sid: string;
/**
* The unique SID identifier of the Account.
*/
accountSid: string;
/**
* The unique SID identifier of the Service.
*/
serviceSid: string;
/**
* The unique SID identifier of the Entity.
*/
entitySid: string;
/**
* Customer unique identity for the Entity owner of the Challenge.
*/
identity: string;
/**
* The unique SID identifier of the Factor.
*/
factorSid: string;
/**
* The date that this Challenge was created, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateCreated: Date;
/**
* The date that this Challenge was updated, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateUpdated: Date;
/**
* The date that this Challenge was responded, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateResponded: Date;
/**
* The date-time when this Challenge expires, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
expirationDate: Date;
/**
* The Status of this Challenge. One of `pending`, `expired`, `approved` or `denied`.
*/
status: string;
/**
* Reason for the Challenge to be in certain `status`. One of `none`, `not_needed` or `not_requested`.
*/
respondedReason: string;
/**
* Details provided to give context about the Challenge.
*/
details: any;
/**
* Details provided to give context about the Challenge.
*/
hiddenDetails: any;
/**
* Custom metadata associated with the challenge.
*/
metadata: any;
/**
* The Factor Type of this Challenge. Currently `push` and `totp` are supported.
*/
factorType: string;
/**
* The URL of this resource.
*/
url: string;
/**
* Contains a dictionary of URL links to nested resources of this Challenge.
*/
links: Record<string, string>;
private get _proxy();
/**
* Create a NewChallengeInstance
*
* @param params - Body for request
* @param headers - header params for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed NewChallengeInstance
*/
create(params: CreatePasskeysChallengeRequest, headers?: any, callback?: (error: Error | null, item?: NewChallengeInstance) => any): Promise<NewChallengeInstance>;
/**
* Create a NewChallengeInstance and return HTTP info
*
* @param params - Body for request
* @param headers - header params for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed NewChallengeInstance with HTTP metadata
*/
createWithHttpInfo(params: CreatePasskeysChallengeRequest, headers?: any, callback?: (error: Error | null, item?: ApiResponse<NewChallengeInstance>) => any): Promise<ApiResponse<NewChallengeInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
options: Record<string, object>;
sid: string;
accountSid: string;
serviceSid: string;
entitySid: string;
identity: string;
factorSid: string;
dateCreated: Date;
dateUpdated: Date;
dateResponded: Date;
expirationDate: Date;
status: string;
respondedReason: string;
details: any;
hiddenDetails: any;
metadata: any;
factorType: string;
url: string;
links: Record<string, string>;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface NewChallengeSolution {
serviceSid: string;
}
export interface NewChallengeListInstance {
_version: V2;
_solution: NewChallengeSolution;
_uri: string;
(): NewChallengeContext;
get(): NewChallengeContext;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function NewChallengeListInstance(version: V2, serviceSid: string): NewChallengeListInstance;
export {};

View File

@@ -0,0 +1,188 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Verify
* 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.NewChallengeInstance = exports.NewChallengeContextImpl = exports.CreatePasskeysChallengeRequest = void 0;
exports.NewChallengeListInstance = NewChallengeListInstance;
const util_1 = require("util");
const deserialize = require("../../../../base/deserialize");
const serialize = require("../../../../base/serialize");
const utility_1 = require("../../../../base/utility");
class CreatePasskeysChallengeRequest {
constructor(payload) {
this.identity = payload["identity"];
this.factorSid = payload["factor_sid"];
}
}
exports.CreatePasskeysChallengeRequest = CreatePasskeysChallengeRequest;
class NewChallengeContextImpl {
constructor(_version, serviceSid) {
this._version = _version;
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
this._solution = { serviceSid };
this._uri = `/Services/${serviceSid}/Passkeys/Challenges`;
}
create(params, headers, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
let data = {};
data = params;
if (headers === null || headers === undefined) {
headers = {};
}
headers["Content-Type"] = "application/json";
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.create({
uri: instance._uri,
method: "post",
data,
headers,
});
operationPromise = operationPromise.then((payload) => new NewChallengeInstance(operationVersion, payload, instance._solution.serviceSid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
createWithHttpInfo(params, headers, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
let data = {};
data = params;
if (headers === null || headers === undefined) {
headers = {};
}
headers["Content-Type"] = "application/json";
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.createWithResponseInfo({
uri: instance._uri,
method: "post",
data,
headers,
})
.then((response) => ({
...response,
body: new NewChallengeInstance(operationVersion, response.body, instance._solution.serviceSid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return this._solution;
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.NewChallengeContextImpl = NewChallengeContextImpl;
class NewChallengeInstance {
constructor(_version, payload, serviceSid) {
this._version = _version;
this.options = payload.options;
this.sid = payload.sid;
this.accountSid = payload.account_sid;
this.serviceSid = payload.service_sid;
this.entitySid = payload.entity_sid;
this.identity = payload.identity;
this.factorSid = payload.factor_sid;
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.dateResponded = deserialize.iso8601DateTime(payload.date_responded);
this.expirationDate = deserialize.iso8601DateTime(payload.expiration_date);
this.status = payload.status;
this.respondedReason = payload.responded_reason;
this.details = payload.details;
this.hiddenDetails = payload.hidden_details;
this.metadata = payload.metadata;
this.factorType = payload.factor_type;
this.url = payload.url;
this.links = payload.links;
this._solution = { serviceSid };
}
get _proxy() {
this._context =
this._context ||
new NewChallengeContextImpl(this._version, this._solution.serviceSid);
return this._context;
}
create(params, callback) {
return this._proxy.create(params, callback);
}
createWithHttpInfo(params, callback) {
return this._proxy.createWithHttpInfo(params, callback);
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
options: this.options,
sid: this.sid,
accountSid: this.accountSid,
serviceSid: this.serviceSid,
entitySid: this.entitySid,
identity: this.identity,
factorSid: this.factorSid,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
dateResponded: this.dateResponded,
expirationDate: this.expirationDate,
status: this.status,
respondedReason: this.respondedReason,
details: this.details,
hiddenDetails: this.hiddenDetails,
metadata: this.metadata,
factorType: this.factorType,
url: this.url,
links: this.links,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.NewChallengeInstance = NewChallengeInstance;
function NewChallengeListInstance(version, serviceSid) {
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
const instance = (() => instance.get());
instance.get = function get() {
return new NewChallengeContextImpl(version, serviceSid);
};
instance._version = version;
instance._solution = { serviceSid };
instance._uri = ``;
instance.toJSON = function toJSON() {
return instance._solution;
};
instance[util_1.inspect.custom] = function inspectImpl(_depth, options) {
return (0, util_1.inspect)(instance.toJSON(), options);
};
return instance;
}

View File

@@ -0,0 +1,168 @@
import { inspect, InspectOptions } from "util";
import V2 from "../../V2";
import { ApiResponse } from "../../../../base/ApiResponse";
export declare class CreateNewPasskeysFactorRequest {
"friendlyName": string;
"identity": string;
"config"?: CreateNewPasskeysFactorRequestConfig;
constructor(payload: any);
}
export declare class CreateNewPasskeysFactorRequestConfig {
"relyingParty"?: CreateNewPasskeysFactorRequestConfigRelyingParty;
"authenticatorAttachment"?: string;
"discoverableCredentials"?: string;
"userVerification"?: string;
constructor(payload: any);
}
/**
* Contains the information of the party requesting the user for authentication
*/
export declare class CreateNewPasskeysFactorRequestConfigRelyingParty {
"id"?: string;
"name"?: string;
"origins"?: Array<string>;
constructor(payload: any);
}
/**
* Options to pass to create a NewFactorInstance
*/
export interface NewFactorListInstanceCreateOptions {
/** */
createNewPasskeysFactorRequest: CreateNewPasskeysFactorRequest;
}
export interface NewFactorSolution {
serviceSid: string;
}
export interface NewFactorListInstance {
_version: V2;
_solution: NewFactorSolution;
_uri: string;
/**
* Create a NewFactorInstance
*
* @param params - Body for request
* @param headers - header params for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed NewFactorInstance
*/
create(params: CreateNewPasskeysFactorRequest, headers?: any, callback?: (error: Error | null, item?: NewFactorInstance) => any): Promise<NewFactorInstance>;
/**
* Create a NewFactorInstance and return HTTP info
*
* @param params - Body for request
* @param headers - header params for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed NewFactorInstance with HTTP metadata
*/
createWithHttpInfo(params: CreateNewPasskeysFactorRequest, headers?: any, callback?: (error: Error | null, item?: ApiResponse<NewFactorInstance>) => any): Promise<ApiResponse<NewFactorInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function NewFactorListInstance(version: V2, serviceSid: string): NewFactorListInstance;
interface NewFactorResource {
sid: string;
account_sid: string;
service_sid: string;
entity_sid: string;
identity: string;
binding: any;
options: any;
date_created: Date;
date_updated: Date;
friendly_name: string;
status: string;
factor_type: string;
config: any;
metadata: any;
url: string;
}
export declare class NewFactorInstance {
protected _version: V2;
constructor(_version: V2, payload: NewFactorResource, serviceSid: string);
/**
* A 34 character string that uniquely identifies this Factor.
*/
sid: string;
/**
* The unique SID identifier of the Account.
*/
accountSid: string;
/**
* The unique SID identifier of the Service.
*/
serviceSid: string;
/**
* The unique SID identifier of the Entity.
*/
entitySid: string;
/**
* Customer unique identity for the Entity owner of the Factor.
*/
identity: string;
/**
* Contains the `factor_type` specific secret and metadata. The Binding property is ONLY returned upon Factor creation.
*/
binding: any;
options: any;
/**
* The date that this Factor was created, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateCreated: Date;
/**
* The date that this Factor was updated, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateUpdated: Date;
/**
* The friendly name of this Factor. This can be any string up to 64 characters, meant for humans to distinguish between Factors.
*/
friendlyName: string;
/**
* The Status of this Factor. One of `unverified` or `verified`.
*/
status: string;
/**
* The Type of this Factor. Currently `push` and `totp` are supported.
*/
factorType: string;
/**
* An object that contains configurations specific to a `factor_type`.
*/
config: any;
/**
* Custom metadata associated with the factor.
*/
metadata: any;
/**
* The URL of this resource.
*/
url: string;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
accountSid: string;
serviceSid: string;
entitySid: string;
identity: string;
binding: any;
options: any;
dateCreated: Date;
dateUpdated: Date;
friendlyName: string;
status: string;
factorType: string;
config: any;
metadata: any;
url: string;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export {};

View File

@@ -0,0 +1,161 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Verify
* 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.NewFactorInstance = exports.CreateNewPasskeysFactorRequestConfigRelyingParty = exports.CreateNewPasskeysFactorRequestConfig = exports.CreateNewPasskeysFactorRequest = void 0;
exports.NewFactorListInstance = NewFactorListInstance;
const util_1 = require("util");
const deserialize = require("../../../../base/deserialize");
const serialize = require("../../../../base/serialize");
const utility_1 = require("../../../../base/utility");
class CreateNewPasskeysFactorRequest {
constructor(payload) {
this.friendlyName = payload["friendly_name"];
this.identity = payload["identity"];
this.config = payload["config"];
}
}
exports.CreateNewPasskeysFactorRequest = CreateNewPasskeysFactorRequest;
class CreateNewPasskeysFactorRequestConfig {
constructor(payload) {
this.relyingParty = payload["relying_party"];
this.authenticatorAttachment = payload["authenticator_attachment"];
this.discoverableCredentials = payload["discoverable_credentials"];
this.userVerification = payload["user_verification"];
}
}
exports.CreateNewPasskeysFactorRequestConfig = CreateNewPasskeysFactorRequestConfig;
/**
* Contains the information of the party requesting the user for authentication
*/
class CreateNewPasskeysFactorRequestConfigRelyingParty {
constructor(payload) {
this.id = payload["id"];
this.name = payload["name"];
this.origins = payload["origins"];
}
}
exports.CreateNewPasskeysFactorRequestConfigRelyingParty = CreateNewPasskeysFactorRequestConfigRelyingParty;
function NewFactorListInstance(version, serviceSid) {
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
const instance = {};
instance._version = version;
instance._solution = { serviceSid };
instance._uri = `/Services/${serviceSid}/Passkeys/Factors`;
instance.create = function create(params, headers, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
let data = {};
data = params;
if (headers === null || headers === undefined) {
headers = {};
}
headers["Content-Type"] = "application/json";
headers["Accept"] = "application/json";
let operationVersion = version, operationPromise = operationVersion.create({
uri: instance._uri,
method: "post",
data,
headers,
});
operationPromise = operationPromise.then((payload) => new NewFactorInstance(operationVersion, payload, instance._solution.serviceSid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.createWithHttpInfo = function createWithHttpInfo(params, headers, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
let data = {};
data = params;
if (headers === null || headers === undefined) {
headers = {};
}
headers["Content-Type"] = "application/json";
headers["Accept"] = "application/json";
let operationVersion = version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.createWithResponseInfo({
uri: instance._uri,
method: "post",
data,
headers,
})
.then((response) => ({
...response,
body: new NewFactorInstance(operationVersion, response.body, instance._solution.serviceSid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.toJSON = function toJSON() {
return instance._solution;
};
instance[util_1.inspect.custom] = function inspectImpl(_depth, options) {
return (0, util_1.inspect)(instance.toJSON(), options);
};
return instance;
}
class NewFactorInstance {
constructor(_version, payload, serviceSid) {
this._version = _version;
this.sid = payload.sid;
this.accountSid = payload.account_sid;
this.serviceSid = payload.service_sid;
this.entitySid = payload.entity_sid;
this.identity = payload.identity;
this.binding = payload.binding;
this.options = payload.options;
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.friendlyName = payload.friendly_name;
this.status = payload.status;
this.factorType = payload.factor_type;
this.config = payload.config;
this.metadata = payload.metadata;
this.url = payload.url;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
sid: this.sid,
accountSid: this.accountSid,
serviceSid: this.serviceSid,
entitySid: this.entitySid,
identity: this.identity,
binding: this.binding,
options: this.options,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
friendlyName: this.friendlyName,
status: this.status,
factorType: this.factorType,
config: this.config,
metadata: this.metadata,
url: this.url,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.NewFactorInstance = NewFactorInstance;

View File

@@ -0,0 +1,175 @@
import { inspect, InspectOptions } from "util";
import V2 from "../../V2";
import { ApiResponse } from "../../../../base/ApiResponse";
export declare class VerifyPasskeysFactorRequest {
/**
* A [base64url](https://base64.guru/standards/base64url) encoded representation of `rawId`.
*/
"id"?: string;
/**
* The globally unique identifier for this `PublicKeyCredential`.
*/
"rawId"?: string;
/**
* A string that indicates the mechanism by which the WebAuthn implementation is attached to the authenticator at the time the associated `navigator.credentials.create()` or `navigator.credentials.get()` call completes.
*/
"authenticatorAttachment"?: string;
/**
* The valid credential types supported by the API. The values of this enumeration are used for versioning the `AuthenticatorAssertion` and `AuthenticatorAttestation` structures according to the type of the authenticator.
*/
"type"?: string;
"response": VerifyPasskeysFactorRequestResponse;
constructor(payload: any);
}
/**
* The result of a WebAuthn credential registration via `navigator.credentials.create()`, as specified in [AuthenticatorAttestationResponse](https://developer.mozilla.org/en-US/docs/Web/API/AuthenticatorAttestationResponse).
*/
export declare class VerifyPasskeysFactorRequestResponse {
/**
* The authenticator data and an attestation statement for a new key pair generated by the authenticator.
*/
"attestationObject"?: string;
/**
* This property contains the JSON-compatible serialization of the data passed from the browser to the authenticator in order to generate this credential.
*/
"clientDataJSON"?: string;
/**
* An array of strings providing hints as to the methods the client could use to communicate with the relevant authenticator of the public key credential to retrieve.
*/
"transports"?: Array<string>;
constructor(payload: any);
}
/**
* Options to pass to update a NewVerifyFactorInstance
*/
export interface NewVerifyFactorListInstanceUpdateOptions {
/** */
verifyPasskeysFactorRequest: VerifyPasskeysFactorRequest;
}
export interface NewVerifyFactorSolution {
serviceSid: string;
}
export interface NewVerifyFactorListInstance {
_version: V2;
_solution: NewVerifyFactorSolution;
_uri: string;
/**
* Update a NewVerifyFactorInstance
*
* @param params - Body for request
* @param headers - header params for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed NewVerifyFactorInstance
*/
update(params: VerifyPasskeysFactorRequest, headers?: any, callback?: (error: Error | null, item?: NewVerifyFactorInstance) => any): Promise<NewVerifyFactorInstance>;
/**
* Update a NewVerifyFactorInstance and return HTTP info
*
* @param params - Body for request
* @param headers - header params for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed NewVerifyFactorInstance with HTTP metadata
*/
updateWithHttpInfo(params: VerifyPasskeysFactorRequest, headers?: any, callback?: (error: Error | null, item?: ApiResponse<NewVerifyFactorInstance>) => any): Promise<ApiResponse<NewVerifyFactorInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function NewVerifyFactorListInstance(version: V2, serviceSid: string): NewVerifyFactorListInstance;
interface NewVerifyFactorResource {
sid: string;
account_sid: string;
service_sid: string;
entity_sid: string;
identity: string;
date_created: Date;
date_updated: Date;
friendly_name: string;
status: string;
factor_type: string;
config: any;
metadata: any;
url: string;
}
export declare class NewVerifyFactorInstance {
protected _version: V2;
constructor(_version: V2, payload: NewVerifyFactorResource, serviceSid: string);
/**
* A 34 character string that uniquely identifies this Factor.
*/
sid: string;
/**
* The unique SID identifier of the Account.
*/
accountSid: string;
/**
* The unique SID identifier of the Service.
*/
serviceSid: string;
/**
* The unique SID identifier of the Entity.
*/
entitySid: string;
/**
* Customer unique identity for the Entity owner of the Factor.
*/
identity: string;
/**
* The date that this Factor was created, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateCreated: Date;
/**
* The date that this Factor was updated, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateUpdated: Date;
/**
* A human readable description of this resource, up to 64 characters.
*/
friendlyName: string;
/**
* The Status of this Factor. One of `unverified` or `verified`.
*/
status: string;
/**
* The Type of this Factor. Currently `push` and `totp` are supported.
*/
factorType: string;
/**
* An object that contains configurations specific to a `factor_type`.
*/
config: any;
/**
* Custom metadata associated with the factor.
*/
metadata: any;
/**
* The URL of this resource.
*/
url: string;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
accountSid: string;
serviceSid: string;
entitySid: string;
identity: string;
dateCreated: Date;
dateUpdated: Date;
friendlyName: string;
status: string;
factorType: string;
config: any;
metadata: any;
url: string;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export {};

View File

@@ -0,0 +1,150 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Verify
* 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.NewVerifyFactorInstance = exports.VerifyPasskeysFactorRequestResponse = exports.VerifyPasskeysFactorRequest = void 0;
exports.NewVerifyFactorListInstance = NewVerifyFactorListInstance;
const util_1 = require("util");
const deserialize = require("../../../../base/deserialize");
const serialize = require("../../../../base/serialize");
const utility_1 = require("../../../../base/utility");
class VerifyPasskeysFactorRequest {
constructor(payload) {
this.id = payload["id"];
this.rawId = payload["rawId"];
this.authenticatorAttachment = payload["authenticatorAttachment"];
this.type = payload["type"];
this.response = payload["response"];
}
}
exports.VerifyPasskeysFactorRequest = VerifyPasskeysFactorRequest;
/**
* The result of a WebAuthn credential registration via `navigator.credentials.create()`, as specified in [AuthenticatorAttestationResponse](https://developer.mozilla.org/en-US/docs/Web/API/AuthenticatorAttestationResponse).
*/
class VerifyPasskeysFactorRequestResponse {
constructor(payload) {
this.attestationObject = payload["attestationObject"];
this.clientDataJSON = payload["clientDataJSON"];
this.transports = payload["transports"];
}
}
exports.VerifyPasskeysFactorRequestResponse = VerifyPasskeysFactorRequestResponse;
function NewVerifyFactorListInstance(version, serviceSid) {
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
const instance = {};
instance._version = version;
instance._solution = { serviceSid };
instance._uri = `/Services/${serviceSid}/Passkeys/VerifyFactor`;
instance.update = function update(params, headers, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
let data = {};
data = params;
if (headers === null || headers === undefined) {
headers = {};
}
headers["Content-Type"] = "application/json";
headers["Accept"] = "application/json";
let operationVersion = version, operationPromise = operationVersion.update({
uri: instance._uri,
method: "post",
data,
headers,
});
operationPromise = operationPromise.then((payload) => new NewVerifyFactorInstance(operationVersion, payload, instance._solution.serviceSid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.updateWithHttpInfo = function updateWithHttpInfo(params, headers, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
let data = {};
data = params;
if (headers === null || headers === undefined) {
headers = {};
}
headers["Content-Type"] = "application/json";
headers["Accept"] = "application/json";
let operationVersion = version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.updateWithResponseInfo({
uri: instance._uri,
method: "post",
data,
headers,
})
.then((response) => ({
...response,
body: new NewVerifyFactorInstance(operationVersion, response.body, instance._solution.serviceSid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.toJSON = function toJSON() {
return instance._solution;
};
instance[util_1.inspect.custom] = function inspectImpl(_depth, options) {
return (0, util_1.inspect)(instance.toJSON(), options);
};
return instance;
}
class NewVerifyFactorInstance {
constructor(_version, payload, serviceSid) {
this._version = _version;
this.sid = payload.sid;
this.accountSid = payload.account_sid;
this.serviceSid = payload.service_sid;
this.entitySid = payload.entity_sid;
this.identity = payload.identity;
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.friendlyName = payload.friendly_name;
this.status = payload.status;
this.factorType = payload.factor_type;
this.config = payload.config;
this.metadata = payload.metadata;
this.url = payload.url;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
sid: this.sid,
accountSid: this.accountSid,
serviceSid: this.serviceSid,
entitySid: this.entitySid,
identity: this.identity,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
friendlyName: this.friendlyName,
status: this.status,
factorType: this.factorType,
config: this.config,
metadata: this.metadata,
url: this.url,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.NewVerifyFactorInstance = NewVerifyFactorInstance;

View File

@@ -0,0 +1,452 @@
import { inspect, InspectOptions } from "util";
import Page, { TwilioResponsePayload } from "../../../../base/Page";
import Response from "../../../../http/response";
import V2 from "../../V2";
import { ApiResponse } from "../../../../base/ApiResponse";
import { BucketListInstance } from "./rateLimit/bucket";
/**
* Options to pass to update a RateLimitInstance
*/
export interface RateLimitContextUpdateOptions {
/** Description of this Rate Limit */
description?: string;
}
/**
* Options to pass to create a RateLimitInstance
*/
export interface RateLimitListInstanceCreateOptions {
/** Provides a unique and addressable name to be assigned to this Rate Limit, assigned by the developer, to be optionally used in addition to SID. **This value should not contain PII.** */
uniqueName: string;
/** Description of this Rate Limit */
description?: string;
}
/**
* Options to pass to each
*/
export interface RateLimitListInstanceEachOptions {
/** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
pageSize?: number;
/** Function to process each record. If this and a positional callback are passed, this one will be used */
callback?: (item: RateLimitInstance, done: (err?: Error) => void) => void;
/** Function to be called upon completion of streaming */
done?: Function;
/** Upper limit for the number of records to return. each() guarantees never to return more than limit. Default is no limit */
limit?: number;
}
/**
* Options to pass to list
*/
export interface RateLimitListInstanceOptions {
/** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
pageSize?: number;
/** Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit */
limit?: number;
}
/**
* Options to pass to page
*/
export interface RateLimitListInstancePageOptions {
/** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
pageSize?: number;
/** Page Number, this value is simply for client state */
pageNumber?: number;
/** PageToken provided by the API */
pageToken?: string;
}
export interface RateLimitContext {
buckets: BucketListInstance;
/**
* Remove a RateLimitInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a RateLimitInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean with HTTP metadata
*/
removeWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
/**
* Fetch a RateLimitInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed RateLimitInstance
*/
fetch(callback?: (error: Error | null, item?: RateLimitInstance) => any): Promise<RateLimitInstance>;
/**
* Fetch a RateLimitInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed RateLimitInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<RateLimitInstance>) => any): Promise<ApiResponse<RateLimitInstance>>;
/**
* Update a RateLimitInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed RateLimitInstance
*/
update(callback?: (error: Error | null, item?: RateLimitInstance) => any): Promise<RateLimitInstance>;
/**
* Update a RateLimitInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed RateLimitInstance
*/
update(params: RateLimitContextUpdateOptions, callback?: (error: Error | null, item?: RateLimitInstance) => any): Promise<RateLimitInstance>;
/**
* Update a RateLimitInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed RateLimitInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<RateLimitInstance>) => any): Promise<ApiResponse<RateLimitInstance>>;
/**
* Update a RateLimitInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed RateLimitInstance with HTTP metadata
*/
updateWithHttpInfo(params: RateLimitContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<RateLimitInstance>) => any): Promise<ApiResponse<RateLimitInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface RateLimitContextSolution {
serviceSid: string;
sid: string;
}
export declare class RateLimitContextImpl implements RateLimitContext {
protected _version: V2;
protected _solution: RateLimitContextSolution;
protected _uri: string;
protected _buckets?: BucketListInstance;
constructor(_version: V2, serviceSid: string, sid: string);
get buckets(): BucketListInstance;
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
removeWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
fetch(callback?: (error: Error | null, item?: RateLimitInstance) => any): Promise<RateLimitInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<RateLimitInstance>) => any): Promise<ApiResponse<RateLimitInstance>>;
update(params?: RateLimitContextUpdateOptions | ((error: Error | null, item?: RateLimitInstance) => any), callback?: (error: Error | null, item?: RateLimitInstance) => any): Promise<RateLimitInstance>;
updateWithHttpInfo(params?: RateLimitContextUpdateOptions | ((error: Error | null, item?: ApiResponse<RateLimitInstance>) => any), callback?: (error: Error | null, item?: ApiResponse<RateLimitInstance>) => any): Promise<ApiResponse<RateLimitInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): RateLimitContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface RateLimitPayload extends TwilioResponsePayload {
rate_limits: RateLimitResource[];
}
interface RateLimitResource {
sid: string;
service_sid: string;
account_sid: string;
unique_name: string;
description: string;
date_created: Date;
date_updated: Date;
url: string;
links: Record<string, string>;
}
export declare class RateLimitInstance {
protected _version: V2;
protected _solution: RateLimitContextSolution;
protected _context?: RateLimitContext;
constructor(_version: V2, payload: RateLimitResource, serviceSid: string, sid?: string);
/**
* A 34 character string that uniquely identifies this Rate Limit.
*/
sid: string;
/**
* The SID of the [Service](https://www.twilio.com/docs/verify/api/service) the resource is associated with.
*/
serviceSid: string;
/**
* The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Rate Limit resource.
*/
accountSid: string;
/**
* Provides a unique and addressable name to be assigned to this Rate Limit, assigned by the developer, to be optionally used in addition to SID. **This value should not contain PII.**
*/
uniqueName: string;
/**
* Description of this Rate Limit
*/
description: string;
/**
* The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
*/
dateCreated: Date;
/**
* The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
*/
dateUpdated: Date;
/**
* The URL of this resource.
*/
url: string;
/**
* The URLs of related resources.
*/
links: Record<string, string>;
private get _proxy();
/**
* Remove a RateLimitInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a RateLimitInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean with HTTP metadata
*/
removeWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
/**
* Fetch a RateLimitInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed RateLimitInstance
*/
fetch(callback?: (error: Error | null, item?: RateLimitInstance) => any): Promise<RateLimitInstance>;
/**
* Fetch a RateLimitInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed RateLimitInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<RateLimitInstance>) => any): Promise<ApiResponse<RateLimitInstance>>;
/**
* Update a RateLimitInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed RateLimitInstance
*/
update(callback?: (error: Error | null, item?: RateLimitInstance) => any): Promise<RateLimitInstance>;
/**
* Update a RateLimitInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed RateLimitInstance
*/
update(params: RateLimitContextUpdateOptions, callback?: (error: Error | null, item?: RateLimitInstance) => any): Promise<RateLimitInstance>;
/**
* Update a RateLimitInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed RateLimitInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<RateLimitInstance>) => any): Promise<ApiResponse<RateLimitInstance>>;
/**
* Update a RateLimitInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed RateLimitInstance with HTTP metadata
*/
updateWithHttpInfo(params: RateLimitContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<RateLimitInstance>) => any): Promise<ApiResponse<RateLimitInstance>>;
/**
* Access the buckets.
*/
buckets(): BucketListInstance;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
serviceSid: string;
accountSid: string;
uniqueName: string;
description: string;
dateCreated: Date;
dateUpdated: Date;
url: string;
links: Record<string, string>;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface RateLimitSolution {
serviceSid: string;
}
export interface RateLimitListInstance {
_version: V2;
_solution: RateLimitSolution;
_uri: string;
(sid: string): RateLimitContext;
get(sid: string): RateLimitContext;
/**
* Create a RateLimitInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed RateLimitInstance
*/
create(params: RateLimitListInstanceCreateOptions, callback?: (error: Error | null, item?: RateLimitInstance) => any): Promise<RateLimitInstance>;
/**
* Create a RateLimitInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed RateLimitInstance with HTTP metadata
*/
createWithHttpInfo(params: RateLimitListInstanceCreateOptions, callback?: (error: Error | null, item?: ApiResponse<RateLimitInstance>) => any): Promise<ApiResponse<RateLimitInstance>>;
/**
* Streams RateLimitInstance records from the API.
*
* This operation lazily loads records as efficiently as possible until the limit
* is reached.
*
* The results are passed into the callback function, so this operation is memory
* efficient.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { RateLimitListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: RateLimitInstance, done: (err?: Error) => void) => void): void;
each(params: RateLimitListInstanceEachOptions, callback?: (item: RateLimitInstance, done: (err?: Error) => void) => void): void;
/**
* Streams RateLimitInstance records from the API with HTTP metadata captured per page.
*
* This operation lazily loads records as efficiently as possible until the limit
* is reached. HTTP metadata (status code, headers) is captured for each page request.
*
* The results are passed into the callback function, so this operation is memory
* efficient.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { RateLimitListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: RateLimitInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: RateLimitListInstanceEachOptions, callback?: (item: RateLimitInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of RateLimitInstance records from the API.
*
* The request is executed immediately.
*
* @param { string } [targetUrl] - API-generated URL for the requested results page
* @param { function } [callback] - Callback to handle list of records
*/
getPage(targetUrl: string, callback?: (error: Error | null, items: RateLimitPage) => any): Promise<RateLimitPage>;
/**
* Retrieve a single target page of RateLimitInstance records from the API with HTTP metadata.
*
* The request is executed immediately.
*
* @param { string } [targetUrl] - API-generated URL for the requested results page
* @param { function } [callback] - Callback to handle list of records with metadata
*/
getPageWithHttpInfo(targetUrl: string, callback?: (error: Error | null, items: ApiResponse<RateLimitPage>) => any): Promise<ApiResponse<RateLimitPage>>;
/**
* Lists RateLimitInstance records from the API as a list.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { RateLimitListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: RateLimitInstance[]) => any): Promise<RateLimitInstance[]>;
list(params: RateLimitListInstanceOptions, callback?: (error: Error | null, items: RateLimitInstance[]) => any): Promise<RateLimitInstance[]>;
/**
* Lists RateLimitInstance records from the API as a list with HTTP metadata.
*
* Returns all records along with HTTP metadata from the first page fetched.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { RateLimitListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<RateLimitInstance[]>) => any): Promise<ApiResponse<RateLimitInstance[]>>;
listWithHttpInfo(params: RateLimitListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<RateLimitInstance[]>) => any): Promise<ApiResponse<RateLimitInstance[]>>;
/**
* Retrieve a single page of RateLimitInstance records from the API.
*
* The request is executed immediately.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { RateLimitListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: RateLimitPage) => any): Promise<RateLimitPage>;
page(params: RateLimitListInstancePageOptions, callback?: (error: Error | null, items: RateLimitPage) => any): Promise<RateLimitPage>;
/**
* Retrieve a single page of RateLimitInstance records from the API with HTTP metadata.
*
* The request is executed immediately.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { RateLimitListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<RateLimitPage>) => any): Promise<ApiResponse<RateLimitPage>>;
pageWithHttpInfo(params: RateLimitListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<RateLimitPage>) => any): Promise<ApiResponse<RateLimitPage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function RateLimitListInstance(version: V2, serviceSid: string): RateLimitListInstance;
export declare class RateLimitPage extends Page<V2, RateLimitPayload, RateLimitResource, RateLimitInstance> {
/**
* Initialize the RateLimitPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V2, response: Response<string>, solution: RateLimitSolution);
/**
* Build an instance of RateLimitInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: RateLimitResource): RateLimitInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

View File

@@ -0,0 +1,448 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Verify
* 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.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.RateLimitPage = exports.RateLimitInstance = exports.RateLimitContextImpl = void 0;
exports.RateLimitListInstance = RateLimitListInstance;
const util_1 = require("util");
const Page_1 = __importDefault(require("../../../../base/Page"));
const deserialize = require("../../../../base/deserialize");
const serialize = require("../../../../base/serialize");
const utility_1 = require("../../../../base/utility");
const bucket_1 = require("./rateLimit/bucket");
class RateLimitContextImpl {
constructor(_version, serviceSid, sid) {
this._version = _version;
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(sid)) {
throw new Error("Parameter 'sid' is not valid.");
}
this._solution = { serviceSid, sid };
this._uri = `/Services/${serviceSid}/RateLimits/${sid}`;
}
get buckets() {
this._buckets =
this._buckets ||
(0, bucket_1.BucketListInstance)(this._version, this._solution.serviceSid, this._solution.sid);
return this._buckets;
}
remove(callback) {
const headers = {};
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.remove({
uri: instance._uri,
method: "delete",
headers,
});
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
removeWithHttpInfo(callback) {
const headers = {};
const instance = this;
let operationVersion = instance._version;
// DELETE operation - returns boolean based on status code
let operationPromise = operationVersion
.removeWithResponseInfo({ uri: instance._uri, method: "delete", headers })
.then((response) => ({
...response,
body: response.statusCode === 204,
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
fetch(callback) {
const headers = {};
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.fetch({
uri: instance._uri,
method: "get",
headers,
});
operationPromise = operationPromise.then((payload) => new RateLimitInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.sid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
fetchWithHttpInfo(callback) {
const headers = {};
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.fetchWithResponseInfo({
uri: instance._uri,
method: "get",
headers,
})
.then((response) => ({
...response,
body: new RateLimitInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.sid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
update(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["description"] !== undefined)
data["Description"] = params["description"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.update({
uri: instance._uri,
method: "post",
data,
headers,
});
operationPromise = operationPromise.then((payload) => new RateLimitInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.sid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
updateWithHttpInfo(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["description"] !== undefined)
data["Description"] = params["description"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.updateWithResponseInfo({
uri: instance._uri,
method: "post",
data,
headers,
})
.then((response) => ({
...response,
body: new RateLimitInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.sid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return this._solution;
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.RateLimitContextImpl = RateLimitContextImpl;
class RateLimitInstance {
constructor(_version, payload, serviceSid, sid) {
this._version = _version;
this.sid = payload.sid;
this.serviceSid = payload.service_sid;
this.accountSid = payload.account_sid;
this.uniqueName = payload.unique_name;
this.description = payload.description;
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.url = payload.url;
this.links = payload.links;
this._solution = { serviceSid, sid: sid || this.sid };
}
get _proxy() {
this._context =
this._context ||
new RateLimitContextImpl(this._version, this._solution.serviceSid, this._solution.sid);
return this._context;
}
/**
* Remove a RateLimitInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback) {
return this._proxy.remove(callback);
}
/**
* Remove a RateLimitInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean with HTTP metadata
*/
removeWithHttpInfo(callback) {
return this._proxy.removeWithHttpInfo(callback);
}
/**
* Fetch a RateLimitInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed RateLimitInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a RateLimitInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed RateLimitInstance with HTTP metadata
*/
fetchWithHttpInfo(callback) {
return this._proxy.fetchWithHttpInfo(callback);
}
update(params, callback) {
return this._proxy.update(params, callback);
}
updateWithHttpInfo(params, callback) {
return this._proxy.updateWithHttpInfo(params, callback);
}
/**
* Access the buckets.
*/
buckets() {
return this._proxy.buckets;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
sid: this.sid,
serviceSid: this.serviceSid,
accountSid: this.accountSid,
uniqueName: this.uniqueName,
description: this.description,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
url: this.url,
links: this.links,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.RateLimitInstance = RateLimitInstance;
function RateLimitListInstance(version, serviceSid) {
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
const instance = ((sid) => instance.get(sid));
instance.get = function get(sid) {
return new RateLimitContextImpl(version, serviceSid, sid);
};
instance._version = version;
instance._solution = { serviceSid };
instance._uri = `/Services/${serviceSid}/RateLimits`;
instance.create = function create(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["uniqueName"] === null || params["uniqueName"] === undefined) {
throw new Error("Required parameter \"params['uniqueName']\" missing.");
}
let data = {};
data["UniqueName"] = params["uniqueName"];
if (params["description"] !== undefined)
data["Description"] = params["description"];
const headers = {};
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 RateLimitInstance(operationVersion, payload, instance._solution.serviceSid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.createWithHttpInfo = function createWithHttpInfo(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["uniqueName"] === null || params["uniqueName"] === undefined) {
throw new Error("Required parameter \"params['uniqueName']\" missing.");
}
let data = {};
data["UniqueName"] = params["uniqueName"];
if (params["description"] !== undefined)
data["Description"] = params["description"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
let operationVersion = version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.createWithResponseInfo({
uri: instance._uri,
method: "post",
data,
headers,
})
.then((response) => ({
...response,
body: new RateLimitInstance(operationVersion, response.body, instance._solution.serviceSid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.page = function page(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["pageSize"] !== undefined)
data["PageSize"] = params["pageSize"];
if (params.pageNumber !== undefined)
data["Page"] = params.pageNumber;
if (params.pageToken !== undefined)
data["PageToken"] = params.pageToken;
const headers = {};
headers["Accept"] = "application/json";
let operationVersion = version, operationPromise = operationVersion.page({
uri: instance._uri,
method: "get",
params: data,
headers,
});
operationPromise = operationPromise.then((payload) => new RateLimitPage(operationVersion, payload, instance._solution));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.each = instance._version.each;
instance.list = instance._version.list;
instance.getPage = function getPage(targetUrl, callback) {
const operationPromise = instance._version._domain.twilio.request({
method: "get",
uri: targetUrl,
});
let pagePromise = operationPromise.then((payload) => new RateLimitPage(instance._version, payload, instance._solution));
pagePromise = instance._version.setPromiseCallback(pagePromise, callback);
return pagePromise;
};
instance.pageWithHttpInfo = function pageWithHttpInfo(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["pageSize"] !== undefined)
data["PageSize"] = params["pageSize"];
if (params.pageNumber !== undefined)
data["Page"] = params.pageNumber;
if (params.pageToken !== undefined)
data["PageToken"] = params.pageToken;
const headers = {};
headers["Accept"] = "application/json";
let operationVersion = version;
// For page operations, use page() directly as it already returns { statusCode, body, headers }
// IMPORTANT: Pass full response to Page constructor, not response.body
let operationPromise = operationVersion
.page({ uri: instance._uri, method: "get", params: data, headers })
.then((response) => ({
statusCode: response.statusCode,
headers: response.headers,
body: new RateLimitPage(operationVersion, response, instance._solution),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.each = instance._version.each;
instance.eachWithHttpInfo = instance._version.eachWithHttpInfo;
instance.list = instance._version.list;
instance.listWithHttpInfo = instance._version.listWithHttpInfo;
instance.getPageWithHttpInfo = function getPageWithHttpInfo(targetUrl, callback) {
// Use request() directly as it already returns { statusCode, body, headers }
const operationPromise = instance._version._domain.twilio.request({
method: "get",
uri: targetUrl,
});
let pagePromise = operationPromise.then((response) => ({
statusCode: response.statusCode,
headers: response.headers,
body: new RateLimitPage(instance._version, response, instance._solution),
}));
pagePromise = instance._version.setPromiseCallback(pagePromise, callback);
return pagePromise;
};
instance.toJSON = function toJSON() {
return instance._solution;
};
instance[util_1.inspect.custom] = function inspectImpl(_depth, options) {
return (0, util_1.inspect)(instance.toJSON(), options);
};
return instance;
}
class RateLimitPage extends Page_1.default {
/**
* Initialize the RateLimitPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version, response, solution) {
super(version, response, solution);
}
/**
* Build an instance of RateLimitInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new RateLimitInstance(this._version, payload, this._solution.serviceSid);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.RateLimitPage = RateLimitPage;

View File

@@ -0,0 +1,448 @@
import { inspect, InspectOptions } from "util";
import Page, { TwilioResponsePayload } from "../../../../../base/Page";
import Response from "../../../../../http/response";
import V2 from "../../../V2";
import { ApiResponse } from "../../../../../base/ApiResponse";
/**
* Options to pass to update a BucketInstance
*/
export interface BucketContextUpdateOptions {
/** Maximum number of requests permitted in during the interval. */
max?: number;
/** Number of seconds that the rate limit will be enforced over. */
interval?: number;
}
/**
* Options to pass to create a BucketInstance
*/
export interface BucketListInstanceCreateOptions {
/** Maximum number of requests permitted in during the interval. */
max: number;
/** Number of seconds that the rate limit will be enforced over. */
interval: number;
}
/**
* Options to pass to each
*/
export interface BucketListInstanceEachOptions {
/** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
pageSize?: number;
/** Function to process each record. If this and a positional callback are passed, this one will be used */
callback?: (item: BucketInstance, done: (err?: Error) => void) => void;
/** Function to be called upon completion of streaming */
done?: Function;
/** Upper limit for the number of records to return. each() guarantees never to return more than limit. Default is no limit */
limit?: number;
}
/**
* Options to pass to list
*/
export interface BucketListInstanceOptions {
/** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
pageSize?: number;
/** Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit */
limit?: number;
}
/**
* Options to pass to page
*/
export interface BucketListInstancePageOptions {
/** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
pageSize?: number;
/** Page Number, this value is simply for client state */
pageNumber?: number;
/** PageToken provided by the API */
pageToken?: string;
}
export interface BucketContext {
/**
* Remove a BucketInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a BucketInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean with HTTP metadata
*/
removeWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
/**
* Fetch a BucketInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed BucketInstance
*/
fetch(callback?: (error: Error | null, item?: BucketInstance) => any): Promise<BucketInstance>;
/**
* Fetch a BucketInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed BucketInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<BucketInstance>) => any): Promise<ApiResponse<BucketInstance>>;
/**
* Update a BucketInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed BucketInstance
*/
update(callback?: (error: Error | null, item?: BucketInstance) => any): Promise<BucketInstance>;
/**
* Update a BucketInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed BucketInstance
*/
update(params: BucketContextUpdateOptions, callback?: (error: Error | null, item?: BucketInstance) => any): Promise<BucketInstance>;
/**
* Update a BucketInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed BucketInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<BucketInstance>) => any): Promise<ApiResponse<BucketInstance>>;
/**
* Update a BucketInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed BucketInstance with HTTP metadata
*/
updateWithHttpInfo(params: BucketContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<BucketInstance>) => any): Promise<ApiResponse<BucketInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface BucketContextSolution {
serviceSid: string;
rateLimitSid: string;
sid: string;
}
export declare class BucketContextImpl implements BucketContext {
protected _version: V2;
protected _solution: BucketContextSolution;
protected _uri: string;
constructor(_version: V2, serviceSid: string, rateLimitSid: string, sid: string);
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
removeWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
fetch(callback?: (error: Error | null, item?: BucketInstance) => any): Promise<BucketInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<BucketInstance>) => any): Promise<ApiResponse<BucketInstance>>;
update(params?: BucketContextUpdateOptions | ((error: Error | null, item?: BucketInstance) => any), callback?: (error: Error | null, item?: BucketInstance) => any): Promise<BucketInstance>;
updateWithHttpInfo(params?: BucketContextUpdateOptions | ((error: Error | null, item?: ApiResponse<BucketInstance>) => any), callback?: (error: Error | null, item?: ApiResponse<BucketInstance>) => any): Promise<ApiResponse<BucketInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): BucketContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface BucketPayload extends TwilioResponsePayload {
buckets: BucketResource[];
}
interface BucketResource {
sid: string;
rate_limit_sid: string;
service_sid: string;
account_sid: string;
max: number;
interval: number;
date_created: Date;
date_updated: Date;
url: string;
}
export declare class BucketInstance {
protected _version: V2;
protected _solution: BucketContextSolution;
protected _context?: BucketContext;
constructor(_version: V2, payload: BucketResource, serviceSid: string, rateLimitSid: string, sid?: string);
/**
* A 34 character string that uniquely identifies this Bucket.
*/
sid: string;
/**
* The Twilio-provided string that uniquely identifies the Rate Limit resource.
*/
rateLimitSid: string;
/**
* The SID of the [Service](https://www.twilio.com/docs/verify/api/service) the resource is associated with.
*/
serviceSid: string;
/**
* The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Rate Limit resource.
*/
accountSid: string;
/**
* Maximum number of requests permitted in during the interval.
*/
max: number;
/**
* Number of seconds that the rate limit will be enforced over.
*/
interval: number;
/**
* The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
*/
dateCreated: Date;
/**
* The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
*/
dateUpdated: Date;
/**
* The URL of this resource.
*/
url: string;
private get _proxy();
/**
* Remove a BucketInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a BucketInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean with HTTP metadata
*/
removeWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
/**
* Fetch a BucketInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed BucketInstance
*/
fetch(callback?: (error: Error | null, item?: BucketInstance) => any): Promise<BucketInstance>;
/**
* Fetch a BucketInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed BucketInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<BucketInstance>) => any): Promise<ApiResponse<BucketInstance>>;
/**
* Update a BucketInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed BucketInstance
*/
update(callback?: (error: Error | null, item?: BucketInstance) => any): Promise<BucketInstance>;
/**
* Update a BucketInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed BucketInstance
*/
update(params: BucketContextUpdateOptions, callback?: (error: Error | null, item?: BucketInstance) => any): Promise<BucketInstance>;
/**
* Update a BucketInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed BucketInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<BucketInstance>) => any): Promise<ApiResponse<BucketInstance>>;
/**
* Update a BucketInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed BucketInstance with HTTP metadata
*/
updateWithHttpInfo(params: BucketContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<BucketInstance>) => any): Promise<ApiResponse<BucketInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
rateLimitSid: string;
serviceSid: string;
accountSid: string;
max: number;
interval: number;
dateCreated: Date;
dateUpdated: Date;
url: string;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface BucketSolution {
serviceSid: string;
rateLimitSid: string;
}
export interface BucketListInstance {
_version: V2;
_solution: BucketSolution;
_uri: string;
(sid: string): BucketContext;
get(sid: string): BucketContext;
/**
* Create a BucketInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed BucketInstance
*/
create(params: BucketListInstanceCreateOptions, callback?: (error: Error | null, item?: BucketInstance) => any): Promise<BucketInstance>;
/**
* Create a BucketInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed BucketInstance with HTTP metadata
*/
createWithHttpInfo(params: BucketListInstanceCreateOptions, callback?: (error: Error | null, item?: ApiResponse<BucketInstance>) => any): Promise<ApiResponse<BucketInstance>>;
/**
* Streams BucketInstance records from the API.
*
* This operation lazily loads records as efficiently as possible until the limit
* is reached.
*
* The results are passed into the callback function, so this operation is memory
* efficient.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { BucketListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: BucketInstance, done: (err?: Error) => void) => void): void;
each(params: BucketListInstanceEachOptions, callback?: (item: BucketInstance, done: (err?: Error) => void) => void): void;
/**
* Streams BucketInstance records from the API with HTTP metadata captured per page.
*
* This operation lazily loads records as efficiently as possible until the limit
* is reached. HTTP metadata (status code, headers) is captured for each page request.
*
* The results are passed into the callback function, so this operation is memory
* efficient.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { BucketListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: BucketInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: BucketListInstanceEachOptions, callback?: (item: BucketInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of BucketInstance records from the API.
*
* The request is executed immediately.
*
* @param { string } [targetUrl] - API-generated URL for the requested results page
* @param { function } [callback] - Callback to handle list of records
*/
getPage(targetUrl: string, callback?: (error: Error | null, items: BucketPage) => any): Promise<BucketPage>;
/**
* Retrieve a single target page of BucketInstance records from the API with HTTP metadata.
*
* The request is executed immediately.
*
* @param { string } [targetUrl] - API-generated URL for the requested results page
* @param { function } [callback] - Callback to handle list of records with metadata
*/
getPageWithHttpInfo(targetUrl: string, callback?: (error: Error | null, items: ApiResponse<BucketPage>) => any): Promise<ApiResponse<BucketPage>>;
/**
* Lists BucketInstance records from the API as a list.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { BucketListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: BucketInstance[]) => any): Promise<BucketInstance[]>;
list(params: BucketListInstanceOptions, callback?: (error: Error | null, items: BucketInstance[]) => any): Promise<BucketInstance[]>;
/**
* Lists BucketInstance records from the API as a list with HTTP metadata.
*
* Returns all records along with HTTP metadata from the first page fetched.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { BucketListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<BucketInstance[]>) => any): Promise<ApiResponse<BucketInstance[]>>;
listWithHttpInfo(params: BucketListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<BucketInstance[]>) => any): Promise<ApiResponse<BucketInstance[]>>;
/**
* Retrieve a single page of BucketInstance records from the API.
*
* The request is executed immediately.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { BucketListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: BucketPage) => any): Promise<BucketPage>;
page(params: BucketListInstancePageOptions, callback?: (error: Error | null, items: BucketPage) => any): Promise<BucketPage>;
/**
* Retrieve a single page of BucketInstance records from the API with HTTP metadata.
*
* The request is executed immediately.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { BucketListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<BucketPage>) => any): Promise<ApiResponse<BucketPage>>;
pageWithHttpInfo(params: BucketListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<BucketPage>) => any): Promise<ApiResponse<BucketPage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function BucketListInstance(version: V2, serviceSid: string, rateLimitSid: string): BucketListInstance;
export declare class BucketPage extends Page<V2, BucketPayload, BucketResource, BucketInstance> {
/**
* Initialize the BucketPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V2, response: Response<string>, solution: BucketSolution);
/**
* Build an instance of BucketInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: BucketResource): BucketInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

View File

@@ -0,0 +1,449 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Verify
* 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.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BucketPage = exports.BucketInstance = exports.BucketContextImpl = void 0;
exports.BucketListInstance = BucketListInstance;
const util_1 = require("util");
const Page_1 = __importDefault(require("../../../../../base/Page"));
const deserialize = require("../../../../../base/deserialize");
const serialize = require("../../../../../base/serialize");
const utility_1 = require("../../../../../base/utility");
class BucketContextImpl {
constructor(_version, serviceSid, rateLimitSid, sid) {
this._version = _version;
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(rateLimitSid)) {
throw new Error("Parameter 'rateLimitSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(sid)) {
throw new Error("Parameter 'sid' is not valid.");
}
this._solution = { serviceSid, rateLimitSid, sid };
this._uri = `/Services/${serviceSid}/RateLimits/${rateLimitSid}/Buckets/${sid}`;
}
remove(callback) {
const headers = {};
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.remove({
uri: instance._uri,
method: "delete",
headers,
});
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
removeWithHttpInfo(callback) {
const headers = {};
const instance = this;
let operationVersion = instance._version;
// DELETE operation - returns boolean based on status code
let operationPromise = operationVersion
.removeWithResponseInfo({ uri: instance._uri, method: "delete", headers })
.then((response) => ({
...response,
body: response.statusCode === 204,
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
fetch(callback) {
const headers = {};
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.fetch({
uri: instance._uri,
method: "get",
headers,
});
operationPromise = operationPromise.then((payload) => new BucketInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.rateLimitSid, instance._solution.sid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
fetchWithHttpInfo(callback) {
const headers = {};
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.fetchWithResponseInfo({
uri: instance._uri,
method: "get",
headers,
})
.then((response) => ({
...response,
body: new BucketInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.rateLimitSid, instance._solution.sid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
update(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["max"] !== undefined)
data["Max"] = params["max"];
if (params["interval"] !== undefined)
data["Interval"] = params["interval"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.update({
uri: instance._uri,
method: "post",
data,
headers,
});
operationPromise = operationPromise.then((payload) => new BucketInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.rateLimitSid, instance._solution.sid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
updateWithHttpInfo(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["max"] !== undefined)
data["Max"] = params["max"];
if (params["interval"] !== undefined)
data["Interval"] = params["interval"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.updateWithResponseInfo({
uri: instance._uri,
method: "post",
data,
headers,
})
.then((response) => ({
...response,
body: new BucketInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.rateLimitSid, instance._solution.sid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return this._solution;
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.BucketContextImpl = BucketContextImpl;
class BucketInstance {
constructor(_version, payload, serviceSid, rateLimitSid, sid) {
this._version = _version;
this.sid = payload.sid;
this.rateLimitSid = payload.rate_limit_sid;
this.serviceSid = payload.service_sid;
this.accountSid = payload.account_sid;
this.max = deserialize.integer(payload.max);
this.interval = deserialize.integer(payload.interval);
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.url = payload.url;
this._solution = { serviceSid, rateLimitSid, sid: sid || this.sid };
}
get _proxy() {
this._context =
this._context ||
new BucketContextImpl(this._version, this._solution.serviceSid, this._solution.rateLimitSid, this._solution.sid);
return this._context;
}
/**
* Remove a BucketInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback) {
return this._proxy.remove(callback);
}
/**
* Remove a BucketInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean with HTTP metadata
*/
removeWithHttpInfo(callback) {
return this._proxy.removeWithHttpInfo(callback);
}
/**
* Fetch a BucketInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed BucketInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a BucketInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed BucketInstance with HTTP metadata
*/
fetchWithHttpInfo(callback) {
return this._proxy.fetchWithHttpInfo(callback);
}
update(params, callback) {
return this._proxy.update(params, callback);
}
updateWithHttpInfo(params, callback) {
return this._proxy.updateWithHttpInfo(params, callback);
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
sid: this.sid,
rateLimitSid: this.rateLimitSid,
serviceSid: this.serviceSid,
accountSid: this.accountSid,
max: this.max,
interval: this.interval,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
url: this.url,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.BucketInstance = BucketInstance;
function BucketListInstance(version, serviceSid, rateLimitSid) {
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(rateLimitSid)) {
throw new Error("Parameter 'rateLimitSid' is not valid.");
}
const instance = ((sid) => instance.get(sid));
instance.get = function get(sid) {
return new BucketContextImpl(version, serviceSid, rateLimitSid, sid);
};
instance._version = version;
instance._solution = { serviceSid, rateLimitSid };
instance._uri = `/Services/${serviceSid}/RateLimits/${rateLimitSid}/Buckets`;
instance.create = function create(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["max"] === null || params["max"] === undefined) {
throw new Error("Required parameter \"params['max']\" missing.");
}
if (params["interval"] === null || params["interval"] === undefined) {
throw new Error("Required parameter \"params['interval']\" missing.");
}
let data = {};
data["Max"] = params["max"];
data["Interval"] = params["interval"];
const headers = {};
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 BucketInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.rateLimitSid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.createWithHttpInfo = function createWithHttpInfo(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["max"] === null || params["max"] === undefined) {
throw new Error("Required parameter \"params['max']\" missing.");
}
if (params["interval"] === null || params["interval"] === undefined) {
throw new Error("Required parameter \"params['interval']\" missing.");
}
let data = {};
data["Max"] = params["max"];
data["Interval"] = params["interval"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
let operationVersion = version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.createWithResponseInfo({
uri: instance._uri,
method: "post",
data,
headers,
})
.then((response) => ({
...response,
body: new BucketInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.rateLimitSid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.page = function page(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["pageSize"] !== undefined)
data["PageSize"] = params["pageSize"];
if (params.pageNumber !== undefined)
data["Page"] = params.pageNumber;
if (params.pageToken !== undefined)
data["PageToken"] = params.pageToken;
const headers = {};
headers["Accept"] = "application/json";
let operationVersion = version, operationPromise = operationVersion.page({
uri: instance._uri,
method: "get",
params: data,
headers,
});
operationPromise = operationPromise.then((payload) => new BucketPage(operationVersion, payload, instance._solution));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.each = instance._version.each;
instance.list = instance._version.list;
instance.getPage = function getPage(targetUrl, callback) {
const operationPromise = instance._version._domain.twilio.request({
method: "get",
uri: targetUrl,
});
let pagePromise = operationPromise.then((payload) => new BucketPage(instance._version, payload, instance._solution));
pagePromise = instance._version.setPromiseCallback(pagePromise, callback);
return pagePromise;
};
instance.pageWithHttpInfo = function pageWithHttpInfo(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["pageSize"] !== undefined)
data["PageSize"] = params["pageSize"];
if (params.pageNumber !== undefined)
data["Page"] = params.pageNumber;
if (params.pageToken !== undefined)
data["PageToken"] = params.pageToken;
const headers = {};
headers["Accept"] = "application/json";
let operationVersion = version;
// For page operations, use page() directly as it already returns { statusCode, body, headers }
// IMPORTANT: Pass full response to Page constructor, not response.body
let operationPromise = operationVersion
.page({ uri: instance._uri, method: "get", params: data, headers })
.then((response) => ({
statusCode: response.statusCode,
headers: response.headers,
body: new BucketPage(operationVersion, response, instance._solution),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.each = instance._version.each;
instance.eachWithHttpInfo = instance._version.eachWithHttpInfo;
instance.list = instance._version.list;
instance.listWithHttpInfo = instance._version.listWithHttpInfo;
instance.getPageWithHttpInfo = function getPageWithHttpInfo(targetUrl, callback) {
// Use request() directly as it already returns { statusCode, body, headers }
const operationPromise = instance._version._domain.twilio.request({
method: "get",
uri: targetUrl,
});
let pagePromise = operationPromise.then((response) => ({
statusCode: response.statusCode,
headers: response.headers,
body: new BucketPage(instance._version, response, instance._solution),
}));
pagePromise = instance._version.setPromiseCallback(pagePromise, callback);
return pagePromise;
};
instance.toJSON = function toJSON() {
return instance._solution;
};
instance[util_1.inspect.custom] = function inspectImpl(_depth, options) {
return (0, util_1.inspect)(instance.toJSON(), options);
};
return instance;
}
class BucketPage extends Page_1.default {
/**
* Initialize the BucketPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version, response, solution) {
super(version, response, solution);
}
/**
* Build an instance of BucketInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new BucketInstance(this._version, payload, this._solution.serviceSid, this._solution.rateLimitSid);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.BucketPage = BucketPage;

View File

@@ -0,0 +1,298 @@
import { inspect, InspectOptions } from "util";
import V2 from "../../V2";
import { ApiResponse } from "../../../../base/ApiResponse";
/**
* The verification method used. One of: [`email`](https://www.twilio.com/docs/verify/email), `sms`, `whatsapp`, `call`, `sna`, or `rcs`.
*/
export type VerificationChannel = "sms" | "call" | "email" | "whatsapp" | "sna";
/**
* Risk_check overrides Fraud Prevention measures like Fraud Guard, Geo Permissions etc per verification attempt basis, allowing Verify to block traffic considered fraudulent if enabled or bypass active protections if disabled. Can be: `enable`(default) or `disable`. For SMS channel only.
*/
export type VerificationRiskCheck = "enable" | "disable";
/**
* The status of the verification. Can be: `pending`, `approved`, `canceled`, `max_attempts_reached`, `deleted`, `failed` or `expired`.
*/
export type VerificationStatus = "canceled" | "approved";
/**
* Options to pass to update a VerificationInstance
*/
export interface VerificationContextUpdateOptions {
/** */
status: VerificationStatus;
}
/**
* Options to pass to create a VerificationInstance
*/
export interface VerificationListInstanceCreateOptions {
/** The phone number or [email](https://www.twilio.com/docs/verify/email) to verify. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164). */
to: string;
/** The verification method to use. One of: [`email`](https://www.twilio.com/docs/verify/email), `sms`, `whatsapp`, `call`, `sna` or `auto`. */
channel: string;
/** A custom user defined friendly name that overwrites the existing one in the verification message */
customFriendlyName?: string;
/** The text of a custom message to use for the verification [DEPRECATED]. */
customMessage?: string;
/** The digits to send after a phone call is answered, for example, to dial an extension. For more information, see the Programmable Voice documentation of [sendDigits](https://www.twilio.com/docs/voice/twiml/number#attributes-sendDigits). */
sendDigits?: string;
/** Locale will automatically resolve based on phone number country code for SMS, WhatsApp, and call channel verifications. It will fallback to English or the templates default translation if the selected translation is not available. This parameter will override the automatic locale resolution. [See supported languages and more information here](https://www.twilio.com/docs/verify/supported-languages). */
locale?: string;
/** A pre-generated code to use for verification. The code can be between 4 and 10 characters, inclusive. */
customCode?: string;
/** The amount of the associated PSD2 compliant transaction. Requires the PSD2 Service flag enabled. */
amount?: string;
/** The payee of the associated PSD2 compliant transaction. Requires the PSD2 Service flag enabled. */
payee?: string;
/** The custom key-value pairs of Programmable Rate Limits. Keys correspond to `unique_name` fields defined when [creating your Rate Limit](https://www.twilio.com/docs/verify/api/service-rate-limits). Associated value pairs represent values in the request that you are rate limiting on. You may include multiple Rate Limit values in each request. */
rateLimits?: any;
/** [`email`](https://www.twilio.com/docs/verify/email) channel configuration in json format. The fields \\\'from\\\' and \\\'from_name\\\' are optional but if included the \\\'from\\\' field must have a valid email address. */
channelConfiguration?: any;
/** Your [App Hash](https://developers.google.com/identity/sms-retriever/verify#computing_your_apps_hash_string) to be appended at the end of your verification SMS body. Applies only to SMS. Example SMS body: `<#> Your AppName verification code is: 1234 He42w354ol9`. */
appHash?: string;
/** The message [template](https://www.twilio.com/docs/verify/api/templates). If provided, will override the default template for the Service. SMS and Voice channels only. */
templateSid?: string;
/** A stringified JSON object in which the keys are the template\\\'s special variables and the values are the variables substitutions. */
templateCustomSubstitutions?: string;
/** Strongly encouraged if using the auto channel. The IP address of the client\\\'s device. If provided, it has to be a valid IPv4 or IPv6 address. */
deviceIp?: string;
/** An optional Boolean value to indicate the requirement of sna client token in the SNA URL invocation response for added security. This token must match in the Verification Check request to confirm phone number verification. */
enableSnaClientToken?: boolean;
/** */
riskCheck?: VerificationRiskCheck;
/** A string containing a JSON map of key value pairs of tags to be recorded as metadata for the message. The object may contain up to 10 tags. Keys and values can each be up to 128 characters in length. */
tags?: string;
}
export interface VerificationContext {
/**
* Fetch a VerificationInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed VerificationInstance
*/
fetch(callback?: (error: Error | null, item?: VerificationInstance) => any): Promise<VerificationInstance>;
/**
* Fetch a VerificationInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed VerificationInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<VerificationInstance>) => any): Promise<ApiResponse<VerificationInstance>>;
/**
* Update a VerificationInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed VerificationInstance
*/
update(params: VerificationContextUpdateOptions, callback?: (error: Error | null, item?: VerificationInstance) => any): Promise<VerificationInstance>;
/**
* Update a VerificationInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed VerificationInstance with HTTP metadata
*/
updateWithHttpInfo(params: VerificationContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<VerificationInstance>) => any): Promise<ApiResponse<VerificationInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface VerificationContextSolution {
serviceSid: string;
sid: string;
}
export declare class VerificationContextImpl implements VerificationContext {
protected _version: V2;
protected _solution: VerificationContextSolution;
protected _uri: string;
constructor(_version: V2, serviceSid: string, sid: string);
fetch(callback?: (error: Error | null, item?: VerificationInstance) => any): Promise<VerificationInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<VerificationInstance>) => any): Promise<ApiResponse<VerificationInstance>>;
update(params: VerificationContextUpdateOptions, callback?: (error: Error | null, item?: VerificationInstance) => any): Promise<VerificationInstance>;
updateWithHttpInfo(params: VerificationContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<VerificationInstance>) => any): Promise<ApiResponse<VerificationInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): VerificationContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface VerificationResource {
sid: string;
service_sid: string;
account_sid: string;
to: string;
channel: VerificationChannel;
status: string;
valid: boolean;
lookup: any;
amount: string;
payee: string;
send_code_attempts: Array<any>;
date_created: Date;
date_updated: Date;
sna: any;
url: string;
}
export declare class VerificationInstance {
protected _version: V2;
protected _solution: VerificationContextSolution;
protected _context?: VerificationContext;
constructor(_version: V2, payload: VerificationResource, serviceSid: string, sid?: string);
/**
* The unique string that we created to identify the Verification resource.
*/
sid: string;
/**
* The SID of the [Service](https://www.twilio.com/docs/verify/api/service) the resource is associated with.
*/
serviceSid: string;
/**
* The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Verification resource.
*/
accountSid: string;
/**
* The phone number or [email](https://www.twilio.com/docs/verify/email) being verified. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164).
*/
to: string;
channel: VerificationChannel;
/**
* The status of the verification. Can be: `pending`, `approved`, `canceled`, `max_attempts_reached`, `deleted`, `failed` or `expired`.
*/
status: string;
/**
* Use \"status\" instead. Legacy property indicating whether the verification was successful.
*/
valid: boolean;
/**
* Information about the phone number being verified.
*/
lookup: any;
/**
* The amount of the associated PSD2 compliant transaction. Requires the PSD2 Service flag enabled.
*/
amount: string;
/**
* The payee of the associated PSD2 compliant transaction. Requires the PSD2 Service flag enabled.
*/
payee: string;
/**
* An array of verification attempt objects containing the channel attempted and the channel-specific transaction SID.
*/
sendCodeAttempts: Array<any>;
/**
* The date and time in GMT when the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
*/
dateCreated: Date;
/**
* The date and time in GMT when the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format.
*/
dateUpdated: Date;
/**
* The set of fields used for a silent network auth (`sna`) verification. Contains a single field with the URL to be invoked to verify the phone number.
*/
sna: any;
/**
* The absolute URL of the Verification resource.
*/
url: string;
private get _proxy();
/**
* Fetch a VerificationInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed VerificationInstance
*/
fetch(callback?: (error: Error | null, item?: VerificationInstance) => any): Promise<VerificationInstance>;
/**
* Fetch a VerificationInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed VerificationInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<VerificationInstance>) => any): Promise<ApiResponse<VerificationInstance>>;
/**
* Update a VerificationInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed VerificationInstance
*/
update(params: VerificationContextUpdateOptions, callback?: (error: Error | null, item?: VerificationInstance) => any): Promise<VerificationInstance>;
/**
* Update a VerificationInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed VerificationInstance with HTTP metadata
*/
updateWithHttpInfo(params: VerificationContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<VerificationInstance>) => any): Promise<ApiResponse<VerificationInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
serviceSid: string;
accountSid: string;
to: string;
channel: VerificationChannel;
status: string;
valid: boolean;
lookup: any;
amount: string;
payee: string;
sendCodeAttempts: any[];
dateCreated: Date;
dateUpdated: Date;
sna: any;
url: string;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface VerificationSolution {
serviceSid: string;
}
export interface VerificationListInstance {
_version: V2;
_solution: VerificationSolution;
_uri: string;
(sid: string): VerificationContext;
get(sid: string): VerificationContext;
/**
* Create a VerificationInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed VerificationInstance
*/
create(params: VerificationListInstanceCreateOptions, callback?: (error: Error | null, item?: VerificationInstance) => any): Promise<VerificationInstance>;
/**
* Create a VerificationInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed VerificationInstance with HTTP metadata
*/
createWithHttpInfo(params: VerificationListInstanceCreateOptions, callback?: (error: Error | null, item?: ApiResponse<VerificationInstance>) => any): Promise<ApiResponse<VerificationInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function VerificationListInstance(version: V2, serviceSid: string): VerificationListInstance;
export {};

View File

@@ -0,0 +1,354 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Verify
* 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.VerificationInstance = exports.VerificationContextImpl = void 0;
exports.VerificationListInstance = VerificationListInstance;
const util_1 = require("util");
const deserialize = require("../../../../base/deserialize");
const serialize = require("../../../../base/serialize");
const utility_1 = require("../../../../base/utility");
class VerificationContextImpl {
constructor(_version, serviceSid, sid) {
this._version = _version;
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(sid)) {
throw new Error("Parameter 'sid' is not valid.");
}
this._solution = { serviceSid, sid };
this._uri = `/Services/${serviceSid}/Verifications/${sid}`;
}
fetch(callback) {
const headers = {};
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.fetch({
uri: instance._uri,
method: "get",
headers,
});
operationPromise = operationPromise.then((payload) => new VerificationInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.sid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
fetchWithHttpInfo(callback) {
const headers = {};
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.fetchWithResponseInfo({
uri: instance._uri,
method: "get",
headers,
})
.then((response) => ({
...response,
body: new VerificationInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.sid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
update(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["status"] === null || params["status"] === undefined) {
throw new Error("Required parameter \"params['status']\" missing.");
}
let data = {};
data["Status"] = params["status"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.update({
uri: instance._uri,
method: "post",
data,
headers,
});
operationPromise = operationPromise.then((payload) => new VerificationInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.sid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
updateWithHttpInfo(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["status"] === null || params["status"] === undefined) {
throw new Error("Required parameter \"params['status']\" missing.");
}
let data = {};
data["Status"] = params["status"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.updateWithResponseInfo({
uri: instance._uri,
method: "post",
data,
headers,
})
.then((response) => ({
...response,
body: new VerificationInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.sid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return this._solution;
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.VerificationContextImpl = VerificationContextImpl;
class VerificationInstance {
constructor(_version, payload, serviceSid, sid) {
this._version = _version;
this.sid = payload.sid;
this.serviceSid = payload.service_sid;
this.accountSid = payload.account_sid;
this.to = payload.to;
this.channel = payload.channel;
this.status = payload.status;
this.valid = payload.valid;
this.lookup = payload.lookup;
this.amount = payload.amount;
this.payee = payload.payee;
this.sendCodeAttempts = payload.send_code_attempts;
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.sna = payload.sna;
this.url = payload.url;
this._solution = { serviceSid, sid: sid || this.sid };
}
get _proxy() {
this._context =
this._context ||
new VerificationContextImpl(this._version, this._solution.serviceSid, this._solution.sid);
return this._context;
}
/**
* Fetch a VerificationInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed VerificationInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a VerificationInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed VerificationInstance with HTTP metadata
*/
fetchWithHttpInfo(callback) {
return this._proxy.fetchWithHttpInfo(callback);
}
update(params, callback) {
return this._proxy.update(params, callback);
}
updateWithHttpInfo(params, callback) {
return this._proxy.updateWithHttpInfo(params, callback);
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
sid: this.sid,
serviceSid: this.serviceSid,
accountSid: this.accountSid,
to: this.to,
channel: this.channel,
status: this.status,
valid: this.valid,
lookup: this.lookup,
amount: this.amount,
payee: this.payee,
sendCodeAttempts: this.sendCodeAttempts,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
sna: this.sna,
url: this.url,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.VerificationInstance = VerificationInstance;
function VerificationListInstance(version, serviceSid) {
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
const instance = ((sid) => instance.get(sid));
instance.get = function get(sid) {
return new VerificationContextImpl(version, serviceSid, sid);
};
instance._version = version;
instance._solution = { serviceSid };
instance._uri = `/Services/${serviceSid}/Verifications`;
instance.create = function create(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["to"] === null || params["to"] === undefined) {
throw new Error("Required parameter \"params['to']\" missing.");
}
if (params["channel"] === null || params["channel"] === undefined) {
throw new Error("Required parameter \"params['channel']\" missing.");
}
let data = {};
data["To"] = params["to"];
data["Channel"] = params["channel"];
if (params["customFriendlyName"] !== undefined)
data["CustomFriendlyName"] = params["customFriendlyName"];
if (params["customMessage"] !== undefined)
data["CustomMessage"] = params["customMessage"];
if (params["sendDigits"] !== undefined)
data["SendDigits"] = params["sendDigits"];
if (params["locale"] !== undefined)
data["Locale"] = params["locale"];
if (params["customCode"] !== undefined)
data["CustomCode"] = params["customCode"];
if (params["amount"] !== undefined)
data["Amount"] = params["amount"];
if (params["payee"] !== undefined)
data["Payee"] = params["payee"];
if (params["rateLimits"] !== undefined)
data["RateLimits"] = serialize.object(params["rateLimits"]);
if (params["channelConfiguration"] !== undefined)
data["ChannelConfiguration"] = serialize.object(params["channelConfiguration"]);
if (params["appHash"] !== undefined)
data["AppHash"] = params["appHash"];
if (params["templateSid"] !== undefined)
data["TemplateSid"] = params["templateSid"];
if (params["templateCustomSubstitutions"] !== undefined)
data["TemplateCustomSubstitutions"] =
params["templateCustomSubstitutions"];
if (params["deviceIp"] !== undefined)
data["DeviceIp"] = params["deviceIp"];
if (params["enableSnaClientToken"] !== undefined)
data["EnableSnaClientToken"] = serialize.bool(params["enableSnaClientToken"]);
if (params["riskCheck"] !== undefined)
data["RiskCheck"] = params["riskCheck"];
if (params["tags"] !== undefined)
data["Tags"] = params["tags"];
const headers = {};
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 VerificationInstance(operationVersion, payload, instance._solution.serviceSid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.createWithHttpInfo = function createWithHttpInfo(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["to"] === null || params["to"] === undefined) {
throw new Error("Required parameter \"params['to']\" missing.");
}
if (params["channel"] === null || params["channel"] === undefined) {
throw new Error("Required parameter \"params['channel']\" missing.");
}
let data = {};
data["To"] = params["to"];
data["Channel"] = params["channel"];
if (params["customFriendlyName"] !== undefined)
data["CustomFriendlyName"] = params["customFriendlyName"];
if (params["customMessage"] !== undefined)
data["CustomMessage"] = params["customMessage"];
if (params["sendDigits"] !== undefined)
data["SendDigits"] = params["sendDigits"];
if (params["locale"] !== undefined)
data["Locale"] = params["locale"];
if (params["customCode"] !== undefined)
data["CustomCode"] = params["customCode"];
if (params["amount"] !== undefined)
data["Amount"] = params["amount"];
if (params["payee"] !== undefined)
data["Payee"] = params["payee"];
if (params["rateLimits"] !== undefined)
data["RateLimits"] = serialize.object(params["rateLimits"]);
if (params["channelConfiguration"] !== undefined)
data["ChannelConfiguration"] = serialize.object(params["channelConfiguration"]);
if (params["appHash"] !== undefined)
data["AppHash"] = params["appHash"];
if (params["templateSid"] !== undefined)
data["TemplateSid"] = params["templateSid"];
if (params["templateCustomSubstitutions"] !== undefined)
data["TemplateCustomSubstitutions"] =
params["templateCustomSubstitutions"];
if (params["deviceIp"] !== undefined)
data["DeviceIp"] = params["deviceIp"];
if (params["enableSnaClientToken"] !== undefined)
data["EnableSnaClientToken"] = serialize.bool(params["enableSnaClientToken"]);
if (params["riskCheck"] !== undefined)
data["RiskCheck"] = params["riskCheck"];
if (params["tags"] !== undefined)
data["Tags"] = params["tags"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
let operationVersion = version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.createWithResponseInfo({
uri: instance._uri,
method: "post",
data,
headers,
})
.then((response) => ({
...response,
body: new VerificationInstance(operationVersion, response.body, instance._solution.serviceSid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.toJSON = function toJSON() {
return instance._solution;
};
instance[util_1.inspect.custom] = function inspectImpl(_depth, options) {
return (0, util_1.inspect)(instance.toJSON(), options);
};
return instance;
}

View File

@@ -0,0 +1,156 @@
import { inspect, InspectOptions } from "util";
import V2 from "../../V2";
import { ApiResponse } from "../../../../base/ApiResponse";
/**
* The verification method to use. One of: [`email`](https://www.twilio.com/docs/verify/email), `sms`, `whatsapp`, `call`, or `sna`.
*/
export type VerificationCheckChannel = "sms" | "call" | "email" | "whatsapp" | "sna";
/**
* Options to pass to create a VerificationCheckInstance
*/
export interface VerificationCheckListInstanceCreateOptions {
/** The 4-10 character string being verified. */
code?: string;
/** The phone number or [email](https://www.twilio.com/docs/verify/email) to verify. Either this parameter or the `verification_sid` must be specified. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164). */
to?: string;
/** A SID that uniquely identifies the Verification Check. Either this parameter or the `to` phone number/[email](https://www.twilio.com/docs/verify/email) must be specified. */
verificationSid?: string;
/** The amount of the associated PSD2 compliant transaction. Requires the PSD2 Service flag enabled. */
amount?: string;
/** The payee of the associated PSD2 compliant transaction. Requires the PSD2 Service flag enabled. */
payee?: string;
/** A sna client token received in sna url invocation response needs to be passed in Verification Check request and should match to get successful response. */
snaClientToken?: string;
}
export interface VerificationCheckSolution {
serviceSid: string;
}
export interface VerificationCheckListInstance {
_version: V2;
_solution: VerificationCheckSolution;
_uri: string;
/**
* Create a VerificationCheckInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed VerificationCheckInstance
*/
create(callback?: (error: Error | null, item?: VerificationCheckInstance) => any): Promise<VerificationCheckInstance>;
/**
* Create a VerificationCheckInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed VerificationCheckInstance
*/
create(params: VerificationCheckListInstanceCreateOptions, callback?: (error: Error | null, item?: VerificationCheckInstance) => any): Promise<VerificationCheckInstance>;
/**
* Create a VerificationCheckInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed VerificationCheckInstance with HTTP metadata
*/
createWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<VerificationCheckInstance>) => any): Promise<ApiResponse<VerificationCheckInstance>>;
/**
* Create a VerificationCheckInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed VerificationCheckInstance with HTTP metadata
*/
createWithHttpInfo(params: VerificationCheckListInstanceCreateOptions, callback?: (error: Error | null, item?: ApiResponse<VerificationCheckInstance>) => any): Promise<ApiResponse<VerificationCheckInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function VerificationCheckListInstance(version: V2, serviceSid: string): VerificationCheckListInstance;
interface VerificationCheckResource {
sid: string;
service_sid: string;
account_sid: string;
to: string;
channel: VerificationCheckChannel;
status: string;
valid: boolean;
amount: string;
payee: string;
date_created: Date;
date_updated: Date;
sna_attempts_error_codes: Array<any>;
}
export declare class VerificationCheckInstance {
protected _version: V2;
constructor(_version: V2, payload: VerificationCheckResource, serviceSid: string);
/**
* The unique string that we created to identify the VerificationCheck resource.
*/
sid: string;
/**
* The SID of the [Service](https://www.twilio.com/docs/verify/api/service) the resource is associated with.
*/
serviceSid: string;
/**
* The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the VerificationCheck resource.
*/
accountSid: string;
/**
* The phone number or [email](https://www.twilio.com/docs/verify/email) being verified. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164).
*/
to: string;
channel: VerificationCheckChannel;
/**
* The status of the verification. Can be: `pending`, `approved`, `canceled`, `max_attempts_reached`, `deleted`, `failed` or `expired`.
*/
status: string;
/**
* Use \"status\" instead. Legacy property indicating whether the verification was successful.
*/
valid: boolean;
/**
* The amount of the associated PSD2 compliant transaction. Requires the PSD2 Service flag enabled.
*/
amount: string;
/**
* The payee of the associated PSD2 compliant transaction. Requires the PSD2 Service flag enabled.
*/
payee: string;
/**
* The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time in GMT when the Verification Check resource was created.
*/
dateCreated: Date;
/**
* The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time in GMT when the Verification Check resource was last updated.
*/
dateUpdated: Date;
/**
* List of error codes as a result of attempting a verification using the `sna` channel. The error codes are chronologically ordered, from the first attempt to the latest attempt. This will be an empty list if no errors occured or `null` if the last channel used wasn\'t `sna`.
*/
snaAttemptsErrorCodes: Array<any>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
serviceSid: string;
accountSid: string;
to: string;
channel: VerificationCheckChannel;
status: string;
valid: boolean;
amount: string;
payee: string;
dateCreated: Date;
dateUpdated: Date;
snaAttemptsErrorCodes: any[];
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export {};

View File

@@ -0,0 +1,153 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Verify
* 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.VerificationCheckInstance = void 0;
exports.VerificationCheckListInstance = VerificationCheckListInstance;
const util_1 = require("util");
const deserialize = require("../../../../base/deserialize");
const serialize = require("../../../../base/serialize");
const utility_1 = require("../../../../base/utility");
function VerificationCheckListInstance(version, serviceSid) {
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
const instance = {};
instance._version = version;
instance._solution = { serviceSid };
instance._uri = `/Services/${serviceSid}/VerificationCheck`;
instance.create = function create(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["code"] !== undefined)
data["Code"] = params["code"];
if (params["to"] !== undefined)
data["To"] = params["to"];
if (params["verificationSid"] !== undefined)
data["VerificationSid"] = params["verificationSid"];
if (params["amount"] !== undefined)
data["Amount"] = params["amount"];
if (params["payee"] !== undefined)
data["Payee"] = params["payee"];
if (params["snaClientToken"] !== undefined)
data["SnaClientToken"] = params["snaClientToken"];
const headers = {};
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 VerificationCheckInstance(operationVersion, payload, instance._solution.serviceSid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.createWithHttpInfo = function createWithHttpInfo(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["code"] !== undefined)
data["Code"] = params["code"];
if (params["to"] !== undefined)
data["To"] = params["to"];
if (params["verificationSid"] !== undefined)
data["VerificationSid"] = params["verificationSid"];
if (params["amount"] !== undefined)
data["Amount"] = params["amount"];
if (params["payee"] !== undefined)
data["Payee"] = params["payee"];
if (params["snaClientToken"] !== undefined)
data["SnaClientToken"] = params["snaClientToken"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
let operationVersion = version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.createWithResponseInfo({
uri: instance._uri,
method: "post",
data,
headers,
})
.then((response) => ({
...response,
body: new VerificationCheckInstance(operationVersion, response.body, instance._solution.serviceSid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.toJSON = function toJSON() {
return instance._solution;
};
instance[util_1.inspect.custom] = function inspectImpl(_depth, options) {
return (0, util_1.inspect)(instance.toJSON(), options);
};
return instance;
}
class VerificationCheckInstance {
constructor(_version, payload, serviceSid) {
this._version = _version;
this.sid = payload.sid;
this.serviceSid = payload.service_sid;
this.accountSid = payload.account_sid;
this.to = payload.to;
this.channel = payload.channel;
this.status = payload.status;
this.valid = payload.valid;
this.amount = payload.amount;
this.payee = payload.payee;
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.snaAttemptsErrorCodes = payload.sna_attempts_error_codes;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
sid: this.sid,
serviceSid: this.serviceSid,
accountSid: this.accountSid,
to: this.to,
channel: this.channel,
status: this.status,
valid: this.valid,
amount: this.amount,
payee: this.payee,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
snaAttemptsErrorCodes: this.snaAttemptsErrorCodes,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.VerificationCheckInstance = VerificationCheckInstance;

View File

@@ -0,0 +1,479 @@
import { inspect, InspectOptions } from "util";
import Page, { TwilioResponsePayload } from "../../../../base/Page";
import Response from "../../../../http/response";
import V2 from "../../V2";
import { ApiResponse } from "../../../../base/ApiResponse";
/**
* The method to be used when calling the webhook\'s URL.
*/
export type WebhookMethods = "GET" | "POST";
/**
* The webhook status. Default value is `enabled`. One of: `enabled` or `disabled`
*/
export type WebhookStatus = "enabled" | "disabled";
/**
* The webhook version. Default value is `v2` which includes all the latest fields. Version `v1` is legacy and may be removed in the future.
*/
export type WebhookVersion = "v1" | "v2";
/**
* Options to pass to update a WebhookInstance
*/
export interface WebhookContextUpdateOptions {
/** The string that you assigned to describe the webhook. **This value should not contain PII.** */
friendlyName?: string;
/** The array of events that this Webhook is subscribed to. Possible event types: `*, factor.deleted, factor.created, factor.verified, challenge.approved, challenge.denied` */
eventTypes?: Array<string>;
/** The URL associated with this Webhook. */
webhookUrl?: string;
/** */
status?: WebhookStatus;
/** */
version?: WebhookVersion;
}
/**
* Options to pass to create a WebhookInstance
*/
export interface WebhookListInstanceCreateOptions {
/** The string that you assigned to describe the webhook. **This value should not contain PII.** */
friendlyName: string;
/** The array of events that this Webhook is subscribed to. Possible event types: `*, factor.deleted, factor.created, factor.verified, challenge.approved, challenge.denied` */
eventTypes: Array<string>;
/** The URL associated with this Webhook. */
webhookUrl: string;
/** */
status?: WebhookStatus;
/** */
version?: WebhookVersion;
}
/**
* Options to pass to each
*/
export interface WebhookListInstanceEachOptions {
/** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
pageSize?: number;
/** Function to process each record. If this and a positional callback are passed, this one will be used */
callback?: (item: WebhookInstance, done: (err?: Error) => void) => void;
/** Function to be called upon completion of streaming */
done?: Function;
/** Upper limit for the number of records to return. each() guarantees never to return more than limit. Default is no limit */
limit?: number;
}
/**
* Options to pass to list
*/
export interface WebhookListInstanceOptions {
/** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
pageSize?: number;
/** Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit */
limit?: number;
}
/**
* Options to pass to page
*/
export interface WebhookListInstancePageOptions {
/** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
pageSize?: number;
/** Page Number, this value is simply for client state */
pageNumber?: number;
/** PageToken provided by the API */
pageToken?: string;
}
export interface WebhookContext {
/**
* Remove a WebhookInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a WebhookInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean with HTTP metadata
*/
removeWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
/**
* Fetch a WebhookInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed WebhookInstance
*/
fetch(callback?: (error: Error | null, item?: WebhookInstance) => any): Promise<WebhookInstance>;
/**
* Fetch a WebhookInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed WebhookInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<WebhookInstance>) => any): Promise<ApiResponse<WebhookInstance>>;
/**
* Update a WebhookInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed WebhookInstance
*/
update(callback?: (error: Error | null, item?: WebhookInstance) => any): Promise<WebhookInstance>;
/**
* Update a WebhookInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed WebhookInstance
*/
update(params: WebhookContextUpdateOptions, callback?: (error: Error | null, item?: WebhookInstance) => any): Promise<WebhookInstance>;
/**
* Update a WebhookInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed WebhookInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<WebhookInstance>) => any): Promise<ApiResponse<WebhookInstance>>;
/**
* Update a WebhookInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed WebhookInstance with HTTP metadata
*/
updateWithHttpInfo(params: WebhookContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<WebhookInstance>) => any): Promise<ApiResponse<WebhookInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface WebhookContextSolution {
serviceSid: string;
sid: string;
}
export declare class WebhookContextImpl implements WebhookContext {
protected _version: V2;
protected _solution: WebhookContextSolution;
protected _uri: string;
constructor(_version: V2, serviceSid: string, sid: string);
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
removeWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
fetch(callback?: (error: Error | null, item?: WebhookInstance) => any): Promise<WebhookInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<WebhookInstance>) => any): Promise<ApiResponse<WebhookInstance>>;
update(params?: WebhookContextUpdateOptions | ((error: Error | null, item?: WebhookInstance) => any), callback?: (error: Error | null, item?: WebhookInstance) => any): Promise<WebhookInstance>;
updateWithHttpInfo(params?: WebhookContextUpdateOptions | ((error: Error | null, item?: ApiResponse<WebhookInstance>) => any), callback?: (error: Error | null, item?: ApiResponse<WebhookInstance>) => any): Promise<ApiResponse<WebhookInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): WebhookContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface WebhookPayload extends TwilioResponsePayload {
webhooks: WebhookResource[];
}
interface WebhookResource {
sid: string;
service_sid: string;
account_sid: string;
friendly_name: string;
event_types: Array<string>;
status: WebhookStatus;
version: WebhookVersion;
webhook_url: string;
webhook_method: WebhookMethods;
date_created: Date;
date_updated: Date;
url: string;
}
export declare class WebhookInstance {
protected _version: V2;
protected _solution: WebhookContextSolution;
protected _context?: WebhookContext;
constructor(_version: V2, payload: WebhookResource, serviceSid: string, sid?: string);
/**
* The unique string that we created to identify the Webhook resource.
*/
sid: string;
/**
* The unique SID identifier of the Service.
*/
serviceSid: string;
/**
* The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Service resource.
*/
accountSid: string;
/**
* The string that you assigned to describe the webhook. **This value should not contain PII.**
*/
friendlyName: string;
/**
* The array of events that this Webhook is subscribed to. Possible event types: `*, factor.deleted, factor.created, factor.verified, challenge.approved, challenge.denied`
*/
eventTypes: Array<string>;
status: WebhookStatus;
version: WebhookVersion;
/**
* The URL associated with this Webhook.
*/
webhookUrl: string;
webhookMethod: WebhookMethods;
/**
* The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateCreated: Date;
/**
* The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateUpdated: Date;
/**
* The absolute URL of the Webhook resource.
*/
url: string;
private get _proxy();
/**
* Remove a WebhookInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback?: (error: Error | null, item?: boolean) => any): Promise<boolean>;
/**
* Remove a WebhookInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean with HTTP metadata
*/
removeWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<boolean>) => any): Promise<ApiResponse<boolean>>;
/**
* Fetch a WebhookInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed WebhookInstance
*/
fetch(callback?: (error: Error | null, item?: WebhookInstance) => any): Promise<WebhookInstance>;
/**
* Fetch a WebhookInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed WebhookInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<WebhookInstance>) => any): Promise<ApiResponse<WebhookInstance>>;
/**
* Update a WebhookInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed WebhookInstance
*/
update(callback?: (error: Error | null, item?: WebhookInstance) => any): Promise<WebhookInstance>;
/**
* Update a WebhookInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed WebhookInstance
*/
update(params: WebhookContextUpdateOptions, callback?: (error: Error | null, item?: WebhookInstance) => any): Promise<WebhookInstance>;
/**
* Update a WebhookInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed WebhookInstance with HTTP metadata
*/
updateWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<WebhookInstance>) => any): Promise<ApiResponse<WebhookInstance>>;
/**
* Update a WebhookInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed WebhookInstance with HTTP metadata
*/
updateWithHttpInfo(params: WebhookContextUpdateOptions, callback?: (error: Error | null, item?: ApiResponse<WebhookInstance>) => any): Promise<ApiResponse<WebhookInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
serviceSid: string;
accountSid: string;
friendlyName: string;
eventTypes: string[];
status: WebhookStatus;
version: WebhookVersion;
webhookUrl: string;
webhookMethod: WebhookMethods;
dateCreated: Date;
dateUpdated: Date;
url: string;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface WebhookSolution {
serviceSid: string;
}
export interface WebhookListInstance {
_version: V2;
_solution: WebhookSolution;
_uri: string;
(sid: string): WebhookContext;
get(sid: string): WebhookContext;
/**
* Create a WebhookInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed WebhookInstance
*/
create(params: WebhookListInstanceCreateOptions, callback?: (error: Error | null, item?: WebhookInstance) => any): Promise<WebhookInstance>;
/**
* Create a WebhookInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed WebhookInstance with HTTP metadata
*/
createWithHttpInfo(params: WebhookListInstanceCreateOptions, callback?: (error: Error | null, item?: ApiResponse<WebhookInstance>) => any): Promise<ApiResponse<WebhookInstance>>;
/**
* Streams WebhookInstance records from the API.
*
* This operation lazily loads records as efficiently as possible until the limit
* is reached.
*
* The results are passed into the callback function, so this operation is memory
* efficient.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { WebhookListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: WebhookInstance, done: (err?: Error) => void) => void): void;
each(params: WebhookListInstanceEachOptions, callback?: (item: WebhookInstance, done: (err?: Error) => void) => void): void;
/**
* Streams WebhookInstance records from the API with HTTP metadata captured per page.
*
* This operation lazily loads records as efficiently as possible until the limit
* is reached. HTTP metadata (status code, headers) is captured for each page request.
*
* The results are passed into the callback function, so this operation is memory
* efficient.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { WebhookListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: WebhookInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: WebhookListInstanceEachOptions, callback?: (item: WebhookInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of WebhookInstance records from the API.
*
* The request is executed immediately.
*
* @param { string } [targetUrl] - API-generated URL for the requested results page
* @param { function } [callback] - Callback to handle list of records
*/
getPage(targetUrl: string, callback?: (error: Error | null, items: WebhookPage) => any): Promise<WebhookPage>;
/**
* Retrieve a single target page of WebhookInstance records from the API with HTTP metadata.
*
* The request is executed immediately.
*
* @param { string } [targetUrl] - API-generated URL for the requested results page
* @param { function } [callback] - Callback to handle list of records with metadata
*/
getPageWithHttpInfo(targetUrl: string, callback?: (error: Error | null, items: ApiResponse<WebhookPage>) => any): Promise<ApiResponse<WebhookPage>>;
/**
* Lists WebhookInstance records from the API as a list.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { WebhookListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: WebhookInstance[]) => any): Promise<WebhookInstance[]>;
list(params: WebhookListInstanceOptions, callback?: (error: Error | null, items: WebhookInstance[]) => any): Promise<WebhookInstance[]>;
/**
* Lists WebhookInstance records from the API as a list with HTTP metadata.
*
* Returns all records along with HTTP metadata from the first page fetched.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { WebhookListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<WebhookInstance[]>) => any): Promise<ApiResponse<WebhookInstance[]>>;
listWithHttpInfo(params: WebhookListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<WebhookInstance[]>) => any): Promise<ApiResponse<WebhookInstance[]>>;
/**
* Retrieve a single page of WebhookInstance records from the API.
*
* The request is executed immediately.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { WebhookListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: WebhookPage) => any): Promise<WebhookPage>;
page(params: WebhookListInstancePageOptions, callback?: (error: Error | null, items: WebhookPage) => any): Promise<WebhookPage>;
/**
* Retrieve a single page of WebhookInstance records from the API with HTTP metadata.
*
* The request is executed immediately.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { WebhookListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<WebhookPage>) => any): Promise<ApiResponse<WebhookPage>>;
pageWithHttpInfo(params: WebhookListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<WebhookPage>) => any): Promise<ApiResponse<WebhookPage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function WebhookListInstance(version: V2, serviceSid: string): WebhookListInstance;
export declare class WebhookPage extends Page<V2, WebhookPayload, WebhookResource, WebhookInstance> {
/**
* Initialize the WebhookPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V2, response: Response<string>, solution: WebhookSolution);
/**
* Build an instance of WebhookInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: WebhookResource): WebhookInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

View File

@@ -0,0 +1,479 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Verify
* 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.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.WebhookPage = exports.WebhookInstance = exports.WebhookContextImpl = void 0;
exports.WebhookListInstance = WebhookListInstance;
const util_1 = require("util");
const Page_1 = __importDefault(require("../../../../base/Page"));
const deserialize = require("../../../../base/deserialize");
const serialize = require("../../../../base/serialize");
const utility_1 = require("../../../../base/utility");
class WebhookContextImpl {
constructor(_version, serviceSid, sid) {
this._version = _version;
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
if (!(0, utility_1.isValidPathParam)(sid)) {
throw new Error("Parameter 'sid' is not valid.");
}
this._solution = { serviceSid, sid };
this._uri = `/Services/${serviceSid}/Webhooks/${sid}`;
}
remove(callback) {
const headers = {};
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.remove({
uri: instance._uri,
method: "delete",
headers,
});
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
removeWithHttpInfo(callback) {
const headers = {};
const instance = this;
let operationVersion = instance._version;
// DELETE operation - returns boolean based on status code
let operationPromise = operationVersion
.removeWithResponseInfo({ uri: instance._uri, method: "delete", headers })
.then((response) => ({
...response,
body: response.statusCode === 204,
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
fetch(callback) {
const headers = {};
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.fetch({
uri: instance._uri,
method: "get",
headers,
});
operationPromise = operationPromise.then((payload) => new WebhookInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.sid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
fetchWithHttpInfo(callback) {
const headers = {};
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.fetchWithResponseInfo({
uri: instance._uri,
method: "get",
headers,
})
.then((response) => ({
...response,
body: new WebhookInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.sid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
update(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
if (params["eventTypes"] !== undefined)
data["EventTypes"] = serialize.map(params["eventTypes"], (e) => e);
if (params["webhookUrl"] !== undefined)
data["WebhookUrl"] = params["webhookUrl"];
if (params["status"] !== undefined)
data["Status"] = params["status"];
if (params["version"] !== undefined)
data["Version"] = params["version"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.update({
uri: instance._uri,
method: "post",
data,
headers,
});
operationPromise = operationPromise.then((payload) => new WebhookInstance(operationVersion, payload, instance._solution.serviceSid, instance._solution.sid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
updateWithHttpInfo(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
if (params["eventTypes"] !== undefined)
data["EventTypes"] = serialize.map(params["eventTypes"], (e) => e);
if (params["webhookUrl"] !== undefined)
data["WebhookUrl"] = params["webhookUrl"];
if (params["status"] !== undefined)
data["Status"] = params["status"];
if (params["version"] !== undefined)
data["Version"] = params["version"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.updateWithResponseInfo({
uri: instance._uri,
method: "post",
data,
headers,
})
.then((response) => ({
...response,
body: new WebhookInstance(operationVersion, response.body, instance._solution.serviceSid, instance._solution.sid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return this._solution;
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.WebhookContextImpl = WebhookContextImpl;
class WebhookInstance {
constructor(_version, payload, serviceSid, sid) {
this._version = _version;
this.sid = payload.sid;
this.serviceSid = payload.service_sid;
this.accountSid = payload.account_sid;
this.friendlyName = payload.friendly_name;
this.eventTypes = payload.event_types;
this.status = payload.status;
this.version = payload.version;
this.webhookUrl = payload.webhook_url;
this.webhookMethod = payload.webhook_method;
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.url = payload.url;
this._solution = { serviceSid, sid: sid || this.sid };
}
get _proxy() {
this._context =
this._context ||
new WebhookContextImpl(this._version, this._solution.serviceSid, this._solution.sid);
return this._context;
}
/**
* Remove a WebhookInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean
*/
remove(callback) {
return this._proxy.remove(callback);
}
/**
* Remove a WebhookInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed boolean with HTTP metadata
*/
removeWithHttpInfo(callback) {
return this._proxy.removeWithHttpInfo(callback);
}
/**
* Fetch a WebhookInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed WebhookInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a WebhookInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed WebhookInstance with HTTP metadata
*/
fetchWithHttpInfo(callback) {
return this._proxy.fetchWithHttpInfo(callback);
}
update(params, callback) {
return this._proxy.update(params, callback);
}
updateWithHttpInfo(params, callback) {
return this._proxy.updateWithHttpInfo(params, callback);
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
sid: this.sid,
serviceSid: this.serviceSid,
accountSid: this.accountSid,
friendlyName: this.friendlyName,
eventTypes: this.eventTypes,
status: this.status,
version: this.version,
webhookUrl: this.webhookUrl,
webhookMethod: this.webhookMethod,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
url: this.url,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.WebhookInstance = WebhookInstance;
function WebhookListInstance(version, serviceSid) {
if (!(0, utility_1.isValidPathParam)(serviceSid)) {
throw new Error("Parameter 'serviceSid' is not valid.");
}
const instance = ((sid) => instance.get(sid));
instance.get = function get(sid) {
return new WebhookContextImpl(version, serviceSid, sid);
};
instance._version = version;
instance._solution = { serviceSid };
instance._uri = `/Services/${serviceSid}/Webhooks`;
instance.create = function create(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["friendlyName"] === null ||
params["friendlyName"] === undefined) {
throw new Error("Required parameter \"params['friendlyName']\" missing.");
}
if (params["eventTypes"] === null || params["eventTypes"] === undefined) {
throw new Error("Required parameter \"params['eventTypes']\" missing.");
}
if (params["webhookUrl"] === null || params["webhookUrl"] === undefined) {
throw new Error("Required parameter \"params['webhookUrl']\" missing.");
}
let data = {};
data["FriendlyName"] = params["friendlyName"];
data["EventTypes"] = serialize.map(params["eventTypes"], (e) => e);
data["WebhookUrl"] = params["webhookUrl"];
if (params["status"] !== undefined)
data["Status"] = params["status"];
if (params["version"] !== undefined)
data["Version"] = params["version"];
const headers = {};
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 WebhookInstance(operationVersion, payload, instance._solution.serviceSid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.createWithHttpInfo = function createWithHttpInfo(params, callback) {
if (params === null || params === undefined) {
throw new Error('Required parameter "params" missing.');
}
if (params["friendlyName"] === null ||
params["friendlyName"] === undefined) {
throw new Error("Required parameter \"params['friendlyName']\" missing.");
}
if (params["eventTypes"] === null || params["eventTypes"] === undefined) {
throw new Error("Required parameter \"params['eventTypes']\" missing.");
}
if (params["webhookUrl"] === null || params["webhookUrl"] === undefined) {
throw new Error("Required parameter \"params['webhookUrl']\" missing.");
}
let data = {};
data["FriendlyName"] = params["friendlyName"];
data["EventTypes"] = serialize.map(params["eventTypes"], (e) => e);
data["WebhookUrl"] = params["webhookUrl"];
if (params["status"] !== undefined)
data["Status"] = params["status"];
if (params["version"] !== undefined)
data["Version"] = params["version"];
const headers = {};
headers["Content-Type"] = "application/x-www-form-urlencoded";
headers["Accept"] = "application/json";
let operationVersion = version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.createWithResponseInfo({
uri: instance._uri,
method: "post",
data,
headers,
})
.then((response) => ({
...response,
body: new WebhookInstance(operationVersion, response.body, instance._solution.serviceSid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.page = function page(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["pageSize"] !== undefined)
data["PageSize"] = params["pageSize"];
if (params.pageNumber !== undefined)
data["Page"] = params.pageNumber;
if (params.pageToken !== undefined)
data["PageToken"] = params.pageToken;
const headers = {};
headers["Accept"] = "application/json";
let operationVersion = version, operationPromise = operationVersion.page({
uri: instance._uri,
method: "get",
params: data,
headers,
});
operationPromise = operationPromise.then((payload) => new WebhookPage(operationVersion, payload, instance._solution));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.each = instance._version.each;
instance.list = instance._version.list;
instance.getPage = function getPage(targetUrl, callback) {
const operationPromise = instance._version._domain.twilio.request({
method: "get",
uri: targetUrl,
});
let pagePromise = operationPromise.then((payload) => new WebhookPage(instance._version, payload, instance._solution));
pagePromise = instance._version.setPromiseCallback(pagePromise, callback);
return pagePromise;
};
instance.pageWithHttpInfo = function pageWithHttpInfo(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["pageSize"] !== undefined)
data["PageSize"] = params["pageSize"];
if (params.pageNumber !== undefined)
data["Page"] = params.pageNumber;
if (params.pageToken !== undefined)
data["PageToken"] = params.pageToken;
const headers = {};
headers["Accept"] = "application/json";
let operationVersion = version;
// For page operations, use page() directly as it already returns { statusCode, body, headers }
// IMPORTANT: Pass full response to Page constructor, not response.body
let operationPromise = operationVersion
.page({ uri: instance._uri, method: "get", params: data, headers })
.then((response) => ({
statusCode: response.statusCode,
headers: response.headers,
body: new WebhookPage(operationVersion, response, instance._solution),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.each = instance._version.each;
instance.eachWithHttpInfo = instance._version.eachWithHttpInfo;
instance.list = instance._version.list;
instance.listWithHttpInfo = instance._version.listWithHttpInfo;
instance.getPageWithHttpInfo = function getPageWithHttpInfo(targetUrl, callback) {
// Use request() directly as it already returns { statusCode, body, headers }
const operationPromise = instance._version._domain.twilio.request({
method: "get",
uri: targetUrl,
});
let pagePromise = operationPromise.then((response) => ({
statusCode: response.statusCode,
headers: response.headers,
body: new WebhookPage(instance._version, response, instance._solution),
}));
pagePromise = instance._version.setPromiseCallback(pagePromise, callback);
return pagePromise;
};
instance.toJSON = function toJSON() {
return instance._solution;
};
instance[util_1.inspect.custom] = function inspectImpl(_depth, options) {
return (0, util_1.inspect)(instance.toJSON(), options);
};
return instance;
}
class WebhookPage extends Page_1.default {
/**
* Initialize the WebhookPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version, response, solution) {
super(version, response, solution);
}
/**
* Build an instance of WebhookInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new WebhookInstance(this._version, payload, this._solution.serviceSid);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.WebhookPage = WebhookPage;

224
node_modules/twilio/lib/rest/verify/v2/template.d.ts generated vendored Normal file
View File

@@ -0,0 +1,224 @@
import { inspect, InspectOptions } from "util";
import Page, { TwilioResponsePayload } from "../../../base/Page";
import Response from "../../../http/response";
import V2 from "../V2";
import { ApiResponse } from "../../../base/ApiResponse";
/**
* Options to pass to each
*/
export interface TemplateListInstanceEachOptions {
/** String filter used to query templates with a given friendly name. */
friendlyName?: string;
/** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
pageSize?: number;
/** Function to process each record. If this and a positional callback are passed, this one will be used */
callback?: (item: TemplateInstance, done: (err?: Error) => void) => void;
/** Function to be called upon completion of streaming */
done?: Function;
/** Upper limit for the number of records to return. each() guarantees never to return more than limit. Default is no limit */
limit?: number;
}
/**
* Options to pass to list
*/
export interface TemplateListInstanceOptions {
/** String filter used to query templates with a given friendly name. */
friendlyName?: string;
/** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
pageSize?: number;
/** Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit */
limit?: number;
}
/**
* Options to pass to page
*/
export interface TemplateListInstancePageOptions {
/** String filter used to query templates with a given friendly name. */
friendlyName?: string;
/** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
pageSize?: number;
/** Page Number, this value is simply for client state */
pageNumber?: number;
/** PageToken provided by the API */
pageToken?: string;
}
export interface TemplateSolution {
}
export interface TemplateListInstance {
_version: V2;
_solution: TemplateSolution;
_uri: string;
/**
* Streams TemplateInstance records from the API.
*
* This operation lazily loads records as efficiently as possible until the limit
* is reached.
*
* The results are passed into the callback function, so this operation is memory
* efficient.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { TemplateListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: TemplateInstance, done: (err?: Error) => void) => void): void;
each(params: TemplateListInstanceEachOptions, callback?: (item: TemplateInstance, done: (err?: Error) => void) => void): void;
/**
* Streams TemplateInstance records from the API with HTTP metadata captured per page.
*
* This operation lazily loads records as efficiently as possible until the limit
* is reached. HTTP metadata (status code, headers) is captured for each page request.
*
* The results are passed into the callback function, so this operation is memory
* efficient.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { TemplateListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: TemplateInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: TemplateListInstanceEachOptions, callback?: (item: TemplateInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of TemplateInstance records from the API.
*
* The request is executed immediately.
*
* @param { string } [targetUrl] - API-generated URL for the requested results page
* @param { function } [callback] - Callback to handle list of records
*/
getPage(targetUrl: string, callback?: (error: Error | null, items: TemplatePage) => any): Promise<TemplatePage>;
/**
* Retrieve a single target page of TemplateInstance records from the API with HTTP metadata.
*
* The request is executed immediately.
*
* @param { string } [targetUrl] - API-generated URL for the requested results page
* @param { function } [callback] - Callback to handle list of records with metadata
*/
getPageWithHttpInfo(targetUrl: string, callback?: (error: Error | null, items: ApiResponse<TemplatePage>) => any): Promise<ApiResponse<TemplatePage>>;
/**
* Lists TemplateInstance records from the API as a list.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { TemplateListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: TemplateInstance[]) => any): Promise<TemplateInstance[]>;
list(params: TemplateListInstanceOptions, callback?: (error: Error | null, items: TemplateInstance[]) => any): Promise<TemplateInstance[]>;
/**
* Lists TemplateInstance records from the API as a list with HTTP metadata.
*
* Returns all records along with HTTP metadata from the first page fetched.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { TemplateListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<TemplateInstance[]>) => any): Promise<ApiResponse<TemplateInstance[]>>;
listWithHttpInfo(params: TemplateListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<TemplateInstance[]>) => any): Promise<ApiResponse<TemplateInstance[]>>;
/**
* Retrieve a single page of TemplateInstance records from the API.
*
* The request is executed immediately.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { TemplateListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: TemplatePage) => any): Promise<TemplatePage>;
page(params: TemplateListInstancePageOptions, callback?: (error: Error | null, items: TemplatePage) => any): Promise<TemplatePage>;
/**
* Retrieve a single page of TemplateInstance records from the API with HTTP metadata.
*
* The request is executed immediately.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { TemplateListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<TemplatePage>) => any): Promise<ApiResponse<TemplatePage>>;
pageWithHttpInfo(params: TemplateListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<TemplatePage>) => any): Promise<ApiResponse<TemplatePage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function TemplateListInstance(version: V2): TemplateListInstance;
interface TemplatePayload extends TwilioResponsePayload {
templates: TemplateResource[];
}
interface TemplateResource {
sid: string;
account_sid: string;
friendly_name: string;
channels: Array<string>;
translations: any;
}
export declare class TemplateInstance {
protected _version: V2;
constructor(_version: V2, payload: TemplateResource);
/**
* A 34 character string that uniquely identifies a Verification Template.
*/
sid: string;
/**
* The unique SID identifier of the Account.
*/
accountSid: string;
/**
* A descriptive string that you create to describe a Template. It can be up to 32 characters long.
*/
friendlyName: string;
/**
* A list of channels that support the Template. Can include: sms, voice.
*/
channels: Array<string>;
/**
* An object that contains the different translations of the template. Every translation is identified by the language short name and contains its respective information as the approval status, text and created/modified date.
*/
translations: any;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
accountSid: string;
friendlyName: string;
channels: string[];
translations: any;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export declare class TemplatePage extends Page<V2, TemplatePayload, TemplateResource, TemplateInstance> {
/**
* Initialize the TemplatePage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V2, response: Response<string>, solution: TemplateSolution);
/**
* Build an instance of TemplateInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: TemplateResource): TemplateInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

179
node_modules/twilio/lib/rest/verify/v2/template.js generated vendored Normal file
View File

@@ -0,0 +1,179 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Verify
* 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.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TemplatePage = exports.TemplateInstance = void 0;
exports.TemplateListInstance = TemplateListInstance;
const util_1 = require("util");
const Page_1 = __importDefault(require("../../../base/Page"));
const deserialize = require("../../../base/deserialize");
const serialize = require("../../../base/serialize");
function TemplateListInstance(version) {
const instance = {};
instance._version = version;
instance._solution = {};
instance._uri = `/Templates`;
instance.page = function page(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
if (params["pageSize"] !== undefined)
data["PageSize"] = params["pageSize"];
if (params.pageNumber !== undefined)
data["Page"] = params.pageNumber;
if (params.pageToken !== undefined)
data["PageToken"] = params.pageToken;
const headers = {};
headers["Accept"] = "application/json";
let operationVersion = version, operationPromise = operationVersion.page({
uri: instance._uri,
method: "get",
params: data,
headers,
});
operationPromise = operationPromise.then((payload) => new TemplatePage(operationVersion, payload, instance._solution));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.each = instance._version.each;
instance.list = instance._version.list;
instance.getPage = function getPage(targetUrl, callback) {
const operationPromise = instance._version._domain.twilio.request({
method: "get",
uri: targetUrl,
});
let pagePromise = operationPromise.then((payload) => new TemplatePage(instance._version, payload, instance._solution));
pagePromise = instance._version.setPromiseCallback(pagePromise, callback);
return pagePromise;
};
instance.pageWithHttpInfo = function pageWithHttpInfo(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["friendlyName"] !== undefined)
data["FriendlyName"] = params["friendlyName"];
if (params["pageSize"] !== undefined)
data["PageSize"] = params["pageSize"];
if (params.pageNumber !== undefined)
data["Page"] = params.pageNumber;
if (params.pageToken !== undefined)
data["PageToken"] = params.pageToken;
const headers = {};
headers["Accept"] = "application/json";
let operationVersion = version;
// For page operations, use page() directly as it already returns { statusCode, body, headers }
// IMPORTANT: Pass full response to Page constructor, not response.body
let operationPromise = operationVersion
.page({ uri: instance._uri, method: "get", params: data, headers })
.then((response) => ({
statusCode: response.statusCode,
headers: response.headers,
body: new TemplatePage(operationVersion, response, instance._solution),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.each = instance._version.each;
instance.eachWithHttpInfo = instance._version.eachWithHttpInfo;
instance.list = instance._version.list;
instance.listWithHttpInfo = instance._version.listWithHttpInfo;
instance.getPageWithHttpInfo = function getPageWithHttpInfo(targetUrl, callback) {
// Use request() directly as it already returns { statusCode, body, headers }
const operationPromise = instance._version._domain.twilio.request({
method: "get",
uri: targetUrl,
});
let pagePromise = operationPromise.then((response) => ({
statusCode: response.statusCode,
headers: response.headers,
body: new TemplatePage(instance._version, response, instance._solution),
}));
pagePromise = instance._version.setPromiseCallback(pagePromise, callback);
return pagePromise;
};
instance.toJSON = function toJSON() {
return instance._solution;
};
instance[util_1.inspect.custom] = function inspectImpl(_depth, options) {
return (0, util_1.inspect)(instance.toJSON(), options);
};
return instance;
}
class TemplateInstance {
constructor(_version, payload) {
this._version = _version;
this.sid = payload.sid;
this.accountSid = payload.account_sid;
this.friendlyName = payload.friendly_name;
this.channels = payload.channels;
this.translations = payload.translations;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
sid: this.sid,
accountSid: this.accountSid,
friendlyName: this.friendlyName,
channels: this.channels,
translations: this.translations,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.TemplateInstance = TemplateInstance;
class TemplatePage extends Page_1.default {
/**
* Initialize the TemplatePage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version, response, solution) {
super(version, response, solution);
}
/**
* Build an instance of TemplateInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new TemplateInstance(this._version, payload);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.TemplatePage = TemplatePage;

View File

@@ -0,0 +1,363 @@
import { inspect, InspectOptions } from "util";
import Page, { TwilioResponsePayload } from "../../../base/Page";
import Response from "../../../http/response";
import V2 from "../V2";
import { ApiResponse } from "../../../base/ApiResponse";
/**
* A string specifying the communication channel used for the verification attempt.
*/
export type VerificationAttemptChannels = "sms" | "call" | "email" | "whatsapp" | "rbm";
/**
* A string specifying the conversion status of the verification. A conversion happens when the user is able to provide the correct code. Possible values are `CONVERTED` and `UNCONVERTED`.
*/
export type VerificationAttemptConversionStatus = "converted" | "unconverted";
/**
* Options to pass to each
*/
export interface VerificationAttemptListInstanceEachOptions {
/** Datetime filter used to consider only Verification Attempts created after this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd\'T\'HH:mm:ss\'Z. */
dateCreatedAfter?: Date;
/** Datetime filter used to consider only Verification Attempts created before this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd\'T\'HH:mm:ss\'Z. */
dateCreatedBefore?: Date;
/** Destination of a verification. It is phone number in E.164 format. */
"channelData.to"?: string;
/** Filter used to query Verification Attempts sent to the specified destination country. */
country?: string;
/** Filter used to query Verification Attempts by communication channel. */
channel?: VerificationAttemptChannels;
/** Filter used to query Verification Attempts by verify service. Only attempts of the provided SID will be returned. */
verifyServiceSid?: string;
/** Filter used to return all the Verification Attempts of a single verification. Only attempts of the provided verification SID will be returned. */
verificationSid?: string;
/** Filter used to query Verification Attempts by conversion status. Valid values are `UNCONVERTED`, for attempts that were not converted, and `CONVERTED`, for attempts that were confirmed. */
status?: VerificationAttemptConversionStatus;
/** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
pageSize?: number;
/** Function to process each record. If this and a positional callback are passed, this one will be used */
callback?: (item: VerificationAttemptInstance, done: (err?: Error) => void) => void;
/** Function to be called upon completion of streaming */
done?: Function;
/** Upper limit for the number of records to return. each() guarantees never to return more than limit. Default is no limit */
limit?: number;
}
/**
* Options to pass to list
*/
export interface VerificationAttemptListInstanceOptions {
/** Datetime filter used to consider only Verification Attempts created after this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd\'T\'HH:mm:ss\'Z. */
dateCreatedAfter?: Date;
/** Datetime filter used to consider only Verification Attempts created before this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd\'T\'HH:mm:ss\'Z. */
dateCreatedBefore?: Date;
/** Destination of a verification. It is phone number in E.164 format. */
"channelData.to"?: string;
/** Filter used to query Verification Attempts sent to the specified destination country. */
country?: string;
/** Filter used to query Verification Attempts by communication channel. */
channel?: VerificationAttemptChannels;
/** Filter used to query Verification Attempts by verify service. Only attempts of the provided SID will be returned. */
verifyServiceSid?: string;
/** Filter used to return all the Verification Attempts of a single verification. Only attempts of the provided verification SID will be returned. */
verificationSid?: string;
/** Filter used to query Verification Attempts by conversion status. Valid values are `UNCONVERTED`, for attempts that were not converted, and `CONVERTED`, for attempts that were confirmed. */
status?: VerificationAttemptConversionStatus;
/** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
pageSize?: number;
/** Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit */
limit?: number;
}
/**
* Options to pass to page
*/
export interface VerificationAttemptListInstancePageOptions {
/** Datetime filter used to consider only Verification Attempts created after this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd\'T\'HH:mm:ss\'Z. */
dateCreatedAfter?: Date;
/** Datetime filter used to consider only Verification Attempts created before this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd\'T\'HH:mm:ss\'Z. */
dateCreatedBefore?: Date;
/** Destination of a verification. It is phone number in E.164 format. */
"channelData.to"?: string;
/** Filter used to query Verification Attempts sent to the specified destination country. */
country?: string;
/** Filter used to query Verification Attempts by communication channel. */
channel?: VerificationAttemptChannels;
/** Filter used to query Verification Attempts by verify service. Only attempts of the provided SID will be returned. */
verifyServiceSid?: string;
/** Filter used to return all the Verification Attempts of a single verification. Only attempts of the provided verification SID will be returned. */
verificationSid?: string;
/** Filter used to query Verification Attempts by conversion status. Valid values are `UNCONVERTED`, for attempts that were not converted, and `CONVERTED`, for attempts that were confirmed. */
status?: VerificationAttemptConversionStatus;
/** How many resources to return in each list page. The default is 50, and the maximum is 1000. */
pageSize?: number;
/** Page Number, this value is simply for client state */
pageNumber?: number;
/** PageToken provided by the API */
pageToken?: string;
}
export interface VerificationAttemptContext {
/**
* Fetch a VerificationAttemptInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed VerificationAttemptInstance
*/
fetch(callback?: (error: Error | null, item?: VerificationAttemptInstance) => any): Promise<VerificationAttemptInstance>;
/**
* Fetch a VerificationAttemptInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed VerificationAttemptInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<VerificationAttemptInstance>) => any): Promise<ApiResponse<VerificationAttemptInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface VerificationAttemptContextSolution {
sid: string;
}
export declare class VerificationAttemptContextImpl implements VerificationAttemptContext {
protected _version: V2;
protected _solution: VerificationAttemptContextSolution;
protected _uri: string;
constructor(_version: V2, sid: string);
fetch(callback?: (error: Error | null, item?: VerificationAttemptInstance) => any): Promise<VerificationAttemptInstance>;
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<VerificationAttemptInstance>) => any): Promise<ApiResponse<VerificationAttemptInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): VerificationAttemptContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface VerificationAttemptPayload extends TwilioResponsePayload {
attempts: VerificationAttemptResource[];
}
interface VerificationAttemptResource {
sid: string;
account_sid: string;
service_sid: string;
verification_sid: string;
date_created: Date;
date_updated: Date;
conversion_status: VerificationAttemptConversionStatus;
channel: VerificationAttemptChannels;
price: any;
channel_data: any;
url: string;
}
export declare class VerificationAttemptInstance {
protected _version: V2;
protected _solution: VerificationAttemptContextSolution;
protected _context?: VerificationAttemptContext;
constructor(_version: V2, payload: VerificationAttemptResource, sid?: string);
/**
* The SID that uniquely identifies the verification attempt resource.
*/
sid: string;
/**
* The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Verification resource.
*/
accountSid: string;
/**
* The SID of the [Service](https://www.twilio.com/docs/verify/api/service) used to generate the attempt.
*/
serviceSid: string;
/**
* The SID of the [Verification](https://www.twilio.com/docs/verify/api/verification) that generated the attempt.
*/
verificationSid: string;
/**
* The date that this Attempt was created, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateCreated: Date;
/**
* The date that this Attempt was updated, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
*/
dateUpdated: Date;
conversionStatus: VerificationAttemptConversionStatus;
channel: VerificationAttemptChannels;
/**
* An object containing the charge for this verification attempt related to the channel costs and the currency used. The costs related to the succeeded verifications are not included. May not be immediately available. More information on pricing is available [here](https://www.twilio.com/en-us/verify/pricing).
*/
price: any;
/**
* An object containing the channel specific information for an attempt.
*/
channelData: any;
url: string;
private get _proxy();
/**
* Fetch a VerificationAttemptInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed VerificationAttemptInstance
*/
fetch(callback?: (error: Error | null, item?: VerificationAttemptInstance) => any): Promise<VerificationAttemptInstance>;
/**
* Fetch a VerificationAttemptInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed VerificationAttemptInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<VerificationAttemptInstance>) => any): Promise<ApiResponse<VerificationAttemptInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
sid: string;
accountSid: string;
serviceSid: string;
verificationSid: string;
dateCreated: Date;
dateUpdated: Date;
conversionStatus: VerificationAttemptConversionStatus;
channel: VerificationAttemptChannels;
price: any;
channelData: any;
url: string;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface VerificationAttemptSolution {
}
export interface VerificationAttemptListInstance {
_version: V2;
_solution: VerificationAttemptSolution;
_uri: string;
(sid: string): VerificationAttemptContext;
get(sid: string): VerificationAttemptContext;
/**
* Streams VerificationAttemptInstance records from the API.
*
* This operation lazily loads records as efficiently as possible until the limit
* is reached.
*
* The results are passed into the callback function, so this operation is memory
* efficient.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { VerificationAttemptListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
each(callback?: (item: VerificationAttemptInstance, done: (err?: Error) => void) => void): void;
each(params: VerificationAttemptListInstanceEachOptions, callback?: (item: VerificationAttemptInstance, done: (err?: Error) => void) => void): void;
/**
* Streams VerificationAttemptInstance records from the API with HTTP metadata captured per page.
*
* This operation lazily loads records as efficiently as possible until the limit
* is reached. HTTP metadata (status code, headers) is captured for each page request.
*
* The results are passed into the callback function, so this operation is memory
* efficient.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { VerificationAttemptListInstanceEachOptions } [params] - Options for request
* @param { function } [callback] - Function to process each record
*/
eachWithHttpInfo(callback?: (item: VerificationAttemptInstance, done: (err?: Error) => void) => void): void;
eachWithHttpInfo(params: VerificationAttemptListInstanceEachOptions, callback?: (item: VerificationAttemptInstance, done: (err?: Error) => void) => void): void;
/**
* Retrieve a single target page of VerificationAttemptInstance records from the API.
*
* The request is executed immediately.
*
* @param { string } [targetUrl] - API-generated URL for the requested results page
* @param { function } [callback] - Callback to handle list of records
*/
getPage(targetUrl: string, callback?: (error: Error | null, items: VerificationAttemptPage) => any): Promise<VerificationAttemptPage>;
/**
* Retrieve a single target page of VerificationAttemptInstance records from the API with HTTP metadata.
*
* The request is executed immediately.
*
* @param { string } [targetUrl] - API-generated URL for the requested results page
* @param { function } [callback] - Callback to handle list of records with metadata
*/
getPageWithHttpInfo(targetUrl: string, callback?: (error: Error | null, items: ApiResponse<VerificationAttemptPage>) => any): Promise<ApiResponse<VerificationAttemptPage>>;
/**
* Lists VerificationAttemptInstance records from the API as a list.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { VerificationAttemptListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
list(callback?: (error: Error | null, items: VerificationAttemptInstance[]) => any): Promise<VerificationAttemptInstance[]>;
list(params: VerificationAttemptListInstanceOptions, callback?: (error: Error | null, items: VerificationAttemptInstance[]) => any): Promise<VerificationAttemptInstance[]>;
/**
* Lists VerificationAttemptInstance records from the API as a list with HTTP metadata.
*
* Returns all records along with HTTP metadata from the first page fetched.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { VerificationAttemptListInstanceOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
listWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<VerificationAttemptInstance[]>) => any): Promise<ApiResponse<VerificationAttemptInstance[]>>;
listWithHttpInfo(params: VerificationAttemptListInstanceOptions, callback?: (error: Error | null, items: ApiResponse<VerificationAttemptInstance[]>) => any): Promise<ApiResponse<VerificationAttemptInstance[]>>;
/**
* Retrieve a single page of VerificationAttemptInstance records from the API.
*
* The request is executed immediately.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { VerificationAttemptListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records
*/
page(callback?: (error: Error | null, items: VerificationAttemptPage) => any): Promise<VerificationAttemptPage>;
page(params: VerificationAttemptListInstancePageOptions, callback?: (error: Error | null, items: VerificationAttemptPage) => any): Promise<VerificationAttemptPage>;
/**
* Retrieve a single page of VerificationAttemptInstance records from the API with HTTP metadata.
*
* The request is executed immediately.
*
* If a function is passed as the first argument, it will be used as the callback
* function.
*
* @param { VerificationAttemptListInstancePageOptions } [params] - Options for request
* @param { function } [callback] - Callback to handle list of records with metadata
*/
pageWithHttpInfo(callback?: (error: Error | null, items: ApiResponse<VerificationAttemptPage>) => any): Promise<ApiResponse<VerificationAttemptPage>>;
pageWithHttpInfo(params: VerificationAttemptListInstancePageOptions, callback?: (error: Error | null, items: ApiResponse<VerificationAttemptPage>) => any): Promise<ApiResponse<VerificationAttemptPage>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function VerificationAttemptListInstance(version: V2): VerificationAttemptListInstance;
export declare class VerificationAttemptPage extends Page<V2, VerificationAttemptPayload, VerificationAttemptResource, VerificationAttemptInstance> {
/**
* Initialize the VerificationAttemptPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version: V2, response: Response<string>, solution: VerificationAttemptSolution);
/**
* Build an instance of VerificationAttemptInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload: VerificationAttemptResource): VerificationAttemptInstance;
[inspect.custom](depth: any, options: InspectOptions): string;
}
export {};

View File

@@ -0,0 +1,304 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Verify
* 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.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.VerificationAttemptPage = exports.VerificationAttemptInstance = exports.VerificationAttemptContextImpl = void 0;
exports.VerificationAttemptListInstance = VerificationAttemptListInstance;
const util_1 = require("util");
const Page_1 = __importDefault(require("../../../base/Page"));
const deserialize = require("../../../base/deserialize");
const serialize = require("../../../base/serialize");
const utility_1 = require("../../../base/utility");
class VerificationAttemptContextImpl {
constructor(_version, sid) {
this._version = _version;
if (!(0, utility_1.isValidPathParam)(sid)) {
throw new Error("Parameter 'sid' is not valid.");
}
this._solution = { sid };
this._uri = `/Attempts/${sid}`;
}
fetch(callback) {
const headers = {};
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.fetch({
uri: instance._uri,
method: "get",
headers,
});
operationPromise = operationPromise.then((payload) => new VerificationAttemptInstance(operationVersion, payload, instance._solution.sid));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
fetchWithHttpInfo(callback) {
const headers = {};
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.fetchWithResponseInfo({
uri: instance._uri,
method: "get",
headers,
})
.then((response) => ({
...response,
body: new VerificationAttemptInstance(operationVersion, response.body, instance._solution.sid),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return this._solution;
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.VerificationAttemptContextImpl = VerificationAttemptContextImpl;
class VerificationAttemptInstance {
constructor(_version, payload, sid) {
this._version = _version;
this.sid = payload.sid;
this.accountSid = payload.account_sid;
this.serviceSid = payload.service_sid;
this.verificationSid = payload.verification_sid;
this.dateCreated = deserialize.iso8601DateTime(payload.date_created);
this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated);
this.conversionStatus = payload.conversion_status;
this.channel = payload.channel;
this.price = payload.price;
this.channelData = payload.channel_data;
this.url = payload.url;
this._solution = { sid: sid || this.sid };
}
get _proxy() {
this._context =
this._context ||
new VerificationAttemptContextImpl(this._version, this._solution.sid);
return this._context;
}
/**
* Fetch a VerificationAttemptInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed VerificationAttemptInstance
*/
fetch(callback) {
return this._proxy.fetch(callback);
}
/**
* Fetch a VerificationAttemptInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed VerificationAttemptInstance with HTTP metadata
*/
fetchWithHttpInfo(callback) {
return this._proxy.fetchWithHttpInfo(callback);
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
sid: this.sid,
accountSid: this.accountSid,
serviceSid: this.serviceSid,
verificationSid: this.verificationSid,
dateCreated: this.dateCreated,
dateUpdated: this.dateUpdated,
conversionStatus: this.conversionStatus,
channel: this.channel,
price: this.price,
channelData: this.channelData,
url: this.url,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.VerificationAttemptInstance = VerificationAttemptInstance;
function VerificationAttemptListInstance(version) {
const instance = ((sid) => instance.get(sid));
instance.get = function get(sid) {
return new VerificationAttemptContextImpl(version, sid);
};
instance._version = version;
instance._solution = {};
instance._uri = `/Attempts`;
instance.page = function page(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["dateCreatedAfter"] !== undefined)
data["DateCreatedAfter"] = serialize.iso8601DateTime(params["dateCreatedAfter"]);
if (params["dateCreatedBefore"] !== undefined)
data["DateCreatedBefore"] = serialize.iso8601DateTime(params["dateCreatedBefore"]);
if (params["channelData.to"] !== undefined)
data["ChannelData.To"] = params["channelData.to"];
if (params["country"] !== undefined)
data["Country"] = params["country"];
if (params["channel"] !== undefined)
data["Channel"] = params["channel"];
if (params["verifyServiceSid"] !== undefined)
data["VerifyServiceSid"] = params["verifyServiceSid"];
if (params["verificationSid"] !== undefined)
data["VerificationSid"] = params["verificationSid"];
if (params["status"] !== undefined)
data["Status"] = params["status"];
if (params["pageSize"] !== undefined)
data["PageSize"] = params["pageSize"];
if (params.pageNumber !== undefined)
data["Page"] = params.pageNumber;
if (params.pageToken !== undefined)
data["PageToken"] = params.pageToken;
const headers = {};
headers["Accept"] = "application/json";
let operationVersion = version, operationPromise = operationVersion.page({
uri: instance._uri,
method: "get",
params: data,
headers,
});
operationPromise = operationPromise.then((payload) => new VerificationAttemptPage(operationVersion, payload, instance._solution));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.each = instance._version.each;
instance.list = instance._version.list;
instance.getPage = function getPage(targetUrl, callback) {
const operationPromise = instance._version._domain.twilio.request({
method: "get",
uri: targetUrl,
});
let pagePromise = operationPromise.then((payload) => new VerificationAttemptPage(instance._version, payload, instance._solution));
pagePromise = instance._version.setPromiseCallback(pagePromise, callback);
return pagePromise;
};
instance.pageWithHttpInfo = function pageWithHttpInfo(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["dateCreatedAfter"] !== undefined)
data["DateCreatedAfter"] = serialize.iso8601DateTime(params["dateCreatedAfter"]);
if (params["dateCreatedBefore"] !== undefined)
data["DateCreatedBefore"] = serialize.iso8601DateTime(params["dateCreatedBefore"]);
if (params["channelData.to"] !== undefined)
data["ChannelData.To"] = params["channelData.to"];
if (params["country"] !== undefined)
data["Country"] = params["country"];
if (params["channel"] !== undefined)
data["Channel"] = params["channel"];
if (params["verifyServiceSid"] !== undefined)
data["VerifyServiceSid"] = params["verifyServiceSid"];
if (params["verificationSid"] !== undefined)
data["VerificationSid"] = params["verificationSid"];
if (params["status"] !== undefined)
data["Status"] = params["status"];
if (params["pageSize"] !== undefined)
data["PageSize"] = params["pageSize"];
if (params.pageNumber !== undefined)
data["Page"] = params.pageNumber;
if (params.pageToken !== undefined)
data["PageToken"] = params.pageToken;
const headers = {};
headers["Accept"] = "application/json";
let operationVersion = version;
// For page operations, use page() directly as it already returns { statusCode, body, headers }
// IMPORTANT: Pass full response to Page constructor, not response.body
let operationPromise = operationVersion
.page({ uri: instance._uri, method: "get", params: data, headers })
.then((response) => ({
statusCode: response.statusCode,
headers: response.headers,
body: new VerificationAttemptPage(operationVersion, response, instance._solution),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
};
instance.each = instance._version.each;
instance.eachWithHttpInfo = instance._version.eachWithHttpInfo;
instance.list = instance._version.list;
instance.listWithHttpInfo = instance._version.listWithHttpInfo;
instance.getPageWithHttpInfo = function getPageWithHttpInfo(targetUrl, callback) {
// Use request() directly as it already returns { statusCode, body, headers }
const operationPromise = instance._version._domain.twilio.request({
method: "get",
uri: targetUrl,
});
let pagePromise = operationPromise.then((response) => ({
statusCode: response.statusCode,
headers: response.headers,
body: new VerificationAttemptPage(instance._version, response, instance._solution),
}));
pagePromise = instance._version.setPromiseCallback(pagePromise, callback);
return pagePromise;
};
instance.toJSON = function toJSON() {
return instance._solution;
};
instance[util_1.inspect.custom] = function inspectImpl(_depth, options) {
return (0, util_1.inspect)(instance.toJSON(), options);
};
return instance;
}
class VerificationAttemptPage extends Page_1.default {
/**
* Initialize the VerificationAttemptPage
*
* @param version - Version of the resource
* @param response - Response from the API
* @param solution - Path solution
*/
constructor(version, response, solution) {
super(version, response, solution);
}
/**
* Build an instance of VerificationAttemptInstance
*
* @param payload - Payload response from the API
*/
getInstance(payload) {
return new VerificationAttemptInstance(this._version, payload);
}
[util_1.inspect.custom](depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.VerificationAttemptPage = VerificationAttemptPage;

View File

@@ -0,0 +1,173 @@
import { inspect, InspectOptions } from "util";
import V2 from "../V2";
import { ApiResponse } from "../../../base/ApiResponse";
export type VerificationAttemptsSummaryChannels = "sms" | "call" | "email" | "whatsapp" | "rbm";
/**
* Options to pass to fetch a VerificationAttemptsSummaryInstance
*/
export interface VerificationAttemptsSummaryContextFetchOptions {
/** Filter used to consider only Verification Attempts of the given verify service on the summary aggregation. */
verifyServiceSid?: string;
/** Datetime filter used to consider only Verification Attempts created after this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd\'T\'HH:mm:ss\'Z. */
dateCreatedAfter?: Date;
/** Datetime filter used to consider only Verification Attempts created before this datetime on the summary aggregation. Given as GMT in ISO 8601 formatted datetime string: yyyy-MM-dd\'T\'HH:mm:ss\'Z. */
dateCreatedBefore?: Date;
/** Filter used to consider only Verification Attempts sent to the specified destination country on the summary aggregation. */
country?: string;
/** Filter Verification Attempts considered on the summary aggregation by communication channel. */
channel?: VerificationAttemptsSummaryChannels;
/** Filter the Verification Attempts considered on the summary aggregation by Destination prefix. It is the prefix of a phone number in E.164 format. */
destinationPrefix?: string;
}
export interface VerificationAttemptsSummaryContext {
/**
* Fetch a VerificationAttemptsSummaryInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed VerificationAttemptsSummaryInstance
*/
fetch(callback?: (error: Error | null, item?: VerificationAttemptsSummaryInstance) => any): Promise<VerificationAttemptsSummaryInstance>;
/**
* Fetch a VerificationAttemptsSummaryInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed VerificationAttemptsSummaryInstance
*/
fetch(params: VerificationAttemptsSummaryContextFetchOptions, callback?: (error: Error | null, item?: VerificationAttemptsSummaryInstance) => any): Promise<VerificationAttemptsSummaryInstance>;
/**
* Fetch a VerificationAttemptsSummaryInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed VerificationAttemptsSummaryInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<VerificationAttemptsSummaryInstance>) => any): Promise<ApiResponse<VerificationAttemptsSummaryInstance>>;
/**
* Fetch a VerificationAttemptsSummaryInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed VerificationAttemptsSummaryInstance with HTTP metadata
*/
fetchWithHttpInfo(params: VerificationAttemptsSummaryContextFetchOptions, callback?: (error: Error | null, item?: ApiResponse<VerificationAttemptsSummaryInstance>) => any): Promise<ApiResponse<VerificationAttemptsSummaryInstance>>;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export interface VerificationAttemptsSummaryContextSolution {
}
export declare class VerificationAttemptsSummaryContextImpl implements VerificationAttemptsSummaryContext {
protected _version: V2;
protected _solution: VerificationAttemptsSummaryContextSolution;
protected _uri: string;
constructor(_version: V2);
fetch(params?: VerificationAttemptsSummaryContextFetchOptions | ((error: Error | null, item?: VerificationAttemptsSummaryInstance) => any), callback?: (error: Error | null, item?: VerificationAttemptsSummaryInstance) => any): Promise<VerificationAttemptsSummaryInstance>;
fetchWithHttpInfo(params?: VerificationAttemptsSummaryContextFetchOptions | ((error: Error | null, item?: ApiResponse<VerificationAttemptsSummaryInstance>) => any), callback?: (error: Error | null, item?: ApiResponse<VerificationAttemptsSummaryInstance>) => any): Promise<ApiResponse<VerificationAttemptsSummaryInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): VerificationAttemptsSummaryContextSolution;
[inspect.custom](_depth: any, options: InspectOptions): string;
}
interface VerificationAttemptsSummaryResource {
total_attempts: number;
total_converted: number;
total_unconverted: number;
conversion_rate_percentage: string;
url: string;
}
export declare class VerificationAttemptsSummaryInstance {
protected _version: V2;
protected _solution: VerificationAttemptsSummaryContextSolution;
protected _context?: VerificationAttemptsSummaryContext;
constructor(_version: V2, payload: VerificationAttemptsSummaryResource);
/**
* Total of attempts made according to the provided filters
*/
totalAttempts: number;
/**
* Total of attempts made that were confirmed by the end user, according to the provided filters.
*/
totalConverted: number;
/**
* Total of attempts made that were not confirmed by the end user, according to the provided filters.
*/
totalUnconverted: number;
/**
* Percentage of the confirmed messages over the total, defined by (total_converted/total_attempts)*100.
*/
conversionRatePercentage: string;
url: string;
private get _proxy();
/**
* Fetch a VerificationAttemptsSummaryInstance
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed VerificationAttemptsSummaryInstance
*/
fetch(callback?: (error: Error | null, item?: VerificationAttemptsSummaryInstance) => any): Promise<VerificationAttemptsSummaryInstance>;
/**
* Fetch a VerificationAttemptsSummaryInstance
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed VerificationAttemptsSummaryInstance
*/
fetch(params: VerificationAttemptsSummaryContextFetchOptions, callback?: (error: Error | null, item?: VerificationAttemptsSummaryInstance) => any): Promise<VerificationAttemptsSummaryInstance>;
/**
* Fetch a VerificationAttemptsSummaryInstance and return HTTP info
*
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed VerificationAttemptsSummaryInstance with HTTP metadata
*/
fetchWithHttpInfo(callback?: (error: Error | null, item?: ApiResponse<VerificationAttemptsSummaryInstance>) => any): Promise<ApiResponse<VerificationAttemptsSummaryInstance>>;
/**
* Fetch a VerificationAttemptsSummaryInstance and return HTTP info
*
* @param params - Parameter for request
* @param callback - Callback to handle processed record
*
* @returns Resolves to processed VerificationAttemptsSummaryInstance with HTTP metadata
*/
fetchWithHttpInfo(params: VerificationAttemptsSummaryContextFetchOptions, callback?: (error: Error | null, item?: ApiResponse<VerificationAttemptsSummaryInstance>) => any): Promise<ApiResponse<VerificationAttemptsSummaryInstance>>;
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON(): {
totalAttempts: number;
totalConverted: number;
totalUnconverted: number;
conversionRatePercentage: string;
url: string;
};
[inspect.custom](_depth: any, options: InspectOptions): string;
}
export interface VerificationAttemptsSummarySolution {
}
export interface VerificationAttemptsSummaryListInstance {
_version: V2;
_solution: VerificationAttemptsSummarySolution;
_uri: string;
(): VerificationAttemptsSummaryContext;
get(): VerificationAttemptsSummaryContext;
/**
* Provide a user-friendly representation
*/
toJSON(): any;
[inspect.custom](_depth: any, options: InspectOptions): any;
}
export declare function VerificationAttemptsSummaryListInstance(version: V2): VerificationAttemptsSummaryListInstance;
export {};

View File

@@ -0,0 +1,170 @@
"use strict";
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Verify
* 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.VerificationAttemptsSummaryInstance = exports.VerificationAttemptsSummaryContextImpl = void 0;
exports.VerificationAttemptsSummaryListInstance = VerificationAttemptsSummaryListInstance;
const util_1 = require("util");
const deserialize = require("../../../base/deserialize");
const serialize = require("../../../base/serialize");
class VerificationAttemptsSummaryContextImpl {
constructor(_version) {
this._version = _version;
this._solution = {};
this._uri = `/Attempts/Summary`;
}
fetch(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["verifyServiceSid"] !== undefined)
data["VerifyServiceSid"] = params["verifyServiceSid"];
if (params["dateCreatedAfter"] !== undefined)
data["DateCreatedAfter"] = serialize.iso8601DateTime(params["dateCreatedAfter"]);
if (params["dateCreatedBefore"] !== undefined)
data["DateCreatedBefore"] = serialize.iso8601DateTime(params["dateCreatedBefore"]);
if (params["country"] !== undefined)
data["Country"] = params["country"];
if (params["channel"] !== undefined)
data["Channel"] = params["channel"];
if (params["destinationPrefix"] !== undefined)
data["DestinationPrefix"] = params["destinationPrefix"];
const headers = {};
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version, operationPromise = operationVersion.fetch({
uri: instance._uri,
method: "get",
params: data,
headers,
});
operationPromise = operationPromise.then((payload) => new VerificationAttemptsSummaryInstance(operationVersion, payload));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
fetchWithHttpInfo(params, callback) {
if (params instanceof Function) {
callback = params;
params = {};
}
else {
params = params || {};
}
let data = {};
if (params["verifyServiceSid"] !== undefined)
data["VerifyServiceSid"] = params["verifyServiceSid"];
if (params["dateCreatedAfter"] !== undefined)
data["DateCreatedAfter"] = serialize.iso8601DateTime(params["dateCreatedAfter"]);
if (params["dateCreatedBefore"] !== undefined)
data["DateCreatedBefore"] = serialize.iso8601DateTime(params["dateCreatedBefore"]);
if (params["country"] !== undefined)
data["Country"] = params["country"];
if (params["channel"] !== undefined)
data["Channel"] = params["channel"];
if (params["destinationPrefix"] !== undefined)
data["DestinationPrefix"] = params["destinationPrefix"];
const headers = {};
headers["Accept"] = "application/json";
const instance = this;
let operationVersion = instance._version;
// CREATE, FETCH, UPDATE operations
let operationPromise = operationVersion
.fetchWithResponseInfo({
uri: instance._uri,
method: "get",
params: data,
headers,
})
.then((response) => ({
...response,
body: new VerificationAttemptsSummaryInstance(operationVersion, response.body),
}));
operationPromise = instance._version.setPromiseCallback(operationPromise, callback);
return operationPromise;
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return this._solution;
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.VerificationAttemptsSummaryContextImpl = VerificationAttemptsSummaryContextImpl;
class VerificationAttemptsSummaryInstance {
constructor(_version, payload) {
this._version = _version;
this.totalAttempts = deserialize.integer(payload.total_attempts);
this.totalConverted = deserialize.integer(payload.total_converted);
this.totalUnconverted = deserialize.integer(payload.total_unconverted);
this.conversionRatePercentage = payload.conversion_rate_percentage;
this.url = payload.url;
this._solution = {};
}
get _proxy() {
this._context =
this._context ||
new VerificationAttemptsSummaryContextImpl(this._version);
return this._context;
}
fetch(params, callback) {
return this._proxy.fetch(params, callback);
}
fetchWithHttpInfo(params, callback) {
return this._proxy.fetchWithHttpInfo(params, callback);
}
/**
* Provide a user-friendly representation
*
* @returns Object
*/
toJSON() {
return {
totalAttempts: this.totalAttempts,
totalConverted: this.totalConverted,
totalUnconverted: this.totalUnconverted,
conversionRatePercentage: this.conversionRatePercentage,
url: this.url,
};
}
[util_1.inspect.custom](_depth, options) {
return (0, util_1.inspect)(this.toJSON(), options);
}
}
exports.VerificationAttemptsSummaryInstance = VerificationAttemptsSummaryInstance;
function VerificationAttemptsSummaryListInstance(version) {
const instance = (() => instance.get());
instance.get = function get() {
return new VerificationAttemptsSummaryContextImpl(version);
};
instance._version = version;
instance._solution = {};
instance._uri = ``;
instance.toJSON = function toJSON() {
return instance._solution;
};
instance[util_1.inspect.custom] = function inspectImpl(_depth, options) {
return (0, util_1.inspect)(instance.toJSON(), options);
};
return instance;
}