Updates the current work session.
1
//native
2
type Kustomer = {
3
apiKey: string;
4
};
5
/**
6
* Update current work session
7
* Updates the current work session.
8
*/
9
export async function main(
10
auth: Kustomer,
11
body: { status: string; team?: string },
12
) {
13
const url = new URL(
14
`https://api.kustomerapp.com/v1/routing/work-sessions/current`,
15
);
16
17
const response = await fetch(url, {
18
method: "PUT",
19
headers: {
20
"Content-Type": "application/json",
21
Authorization: "Bearer " + auth.apiKey,
22
},
23
body: JSON.stringify(body),
24
});
25
if (!response.ok) {
26
const text = await response.text();
27
throw new Error(`${response.status} ${text}`);
28
}
29
return await response.json();
30
31