//native
type Telnyx = {
apiKey: string
}
/**
* List mobile push credentials
* List mobile push credentials
*/
export async function main(
auth: Telnyx,
filter_type_: 'ios' | 'android' | undefined,
filter_alias_: string | undefined,
page_size_: string | undefined,
page_number_: string | undefined
) {
const url = new URL(`https://api.telnyx.com/v2/mobile_push_credentials`)
for (const [k, v] of [
['filter[type]', filter_type_],
['filter[alias]', filter_alias_],
['page[size]', page_size_],
['page[number]', page_number_]
]) {
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