//native
type Telnyx = {
apiKey: string
}
/**
* List all Access IP Ranges
*
*/
export async function main(
auth: Telnyx,
filter_cidr_block_: string | undefined,
filter_cidr_block__startswith_: string | undefined,
filter_cidr_block__endswith_: string | undefined,
filter_cidr_block__contains_: string | undefined,
filter_created_at__gt_: string | undefined,
filter_created_at__lt_: string | undefined,
page_number_: string | undefined,
page_size_: string | undefined
) {
const url = new URL(`https://api.telnyx.com/v2/access_ip_ranges`)
for (const [k, v] of [
['filter[cidr_block]', filter_cidr_block_],
['filter[cidr_block][startswith]', filter_cidr_block__startswith_],
['filter[cidr_block][endswith]', filter_cidr_block__endswith_],
['filter[cidr_block][contains]', filter_cidr_block__contains_],
['filter[created_at][gt]', filter_created_at__gt_],
['filter[created_at][lt]', filter_created_at__lt_],
['page[number]', page_number_],
['page[size]', page_size_]
]) {
if (v !== undefined && v !== '' && k !== undefined) {
url.searchParams.append(k, v)
}
}
const response = await fetch(url, {
method: 'GET',
headers: {
Authorization: 'Bearer ' + auth.apiKey
},
body: undefined
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 428 days ago