Updates data associated with user

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
	body: {
9
		country_code?: string
10
		default_group_id?: number
11
		default_theme_id?: number
12
		delivery_preference?: string
13
		department?: string
14
		email?: string
15
		favourite_group_id?: number
16
		first_name?: string
17
		force_sms?: number
18
		last_name?: string
19
		list_settings?: {}
20
		locale?: string
21
		phone_number?: string
22
		preferences?: {}
23
		setting_message_channel_email_from_address_default?: string
24
		setting_message_channel_email_from_name_default?: string
25
		setting_message_channel_sms_from_name_default?: string
26
		setting_message_channel_sms_msg_template_default?: string
27
		setting_send_reminders_default?: false | true
28
		test_phone_number?: string
29
		test_phone_number_code?: string
30
		ui_view_settings?: string
31
		webhook_message_event_url?: string
32
	}
33
) {
34
	const url = new URL(`https://actimo.com/api/v1/account/user`)
35

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

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

50
	return await response.json()
51
}
52