1 | |
2 | type Telnyx = { |
3 | apiKey: string |
4 | } |
5 | |
6 | * List conference resources |
7 | * Lists conference resources. |
8 | */ |
9 | export async function main( |
10 | auth: Telnyx, |
11 | account_sid: string, |
12 | Page: string | undefined, |
13 | page_size_: string | undefined, |
14 | PageToken: string | undefined, |
15 | FriendlyName: string | undefined, |
16 | Status: 'init' | 'in-progress' | 'completed' | undefined, |
17 | DateCreated: string | undefined, |
18 | DateUpdated: string | undefined |
19 | ) { |
20 | const url = new URL(`https://api.telnyx.com/v2/texml/Accounts/${account_sid}/Conferences`) |
21 | for (const [k, v] of [ |
22 | ['Page', Page], |
23 | ['page[size]', page_size_], |
24 | ['PageToken', PageToken], |
25 | ['FriendlyName', FriendlyName], |
26 | ['Status', Status], |
27 | ['DateCreated', DateCreated], |
28 | ['DateUpdated', DateUpdated] |
29 | ]) { |
30 | if (v !== undefined && v !== '' && k !== undefined) { |
31 | url.searchParams.append(k, v) |
32 | } |
33 | } |
34 | const response = await fetch(url, { |
35 | method: 'GET', |
36 | headers: { |
37 | Authorization: 'Bearer ' + auth.apiKey |
38 | }, |
39 | body: undefined |
40 | }) |
41 | if (!response.ok) { |
42 | const text = await response.text() |
43 | throw new Error(`${response.status} ${text}`) |
44 | } |
45 | return await response.json() |
46 | } |
47 |
|