//native
type Telnyx = {
apiKey: string
}
/**
* Create a port-out related report
* Generate reports about port-out operations.
*/
export async function main(
auth: Telnyx,
body: {
report_type: 'export_portouts_csv'
params: {
filters: {
status__in?:
| 'pending'
| 'authorized'
| 'ported'
| 'rejected'
| 'rejected-pending'
| 'canceled'[]
customer_reference__in?: string[]
end_user_name?: string
phone_numbers__overlaps?: string[]
created_at__lt?: string
created_at__gt?: string
}
}
}
) {
const url = new URL(`https://api.telnyx.com/v2/portouts/reports`)
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + auth.apiKey
},
body: JSON.stringify(body)
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 428 days ago