0
Create Banner
One script reply has been approved by the moderators Verified
Created by hugo697 16 days ago Viewed 1416 times
0
Submitted by hugo697 Bun
Verified 16 days ago
1
//native
2
type Adrapid = {
3
	token: string
4
}
5

6
export async function main(
7
	auth: Adrapid,
8
	body: {
9
		sizeIds?: 'all' | string[]
10
		sizes?: {}[]
11
		templateId?: string
12
		modes?: {
13
			html5?: { packed?: false | true; felxible?: false | true }
14
			amp?: false | true
15
			png?: false | true
16
			jpeg?: false | true
17
			pdf?: false | true
18
			webp?: false | true
19
			video?: {
20
				fps?: number
21
				crf?: number
22
				audio?: { offset?: number; src?: string }
23
			}
24
			gif?: { fps?: number; frames?: unknown[] }
25
		}
26
		clicktag?: string
27
		overrides?: {
28
			itemName?: {
29
				text?: string
30
				references?: { url?: string }
31
				url?: string
32
				css?: {}
33
			}
34
		}
35
		templateData?: {}
36
		sync?: false | true
37
		editable?: false | true
38
		excludeBaseSize?: false | true
39
	}
40
) {
41
	const url = new URL(`https://api.adrapid.com/banners`)
42

43
	const response = await fetch(url, {
44
		method: 'POST',
45
		headers: {
46
			'Content-Type': 'application/json',
47
			Authorization: 'Bearer ' + auth.token
48
		},
49
		body: JSON.stringify(body)
50
	})
51

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

57
	return await response.json()
58
}
59