//native
type Gorgias = {
username: string;
apiKey: string;
domain: string;
};
/**
* Update a ticket
*
*/
export async function main(
auth: Gorgias,
id: string,
body: {
assignee_team?: { id?: number };
assignee_user?: { id?: number };
channel?:
| "aircall"
| "api"
| "chat"
| "email"
| "facebook"
| "facebook-mention"
| "facebook-messenger"
| "facebook-recommendations"
| "help-center"
| "instagram-ad-comment"
| "instagram-comment"
| "instagram-mention"
| "instagram-direct-message"
| "internal-note"
| "phone"
| "sms"
| "twitter"
| "twitter-direct-message"
| "yotpo-review";
closed_datetime?: string;
customer?: { id?: number; email?: string };
external_id?: string;
from_agent?: false | true;
is_unread?: false | true;
language?: string;
last_message_datetime?: string;
last_received_message_datetime?: string;
meta?: {};
opened_datetime?: string;
snooze_datetime?: string;
spam?: false | true;
status?: "open" | "closed";
subject?: string;
tags?: { name?: string }[];
trashed_datetime?: string;
updated_datetime?: string;
via?:
| "aircall"
| "api"
| "chat"
| "email"
| "facebook"
| "facebook-mention"
| "facebook-messenger"
| "facebook-recommendations"
| "help-center"
| "instagram-ad-comment"
| "instagram-comment"
| "instagram-mention"
| "instagram-direct-message"
| "internal-note"
| "phone"
| "sms"
| "twitter"
| "twitter-direct-message"
| "yotpo-review"
| "twilio"
| "zendesk"
| "form"
| "self_service"
| "yotpo"
| "instagram"
| "shopify"
| "gorgias_chat"
| "rule"
| "helpdesk";
},
) {
const url = new URL(`https://${auth.domain}.gorgias.com/api/tickets/${id}/`);
const response = await fetch(url, {
method: "PUT",
headers: {
"Content-Type": "application/json",
Authorization: "Basic " + btoa(`${auth.username}:${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