diff --git a/src/services/unthread.ts b/src/services/unthread.ts index 038a1f8..d94e1d2 100644 --- a/src/services/unthread.ts +++ b/src/services/unthread.ts @@ -80,6 +80,14 @@ interface SendMessageJSONParams { onBehalfOf: OnBehalfOfUser; } +/** + * Ticket creation response + */ +interface CreateTicketResponse { + id: string; + friendlyId: string; +} + /** * Extracts and formats the customer company name from a Telegram group chat title by removing the bot's company name and handling various separators. * @@ -235,7 +243,7 @@ export async function createCustomer(groupChatName: string): Promise { * @param params - Includes group chat name, customer ID, ticket summary, and user information on whose behalf the ticket is created. * @returns The created ticket object from Unthread. */ -export async function createTicket(params: CreateTicketParams): Promise { +export async function createTicket(params: CreateTicketParams): Promise { try { const { groupChatName, customerId, summary, onBehalfOf } = params; @@ -262,7 +270,7 @@ export async function createTicket(params: CreateTicketParams): Promise { * @returns An object containing the ticket's unique ID and friendly ID * @throws If the API request fails or returns a non-OK response */ -async function createTicketJSON(params: CreateTicketJSONParams): Promise { +async function createTicketJSON(params: CreateTicketJSONParams): Promise { const { title, summary, customerId, onBehalfOf } = params; const payload = { @@ -289,7 +297,7 @@ async function createTicketJSON(params: CreateTicketJSONParams): Promise { throw new Error(`Failed to create ticket: ${response.status} ${errorText}`); } - const result = await response.json() as { id: string; friendlyId: string }; + const result = await response.json() as CreateTicketResponse; LogEngine.info('Ticket created (JSON)', { ticketTitle: title,