UNPKG

2.83 kBTypeScriptView Raw
1export type HttpMethod = "get" | "post" | "put" | "patch" | "delete";
2export type Url = string;
3export type PhoneNumber = string;
4export type PhoneNumberCapabilities = {
5 mms: boolean;
6 sms: boolean;
7 voice: boolean;
8 fax: boolean;
9};
10export type Sid = string;
11export interface ListEachOptions<TInstance> {
12 /**
13 * Upper limit for the number of records to return.
14 * each() guarantees never to return more than limit.
15 * Default is no limit
16 */
17 limit?: number;
18 /**
19 * Number of records to fetch per request,
20 * when not set will use the default value of 50 records.
21 * If no pageSize is defined but a limit is defined,
22 * each() will attempt to read the limit with the most efficient
23 * page size, i.e. min(limit, 1000)
24 */
25 pageSize?: number;
26 /**
27 * Function to process each record. If this and a positional
28 * callback are passed, this one will be used
29 */
30 callback?: (item: TInstance, done: (err?: Error) => void) => void;
31 /**
32 * Function to be called upon completion of streaming
33 */
34 done?: (err?: Error) => void;
35}
36export interface ListOptions<TInstance> {
37 /**
38 * Upper limit for the number of records to return.
39 * each() guarantees never to return more than limit.
40 * Default is no limit
41 */
42 limit?: number;
43 /**
44 * Number of records to fetch per request,
45 * when not set will use the default value of 50 records.
46 * If no pageSize is defined but a limit is defined,
47 * each() will attempt to read the limit with the most efficient
48 * page size, i.e. min(limit, 1000)
49 */
50 pageSize?: number;
51 /**
52 * Callback to handle list of records
53 */
54 callback?: (items: TInstance[]) => void;
55}
56export interface PageOptions<TPage> {
57 /**
58 * PageToken provided by the API
59 */
60 pageToken?: string;
61 /**
62 * Page Number, this value is simply for client state
63 */
64 pageNumber?: number;
65 /**
66 * Number of records to return, defaults to 50
67 */
68 pageSize?: number;
69 /**
70 * Callback to handle list of records
71 */
72 callback?: (page: TPage) => void;
73}
74/**
75 * A generic type that returns all property names of a class whose type is not "function"
76 */
77export type NonFunctionPropertyNames<T> = {
78 [K in keyof T]: T[K] extends Function ? never : K;
79}[keyof T];
80/**
81 * A generic type that returns only properties of a class that are not functions
82 */
83export type NonFunctionProperties<T> = Pick<T, NonFunctionPropertyNames<T>>;
84/**
85 * A type alias for better readibility
86 */
87export type Json<T> = NonFunctionProperties<T>;
88export declare class SerializableClass {
89 /**
90 * Converts the current instance in a regular JSON.
91 * It will be automatically called by JSON.stringify()
92 */
93 toJSON(): Json<this>;
94}