Add feedback from message module

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
	keycode: string,
9
	identifier: string,
10
	body: { content?: string; module_id?: number; target_contact_id?: number }
11
) {
12
	const url = new URL(`https://actimo.com/api/v1/messages/${keycode}/feedback/${identifier}`)
13

14
	const response = await fetch(url, {
15
		method: 'POST',
16
		headers: {
17
			'Content-Type': 'application/json'
18
		},
19
		body: JSON.stringify(body)
20
	})
21

22
	if (!response.ok) {
23
		const text = await response.text()
24
		throw new Error(`${response.status} ${text}`)
25
	}
26

27
	return await response.json()
28
}
29