0

Get Enum

by
Published Apr 8, 2025
Script telnyx Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Telnyx = {
3
	apiKey: string
4
}
5
/**
6
 * Get Enum
7
 *
8
 */
9
export async function main(
10
	auth: Telnyx,
11
	endpoint:
12
		| 'mno'
13
		| 'optionalAttributes'
14
		| 'usecase'
15
		| 'vertical'
16
		| 'altBusinessIdType'
17
		| 'brandIdentityStatus'
18
		| 'brandRelationship'
19
		| 'campaignStatus'
20
		| 'entityType'
21
		| 'extVettingProvider'
22
		| 'vettingStatus'
23
		| 'brandStatus'
24
		| 'operationStatus'
25
		| 'approvedPublicCompany'
26
		| 'stockExchange'
27
		| 'vettingClass'
28
) {
29
	const url = new URL(`https://api.telnyx.com/v2/enum/${endpoint}`)
30

31
	const response = await fetch(url, {
32
		method: 'GET',
33
		headers: {
34
			Authorization: 'Bearer ' + auth.apiKey
35
		},
36
		body: undefined
37
	})
38
	if (!response.ok) {
39
		const text = await response.text()
40
		throw new Error(`${response.status} ${text}`)
41
	}
42
	return await response.json()
43
}
44