1 |
|
2 | type Actimo = { |
3 | apiKey: string |
4 | } |
5 |
|
6 | export async function main( |
7 | auth: Actimo, |
8 | body: { |
9 | active?: false | true |
10 | add_to_homepage?: false | true |
11 | allow_unsubscribe?: false | true |
12 | anonymous?: false | true |
13 | bookmarked?: false | true |
14 | categories?: string[] |
15 | channel_email?: false | true |
16 | channel_email_from_address?: string |
17 | channel_email_from_name?: string |
18 | channel_email_subject?: string |
19 | channel_ivr?: false | true |
20 | channel_ivr_msisdn?: string |
21 | channel_ivr_prefer_tollfree?: false | true |
22 | channel_sms?: false | true |
23 | channel_sms_from_name?: string |
24 | channel_sms_msg_template?: string |
25 | channel_sms_simple?: false | true |
26 | channel_voiceblast?: false | true |
27 | content_language?: string |
28 | delay_till?: number |
29 | delivery_days?: number[] |
30 | delivery_hour_end?: number |
31 | delivery_hour_start?: number |
32 | delivery_preference?: string[] |
33 | disable_deeplink?: false | true |
34 | email_first_page?: false | true |
35 | force_sms?: false | true |
36 | ft?: string |
37 | modules?: { |
38 | '{module type}'?: { '{module id}'?: { header?: string; type?: string } } |
39 | } |
40 | must_read?: false | true |
41 | name?: string |
42 | open_limit?: number |
43 | quiz_retake_interval?: number |
44 | quiz_retake_max_attempts?: number |
45 | quiz_retake_message?: string |
46 | recurring_message_id?: number |
47 | reminder_items?: string[] |
48 | reminder_rules?: string[][] |
49 | send_reminders?: false | true |
50 | shared?: false | true |
51 | starred?: string |
52 | subject?: string |
53 | tags?: {}[] |
54 | template_id?: number |
55 | voiceprofile_id?: number |
56 | webhook_message_event_url?: string |
57 | } |
58 | ) { |
59 | const url = new URL(`https://actimo.com/api/v1/messages/`) |
60 |
|
61 | const response = await fetch(url, { |
62 | method: 'POST', |
63 | headers: { |
64 | 'api-key': auth.apiKey, |
65 | 'Content-Type': 'application/json' |
66 | }, |
67 | body: JSON.stringify(body) |
68 | }) |
69 |
|
70 | if (!response.ok) { |
71 | const text = await response.text() |
72 | throw new Error(`${response.status} ${text}`) |
73 | } |
74 |
|
75 | return await response.json() |
76 | } |
77 |
|