0
Update message by id
One script reply has been approved by the moderators Verified
Created by hugo697 16 days ago Viewed 0 times
0
Submitted by hugo697 Bun
Verified 16 days ago
1
//native
2
type Actimo = {
3
	apiKey: string
4
}
5

6
export async function main(
7
	auth: Actimo,
8
	id: string,
9
	body: {
10
		active?: false | true
11
		add_to_homepage?: false | true
12
		allow_unsubscribe?: false | true
13
		anonymous?: false | true
14
		bookmarked?: false | true
15
		categories?: string[]
16
		channel_email?: false | true
17
		channel_email_from_address?: string
18
		channel_email_from_name?: string
19
		channel_email_subject?: string
20
		channel_ivr?: false | true
21
		channel_ivr_msisdn?: string
22
		channel_ivr_prefer_tollfree?: false | true
23
		channel_sms?: false | true
24
		channel_sms_from_name?: string
25
		channel_sms_msg_template?: string
26
		channel_sms_simple?: false | true
27
		channel_voiceblast?: false | true
28
		content_language?: string
29
		delay_till?: number
30
		delivery_days?: number[]
31
		delivery_hour_end?: number
32
		delivery_hour_start?: number
33
		delivery_preference?: string[]
34
		disable_deeplink?: false | true
35
		email_first_page?: false | true
36
		force_sms?: false | true
37
		ft?: string
38
		modules?: {
39
			'{module type}'?: { '{module id}'?: { header?: string; type?: string } }
40
		}
41
		must_read?: false | true
42
		name?: string
43
		open_limit?: number
44
		quiz_retake_interval?: number
45
		quiz_retake_max_attempts?: number
46
		quiz_retake_message?: string
47
		recurring_message_id?: number
48
		reminder_items?: string[]
49
		reminder_rules?: string[][]
50
		send_reminders?: false | true
51
		shared?: false | true
52
		starred?: string
53
		subject?: string
54
		tags?: {}[]
55
		template_id?: number
56
		voiceprofile_id?: number
57
		webhook_message_event_url?: string
58
	}
59
) {
60
	const url = new URL(`https://actimo.com/api/v1/messages/${id}`)
61

62
	const response = await fetch(url, {
63
		method: 'PUT',
64
		headers: {
65
			'api-key': auth.apiKey,
66
			'Content-Type': 'application/json'
67
		},
68
		body: JSON.stringify(body)
69
	})
70

71
	if (!response.ok) {
72
		const text = await response.text()
73
		throw new Error(`${response.status} ${text}`)
74
	}
75

76
	return await response.json()
77
}
78