//native
type Telnyx = {
apiKey: string
}
/**
* List Auto-Response Settings
*
*/
export async function main(
auth: Telnyx,
profile_id: string,
country_code: string | undefined,
created_at_gte_: string | undefined,
created_at_lte_: string | undefined,
updated_at_gte_: string | undefined,
updated_at_lte_: string | undefined
) {
const url = new URL(`https://api.telnyx.com/v2/messaging_profiles/${profile_id}/autoresp_configs`)
for (const [k, v] of [
['country_code', country_code],
['created_at[gte]', created_at_gte_],
['created_at[lte]', created_at_lte_],
['updated_at[gte]', updated_at_gte_],
['updated_at[lte]', updated_at_lte_]
]) {
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