1 | |
2 | |
3 | * Update organization structure |
4 | * Update worker's department |
5 | **Token scopes**: `people:write` |
6 | */ |
7 | export async function main( |
8 | auth: RT.Deel, |
9 | id: string, |
10 | body: Body, |
11 | replace_other_positions?: string | undefined |
12 | ) { |
13 | const url = new URL(`https://api.letsdeel.com/rest/v2/people/${id}/department`) |
14 | for (const [k, v] of [['replace_other_positions', replace_other_positions]]) { |
15 | if (v !== undefined && v !== '') { |
16 | url.searchParams.append(k, v) |
17 | } |
18 | } |
19 | const response = await fetch(url, { |
20 | method: 'PUT', |
21 | headers: { |
22 | 'Content-Type': 'application/json', |
23 | Authorization: 'Bearer ' + auth.apiKey |
24 | }, |
25 | body: JSON.stringify(body) |
26 | }) |
27 | if (!response.ok) { |
28 | const text = await response.text() |
29 | throw new Error(`${response.status} ${text}`) |
30 | } |
31 | return await response.json() |
32 | } |
33 |
|
34 | |
35 | |
36 | * This file was automatically generated by json-schema-to-typescript. |
37 | * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, |
38 | * and run json-schema-to-typescript to regenerate this file. |
39 | */ |
40 |
|
41 | export interface Body { |
42 | data: { |
43 | |
44 | * Unique identifier of this resource. |
45 | */ |
46 | department_id: string |
47 | [k: string]: unknown |
48 | } |
49 | [k: string]: unknown |
50 | } |
51 |
|