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

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

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

49
	return await response.json()
50
}
51