0
Creates a Master Aero based on the Aero Template with the Id provided.
One script reply has been approved by the moderators Verified
Created by hugo697 51 days ago Viewed 578 times
0
Submitted by hugo697 Bun
Verified 51 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
		renewalPattern: string
12
		autoRenew?: false | true
13
		isSunday?: false | true
14
		isMonday?: false | true
15
		isTuesday?: false | true
16
		isWednesday?: false | true
17
		isThursday?: false | true
18
		isFriday?: false | true
19
		isSaturday?: false | true
20
		isDayOfMonth?: false | true
21
		repeatEvery?: number
22
		numberOfDates?: number
23
		startDate?: string
24
		endOnDate?: string
25
		offset?: number
26
		customerId?: number
27
		teamMemberId?: number
28
		aeroGroupId?: number
29
		contactId?: number
30
	}
31
) {
32
	const url = new URL(
33
		`https://api.aeroworkflow.com/api/${accountid}/v1/MasterAeros/FromTemplate/${id}`
34
	)
35

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

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

50
	return await response.json()
51
}
52