0
Creates a Master Aero based on the Library Template with the Id provided.
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
	id: string,
10
	body: {
11
		scheduledTotalHours: number
12
		scheduledHours: number
13
		scheduledMinutes: number
14
		renewalPattern: string
15
		autoRenew?: false | true
16
		isSunday?: false | true
17
		isMonday?: false | true
18
		isTuesday?: false | true
19
		isWednesday?: false | true
20
		isThursday?: false | true
21
		isFriday?: false | true
22
		isSaturday?: false | true
23
		isDayOfMonth?: false | true
24
		billable?: false | true
25
		fixedFee?: false | true
26
		repeatEvery?: number
27
		numberOfDates?: number
28
		startDate?: string
29
		endOnDate?: string
30
		offset?: number
31
		priority: string
32
		aeroTypeId?: number
33
		teamMemberId?: number
34
		customerId?: number
35
		aeroGroupId?: number
36
		contactId?: number
37
		hatId?: number
38
		dayToDue?: number
39
	}
40
) {
41
	const url = new URL(
42
		`https://api.aeroworkflow.com/api/${accountid}/v1/MasterAeros/FromLibraryTemplate/${id}`
43
	)
44

45
	const response = await fetch(url, {
46
		method: 'POST',
47
		headers: {
48
			'Content-Type': 'application/json',
49
			apikey: auth.apiKey
50
		},
51
		body: JSON.stringify(body)
52
	})
53

54
	if (!response.ok) {
55
		const text = await response.text()
56
		throw new Error(`${response.status} ${text}`)
57
	}
58

59
	return await response.json()
60
}
61