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