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 | scheduledStartDate: string |
11 | scheduledTotalHours: number |
12 | scheduledHours: number |
13 | scheduledMinutes: number |
14 | assignedTo: string |
15 | aeroType: string |
16 | subject: string |
17 | priority: string |
18 | status: string |
19 | dueDate?: string |
20 | fullProjectName?: string |
21 | hat?: string |
22 | company?: string |
23 | contact?: string |
24 | description?: string |
25 | billable?: false | true |
26 | fixedFee?: false | true |
27 | } |
28 | ) { |
29 | const url = new URL(`https://api.aeroworkflow.com/api/${accountid}/v1/AeroTasks`) |
30 |
|
31 | const response = await fetch(url, { |
32 | method: 'POST', |
33 | headers: { |
34 | 'Content-Type': 'application/json', |
35 | apikey: auth.apiKey |
36 | }, |
37 | body: JSON.stringify(body) |
38 | }) |
39 |
|
40 | if (!response.ok) { |
41 | const text = await response.text() |
42 | throw new Error(`${response.status} ${text}`) |
43 | } |
44 |
|
45 | return await response.json() |
46 | } |
47 |
|