1 | |
2 | type Actimo = { |
3 | apiKey: string |
4 | } |
5 |
|
6 | export async function main( |
7 | auth: Actimo, |
8 | id: string, |
9 | trainingId: string, |
10 | body: { sectionId?: string; indexTrainingPosition?: number } |
11 | ) { |
12 | const url = new URL(`https://actimo.com/api/v1/academy/${id}/training/${trainingId}/duplicate`) |
13 |
|
14 | const response = await fetch(url, { |
15 | method: 'POST', |
16 | headers: { |
17 | 'api-key': auth.apiKey, |
18 | 'Content-Type': 'application/json' |
19 | }, |
20 | body: JSON.stringify(body) |
21 | }) |
22 |
|
23 | if (!response.ok) { |
24 | const text = await response.text() |
25 | throw new Error(`${response.status} ${text}`) |
26 | } |
27 |
|
28 | return await response.json() |
29 | } |
30 |
|