//native
type Kustomer = {
apiKey: string;
};
/**
* Update work item
* Updates a work item based on its unique ID.
*/
export async function main(
auth: Kustomer,
id: string,
body: {
queue?: {};
routed?:
| { to: string; at?: string }
| { rejectedBy: string }
| { timedout: false | true };
accepted?: { at?: string; by: string; workSession?: string };
status?: "assigned" | "wrap-up" | "completed";
paused?: false | true;
assignedTo?: string;
rev: number;
resource?: { rev?: number };
},
) {
const url = new URL(
`https://api.kustomerapp.com/v1/routing/work-items/${id}`,
);
const response = await fetch(url, {
method: "PUT",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.apiKey,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago