| 1 | 
 | 
 | 2 | type Aero_workflow = {
 | 
 | 3 | 	apiKey: string
 | 
 | 4 | }
 | 
 | 5 | 
 | 
 | 6 | export async function main(
 | 
 | 7 | 	auth: Aero_workflow,
 | 
 | 8 | 	accountid: string,
 | 
 | 9 | 	category: string,
 | 
 | 10 | 	aeroId: string,
 | 
 | 11 | 	body: {
 | 
 | 12 | 		teamMember: string
 | 
 | 13 | 		totalHoursWorked: number
 | 
 | 14 | 		date: string
 | 
 | 15 | 		note?: string
 | 
 | 16 | 		hourlyRate?: number
 | 
 | 17 | 		hourlyCostRate?: number
 | 
 | 18 | 		billable?: false | true
 | 
 | 19 | 		fixedFee?: false | true
 | 
 | 20 | 	}
 | 
 | 21 | ) {
 | 
 | 22 | 	const url = new URL(
 | 
 | 23 | 		`https://api.aeroworkflow.com/api/${accountid}/v1/Aero${category}s/${aeroId}/AeroTimes`
 | 
 | 24 | 	)
 | 
 | 25 | 
 | 
 | 26 | 	const response = await fetch(url, {
 | 
 | 27 | 		method: 'POST',
 | 
 | 28 | 		headers: {
 | 
 | 29 | 			'Content-Type': 'application/json',
 | 
 | 30 | 			apikey: auth.apiKey
 | 
 | 31 | 		},
 | 
 | 32 | 		body: JSON.stringify(body)
 | 
 | 33 | 	})
 | 
 | 34 | 
 | 
 | 35 | 	if (!response.ok) {
 | 
 | 36 | 		const text = await response.text()
 | 
 | 37 | 		throw new Error(`${response.status} ${text}`)
 | 
 | 38 | 	}
 | 
 | 39 | 
 | 
 | 40 | 	return await response.json()
 | 
 | 41 | }
 | 
 | 42 | 
 |