0

List SIM card actions

by
Published Apr 8, 2025

This API lists a paginated collection of SIM card actions. It enables exploring a collection of existing asynchronous operations using specific filters.

Script telnyx Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Telnyx = {
3
	apiKey: string
4
}
5
/**
6
 * List SIM card actions
7
 * This API lists a paginated collection of SIM card actions. It enables exploring a collection of existing asynchronous operations 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_id_: string | undefined,
14
	filter_status_: 'in-progress' | 'completed' | 'failed' | undefined,
15
	filter_bulk_sim_card_action_id_: string | undefined,
16
	filter_action_type_:
17
		| 'enable'
18
		| 'enable_standby_sim_card'
19
		| 'disable'
20
		| 'set_standby'
21
		| 'remove_public_ip'
22
		| 'set_public_ip'
23
		| undefined
24
) {
25
	const url = new URL(`https://api.telnyx.com/v2/sim_card_actions`)
26
	for (const [k, v] of [
27
		['page[number]', page_number_],
28
		['page[size]', page_size_],
29
		['filter[sim_card_id]', filter_sim_card_id_],
30
		['filter[status]', filter_status_],
31
		['filter[bulk_sim_card_action_id]', filter_bulk_sim_card_action_id_],
32
		['filter[action_type]', filter_action_type_]
33
	]) {
34
		if (v !== undefined && v !== '' && k !== undefined) {
35
			url.searchParams.append(k, v)
36
		}
37
	}
38
	const response = await fetch(url, {
39
		method: 'GET',
40
		headers: {
41
			Authorization: 'Bearer ' + auth.apiKey
42
		},
43
		body: undefined
44
	})
45
	if (!response.ok) {
46
		const text = await response.text()
47
		throw new Error(`${response.status} ${text}`)
48
	}
49
	return await response.json()
50
}
51