0
Creates a new Email Aero.
One script reply has been approved by the moderators Verified
Created by hugo697 16 days ago Viewed 0 times
0
Submitted by hugo697 Bun
Verified 16 days ago
1
//native
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
		fromEmail?: string
21
		toEmail?: string
22
		ccEmail?: string
23
		bccEmail?: string
24
		comments?: string
25
		fullProjectName?: string
26
		hat?: string
27
		company?: string
28
		contact?: string
29
		body?: string
30
		incomingEmail?: false | true
31
		billable?: false | true
32
		fixedFee?: false | true
33
	}
34
) {
35
	const url = new URL(`https://api.aeroworkflow.com/api/${accountid}/v1/AeroEmails`)
36

37
	const response = await fetch(url, {
38
		method: 'POST',
39
		headers: {
40
			'Content-Type': 'application/json',
41
			apikey: auth.apiKey
42
		},
43
		body: JSON.stringify(body)
44
	})
45

46
	if (!response.ok) {
47
		const text = await response.text()
48
		throw new Error(`${response.status} ${text}`)
49
	}
50

51
	return await response.json()
52
}
53