Create content item of type

Script actimo Verified

by hugo697 ยท 11/5/2024

The script

Submitted by hugo697 Bun
Verified 572 days ago
1
//native
2
type Actimo = {
3
	apiKey: string
4
}
5

6
export async function main(
7
	auth: Actimo,
8
	type: string,
9
	body: { description?: string; title?: string; video_filters?: string } & {
10
		branding_bg_color?: string
11
		branding_bg_image_url?: string
12
		branding_bg_media_file_id?: number
13
		branding_title?: string
14
		duration?: number
15
		file_ext?: string
16
		file_name?: string
17
		file_path?: string
18
		file_size?: number
19
		file_type?: string
20
		full_path?: string
21
		header?: string
22
		menu_data?: {}
23
		metadata?: string
24
		orig_name?: string
25
		raw_name?: string
26
		shared?: false | true
27
		show_branding?: false | true
28
		show_branding_bg_image?: false | true
29
		tags?: string[]
30
	}
31
) {
32
	const url = new URL(`https://actimo.com/api/v1/content/${type}`)
33

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

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

48
	return await response.json()
49
}
50