type Zendesk = {
username: string;
password: string;
subdomain: string;
};
/**
* Update Trigger Category
* Updates the trigger category with the specified ID.
*/
export async function main(
auth: Zendesk,
trigger_category_id: string,
body: {
trigger_category?: {
name?: string;
position?: string;
[k: string]: unknown;
};
[k: string]: unknown;
}
) {
const url = new URL(
`https://${auth.subdomain}.zendesk.com/api/v2/trigger_categories/${trigger_category_id}`
);
const response = await fetch(url, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
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 377 days ago
type Zendesk = {
username: string;
password: string;
subdomain: string;
};
/**
* Update Trigger Category
* Updates the trigger category with the specified ID.
*/
export async function main(
auth: Zendesk,
trigger_category_id: string,
body: {
trigger_category?: {
name?: string;
position?: string;
[k: string]: unknown;
};
[k: string]: unknown;
}
) {
const url = new URL(
`https://${auth.subdomain}.zendesk.com/api/v2/trigger_categories/${trigger_category_id}`
);
const response = await fetch(url, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
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 923 days ago