//native
type Kustomer = {
apiKey: string;
};
/**
* Update a shortcut
* Updates a shortcut by ID.
*/
export async function main(
auth: Kustomer,
id: string,
body: {
name?: string;
parent?: string;
draft?: { text?: string; template?: string };
payload?: {};
accessTeams?: string[];
accessUsers?: string[];
conversation?: {
tags?: { operator?: "append" | "replace" | "remove"; value?: string[] };
name?: { operator?: "replace" | "remove"; value?: string };
status?: { operator?: "replace" | "remove"; value?: "open" | "done" };
subStatus?: { operator?: "replace" | "remove"; value?: string };
snooze?: { operator?: "replace"; value?: string };
queue?: { operator?: "replace"; value?: {} };
assignedUsers?: {
operator?: "append" | "replace" | "remove";
value?: unknown[];
};
assignedTeams?: {
operator?: "append" | "replace" | "remove";
value?: unknown[];
};
custom?: {};
};
deleted?: false | true;
},
) {
const url = new URL(`https://api.kustomerapp.com/v1/shortcuts/${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