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 | name: string |
11 | defaultEmailAddress?: string |
12 | phone?: string |
13 | website?: string |
14 | accountNumber?: string |
15 | fax?: string |
16 | hourlyBillableRate?: number |
17 | monthlyFixedFee?: number |
18 | contactFirstName?: string |
19 | contactLastName?: string |
20 | addressLine1?: string |
21 | addressLine2?: string |
22 | addressLine3?: string |
23 | addressCity?: string |
24 | addressState?: string |
25 | addressPostalCode?: string |
26 | addressCountry?: string |
27 | notes?: string |
28 | isLead?: false | true |
29 | } |
30 | ) { |
31 | const url = new URL(`https://api.aeroworkflow.com/api/${accountid}/v1/Companies`) |
32 |
|
33 | const response = await fetch(url, { |
34 | method: 'POST', |
35 | headers: { |
36 | 'Content-Type': 'application/json', |
37 | apikey: auth.apiKey |
38 | }, |
39 | body: JSON.stringify(body) |
40 | }) |
41 |
|
42 | if (!response.ok) { |
43 | const text = await response.text() |
44 | throw new Error(`${response.status} ${text}`) |
45 | } |
46 |
|
47 | return await response.json() |
48 | } |
49 |
|