//native
type Telnyx = {
apiKey: string
}
/**
* List notification settings
* List notification settings.
*/
export async function main(
auth: Telnyx,
page_number_: string | undefined,
page_size_: string | undefined,
filter_notification_profile_id__eq_: string | undefined,
filter_notification_channel__eq_: string | undefined,
filter_notification_event_condition_id__eq_: string | undefined,
filter_associated_record_type__eq_: 'account' | 'phone_number' | undefined,
Status: 'canceled' | 'completed' | 'failed' | 'busy' | 'no-answer' | undefined
) {
const url = new URL(`https://api.telnyx.com/v2/notification_settings`)
for (const [k, v] of [
['page[number]', page_number_],
['page[size]', page_size_],
['filter[notification_profile_id][eq]', filter_notification_profile_id__eq_],
['filter[notification_channel][eq]', filter_notification_channel__eq_],
['filter[notification_event_condition_id][eq]', filter_notification_event_condition_id__eq_],
['filter[associated_record_type][eq]', filter_associated_record_type__eq_],
['Status', Status]
]) {
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