1 | |
2 | type Telnyx = { |
3 | apiKey: string |
4 | } |
5 | |
6 | * List SIM card group actions |
7 | * This API allows listing a paginated collection a SIM card group actions. It allows to explore a collection of existing asynchronous operation using specific filters. |
8 | */ |
9 | export async function main( |
10 | auth: Telnyx, |
11 | page_number_: string | undefined, |
12 | page_size_: string | undefined, |
13 | filter_sim_card_group_id_: string | undefined, |
14 | filter_status_: 'in-progress' | 'completed' | 'failed' | undefined, |
15 | filter_type_: 'set_private_wireless_gateway' | 'remove_private_wireless_gateway' | undefined |
16 | ) { |
17 | const url = new URL(`https://api.telnyx.com/v2/sim_card_group_actions`) |
18 | for (const [k, v] of [ |
19 | ['page[number]', page_number_], |
20 | ['page[size]', page_size_], |
21 | ['filter[sim_card_group_id]', filter_sim_card_group_id_], |
22 | ['filter[status]', filter_status_], |
23 | ['filter[type]', filter_type_] |
24 | ]) { |
25 | if (v !== undefined && v !== '' && k !== undefined) { |
26 | url.searchParams.append(k, v) |
27 | } |
28 | } |
29 | const response = await fetch(url, { |
30 | method: 'GET', |
31 | headers: { |
32 | Authorization: 'Bearer ' + auth.apiKey |
33 | }, |
34 | body: undefined |
35 | }) |
36 | if (!response.ok) { |
37 | const text = await response.text() |
38 | throw new Error(`${response.status} ${text}`) |
39 | } |
40 | return await response.json() |
41 | } |
42 |
|