1 | |
2 | type Motimate = { |
3 | token: string |
4 | } |
5 |
|
6 | export async function main( |
7 | auth: Motimate, |
8 | body: { |
9 | external_id?: string |
10 | email?: string |
11 | employee_number: string |
12 | first_name?: string |
13 | last_name?: string |
14 | phone_number: string |
15 | imported?: false | true |
16 | organization_role: |
17 | | 'chief_editor' |
18 | | 'normal_user' |
19 | | 'organization_admin' |
20 | | 'pulse_editor' |
21 | | 'training_editor' |
22 | preferred_language?: |
23 | | 'cs' |
24 | | 'da' |
25 | | 'de' |
26 | | 'en' |
27 | | 'es' |
28 | | 'fi' |
29 | | 'fr' |
30 | | 'hr' |
31 | | 'hu' |
32 | | 'it' |
33 | | 'lt' |
34 | | 'lv' |
35 | | 'nb' |
36 | | 'nl' |
37 | | 'nn' |
38 | | 'pl' |
39 | | 'pt' |
40 | | 'ro' |
41 | | 'ru' |
42 | | 'se' |
43 | | 'sq' |
44 | | 'sr' |
45 | | 'sv' |
46 | | 'tr' |
47 | status?: 'active' | 'inactive' | 'manually_activated' | 'manually_deactivated' |
48 | } |
49 | ) { |
50 | const url = new URL(`https://motimateapp.com/public_api/users`) |
51 |
|
52 | const response = await fetch(url, { |
53 | method: 'POST', |
54 | headers: { |
55 | 'Content-Type': 'application/json', |
56 | Authorization: 'Bearer ' + auth.token |
57 | }, |
58 | body: JSON.stringify(body) |
59 | }) |
60 |
|
61 | if (!response.ok) { |
62 | const text = await response.text() |
63 | throw new Error(`${response.status} ${text}`) |
64 | } |
65 |
|
66 | return await response.json() |
67 | } |
68 |
|