1 | |
2 | type Telnyx = { |
3 | apiKey: string |
4 | } |
5 | |
6 | * Update Verify profile |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Telnyx, |
11 | verify_profile_id: string, |
12 | body: { |
13 | name?: string |
14 | webhook_url?: string |
15 | webhook_failover_url?: string |
16 | sms?: { |
17 | messaging_template_id?: string |
18 | app_name?: string |
19 | alpha_sender?: string |
20 | code_length?: number |
21 | whitelisted_destinations?: string[] |
22 | default_verification_timeout_secs?: number |
23 | } |
24 | call?: { |
25 | messaging_template_id?: string |
26 | app_name?: string |
27 | code_length?: number |
28 | whitelisted_destinations?: string[] |
29 | default_verification_timeout_secs?: number |
30 | } |
31 | flashcall?: { |
32 | whitelisted_destinations?: string[] |
33 | default_verification_timeout_secs?: number |
34 | } |
35 | language?: string |
36 | } |
37 | ) { |
38 | const url = new URL(`https://api.telnyx.com/v2/verify_profiles/${verify_profile_id}`) |
39 |
|
40 | const response = await fetch(url, { |
41 | method: 'PATCH', |
42 | headers: { |
43 | 'Content-Type': 'application/json', |
44 | Authorization: 'Bearer ' + auth.apiKey |
45 | }, |
46 | body: JSON.stringify(body) |
47 | }) |
48 | if (!response.ok) { |
49 | const text = await response.text() |
50 | throw new Error(`${response.status} ${text}`) |
51 | } |
52 | return await response.json() |
53 | } |
54 |
|