1 |
|
2 | type Actimo = { |
3 | apiKey: string |
4 | } |
5 |
|
6 | export async function main( |
7 | auth: Actimo, |
8 | body: { |
9 | task_args: { |
10 | workspaceId: string |
11 | fields: { |
12 | companyGroups: |
13 | | 'activity_id' |
14 | | 'activity_type' |
15 | | 'timestamp' |
16 | | 'parent_id' |
17 | | 'post_id' |
18 | | 'contact_id' |
19 | | 'workspace'[] |
20 | privateGroups: 'activity_id' | 'activity_type' | 'timestamp' | 'parent_id' | 'post_id'[] |
21 | contacts: |
22 | | 'id' |
23 | | 'employeeId' |
24 | | 'name' |
25 | | 'email' |
26 | | 'addr_country' |
27 | | 'department' |
28 | | 'title' |
29 | | 'company' |
30 | | 'company_reg' |
31 | | 'addr_line_1' |
32 | | 'addr_line_2' |
33 | | 'addr_state' |
34 | | 'addr_city' |
35 | | 'addr_zip' |
36 | | 'timezone' |
37 | | 'country_code' |
38 | | 'phone_number' |
39 | | 'tags' |
40 | | 'source_data' |
41 | | 'opt_out' |
42 | | 'manager_id' |
43 | | 'group_names'[] |
44 | } |
45 | interval: { from: string; to: string } |
46 | timezone: string |
47 | } |
48 | task_name: 'generate_social_wall_report' |
49 | task_type: 'social_wall' |
50 | } |
51 | ) { |
52 | const url = new URL(`https://actimo.com/api/v1/tasks/`) |
53 |
|
54 | const response = await fetch(url, { |
55 | method: 'POST', |
56 | headers: { |
57 | 'api-key': auth.apiKey, |
58 | 'Content-Type': 'application/json' |
59 | }, |
60 | body: JSON.stringify(body) |
61 | }) |
62 |
|
63 | if (!response.ok) { |
64 | const text = await response.text() |
65 | throw new Error(`${response.status} ${text}`) |
66 | } |
67 |
|
68 | return await response.json() |
69 | } |
70 |
|