1 | |
2 | type Telnyx = { |
3 | apiKey: string |
4 | } |
5 | |
6 | * Edit a porting order |
7 | * Edits the details of an existing porting order. |
8 |
|
9 | Any or all of a porting orders attributes may be included in the resource object included in a PATCH request. |
10 |
|
11 | If a request does not include all of the attributes for a resource, the system will interpret the missing attributes as if they were included with their current values. To explicitly set something to null, it must be included in the request with a null value. |
12 | */ |
13 | export async function main( |
14 | auth: Telnyx, |
15 | id: string, |
16 | body: { |
17 | misc?: { |
18 | type?: 'full' | 'partial' |
19 | remaining_numbers_action?: 'keep' | 'disconnect' |
20 | new_billing_phone_number?: string |
21 | } |
22 | end_user?: { |
23 | admin?: { |
24 | entity_name?: string |
25 | auth_person_name?: string |
26 | billing_phone_number?: string |
27 | account_number?: string |
28 | tax_identifier?: string |
29 | pin_passcode?: string |
30 | business_identifier?: string |
31 | } |
32 | location?: { |
33 | street_address?: string |
34 | extended_address?: string |
35 | locality?: string |
36 | administrative_area?: string |
37 | postal_code?: string |
38 | country_code?: string |
39 | } |
40 | } |
41 | documents?: { loa?: string; invoice?: string } |
42 | activation_settings?: { foc_datetime_requested?: string } |
43 | phone_number_configuration?: { |
44 | billing_group_id?: string |
45 | connection_id?: string |
46 | messaging_profile_id?: string |
47 | emergency_address_id?: string |
48 | tags?: string[] |
49 | } |
50 | requirement_group_id?: string |
51 | requirements?: { field_value: string; requirement_type_id: string }[] |
52 | user_feedback?: { user_rating?: number; user_comment?: string } |
53 | webhook_url?: string |
54 | customer_reference?: string |
55 | messaging?: { enable_messaging?: false | true } |
56 | } |
57 | ) { |
58 | const url = new URL(`https://api.telnyx.com/v2/porting_orders/${id}`) |
59 |
|
60 | const response = await fetch(url, { |
61 | method: 'PATCH', |
62 | headers: { |
63 | 'Content-Type': 'application/json', |
64 | Authorization: 'Bearer ' + auth.apiKey |
65 | }, |
66 | body: JSON.stringify(body) |
67 | }) |
68 | if (!response.ok) { |
69 | const text = await response.text() |
70 | throw new Error(`${response.status} ${text}`) |
71 | } |
72 | return await response.json() |
73 | } |
74 |
|