1 |
|
2 | type Aero_workflow = { |
3 | apiKey: string |
4 | } |
5 |
|
6 | export async function main( |
7 | auth: Aero_workflow, |
8 | accountid: string, |
9 | body: { |
10 | firstName: string |
11 | lastName: string |
12 | defaultEmailAddress?: string |
13 | officePhone?: string |
14 | homePhone?: string |
15 | mobilePhone?: string |
16 | facebookUrl?: string |
17 | linkedInUrl?: string |
18 | title?: string |
19 | twitterHandle?: string |
20 | notes?: string |
21 | } |
22 | ) { |
23 | const url = new URL(`https://api.aeroworkflow.com/api/${accountid}/v1/Contacts`) |
24 |
|
25 | const response = await fetch(url, { |
26 | method: 'POST', |
27 | headers: { |
28 | 'Content-Type': 'application/json', |
29 | apikey: auth.apiKey |
30 | }, |
31 | body: JSON.stringify(body) |
32 | }) |
33 |
|
34 | if (!response.ok) { |
35 | const text = await response.text() |
36 | throw new Error(`${response.status} ${text}`) |
37 | } |
38 |
|
39 | return await response.json() |
40 | } |
41 |
|