// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../core/resource'; import * as Shared from '../shared'; import * as AccountsAPI from '../accounts/accounts'; import * as MessagesAPI from './messages'; import { MessageRedactParams, MessageRedactResponse, Messages } from './messages'; import { APIPromise } from '../../core/api-promise'; import { PagePromise, PylonCursorPage, type PylonCursorPageParams, PylonSearchPage, type PylonSearchPageParams, } from '../../core/pagination'; import { RequestOptions } from '../../internal/request-options'; import { path } from '../../internal/utils/path'; export class Issues extends APIResource { messages: MessagesAPI.Messages = new MessagesAPI.Messages(this._client); /** * Create a new issue */ create(body: IssueCreateParams, options?: RequestOptions): APIPromise { return this._client.post('/issues', { body, ...options }); } /** * Get an issue by its ID/number */ retrieve(id: string, options?: RequestOptions): APIPromise { return this._client.get(path`/issues/${id}`, options); } /** * Update an existing issue */ update(id: string, body: IssueUpdateParams, options?: RequestOptions): APIPromise { return this._client.patch(path`/issues/${id}`, { body, ...options }); } /** * Get a list of issues */ list(query: IssueListParams, options?: RequestOptions): PagePromise { return this._client.getAPIList('/issues', PylonCursorPage, { query, ...options }); } /** * Delete an existing issue */ delete(id: string, options?: RequestOptions): APIPromise { return this._client.delete(path`/issues/${id}`, options); } /** * Search for issues by a given filter */ search(body: IssueSearchParams, options?: RequestOptions): PagePromise { return this._client.getAPIList('/issues/search', PylonSearchPage, { body, method: 'post', ...options, }); } /** * Snooze an issue */ snooze(id: string, body: IssueSnoozeParams, options?: RequestOptions): APIPromise { return this._client.post(path`/issues/${id}/snooze`, { body, ...options }); } } export type IssuesPylonCursorPage = PylonCursorPage; export type IssuesPylonSearchPage = PylonSearchPage; export interface Issue { id: string; created_at: string; number: number; source: 'slack' | 'email' | 'chat' | 'api' | 'microsoft_teams' | 'discord'; state: string; type: 'Conversation' | 'Triage'; account?: Issue.Account; assignee?: AccountsAPI.UserReference; body_html?: string; business_hours_first_response_seconds?: number; business_hours_resolution_seconds?: number; chat_widget_info?: Issue.ChatWidgetInfo; csat_responses?: Array; custom_fields?: { [key: string]: Shared.CustomFieldValue }; customer_portal_visible?: boolean; external_issues?: Array; first_response_seconds?: number; first_response_time?: string; latest_message_time?: string; link?: string; number_of_touches?: number; requester?: AccountsAPI.UserReference; resolution_seconds?: number; resolution_time?: string; slack?: Issue.Slack; snoozed_until_time?: string; tags?: Array; team?: Issue.Team; title?: string; } export namespace Issue { export interface Account { id?: string; } export interface ChatWidgetInfo { page_url?: string; } export interface CsatResponse { comment?: string; score?: number; } export interface ExternalIssue { external_id?: string; link?: string; source?: string; } export interface Slack { channel_id?: string; message_ts?: string; } export interface Team { id?: string; } } export interface IssueResponse { data?: Issue; request_id?: string; } export interface IssueDeleteResponse { request_id?: string; } export interface IssueCreateParams { /** * The title of the issue */ title: string; /** * The account that this issue belongs to */ account_id?: string; /** * The user the issue should be assigned to */ assignee_id?: string; /** * An array of attachment URLs to attach to this issue */ attachment_urls?: Array; /** * The HTML content of the body of the issue */ body_html?: string; /** * Timestamp of when the issue was created (RFC3339) */ created_at?: string; /** * An array of custom fields to be used on this issue */ custom_fields?: Array; destination_metadata?: IssueCreateParams.DestinationMetadata; /** * The priority of the issue */ priority?: 'urgent' | 'high' | 'medium' | 'low'; /** * The URL of an avatar of the requester */ requester_avatar_url?: string; /** * The email of the user that this issue is on behalf of */ requester_email?: string; /** * The requester that this issue is on behalf of */ requester_id?: string; /** * The full name of the user that this issue is on behalf of */ requester_name?: string; /** * An array of strings to use as tags on this issue */ tags?: Array; /** * The ID of the team this issue should be assigned to */ team_id?: string; } export namespace IssueCreateParams { export interface DestinationMetadata { /** * How communication will be delivered to the customer */ destination?: 'slack' | 'email' | 'chat' | 'internal'; /** * Email address for email destination */ email?: string; /** * BCC email addresses */ email_bccs?: Array; /** * CC email addresses */ email_ccs?: Array; } } export interface IssueUpdateParams { /** * The ID of the user who should be assigned to this issue */ assignee_id?: string; /** * An array of custom fields to be used on this issue */ custom_fields?: Array; /** * Whether the issue should be visible in the customer portal */ customer_portal_visible?: boolean; /** * The ID of the requester that this issue is on behalf of */ requester_id?: string; /** * @deprecated Deprecated. Use requester_id instead */ requestor_id?: string; /** * The state this issue should be moved to */ state?: 'new' | 'waiting_on_you' | 'waiting_on_customer' | 'on_hold' | 'closed'; /** * An array of strings to use as tags on this issue */ tags?: Array; /** * The ID of the team this issue should be assigned to */ team_id?: string; } export interface IssueListParams extends PylonCursorPageParams { /** * The end time in RFC3339 format. Must be within 30 days of start_time */ end_time: string; /** * The start time in RFC3339 format */ start_time: string; } export interface IssueSearchParams extends PylonSearchPageParams {} export interface IssueSnoozeParams { /** * RFC3339 timestamp of when to unsnooze the issue */ snooze_until_time: string; } Issues.Messages = Messages; export declare namespace Issues { export { type Issue as Issue, type IssueResponse as IssueResponse, type IssueDeleteResponse as IssueDeleteResponse, type IssuesPylonCursorPage as IssuesPylonCursorPage, type IssuesPylonSearchPage as IssuesPylonSearchPage, type IssueCreateParams as IssueCreateParams, type IssueUpdateParams as IssueUpdateParams, type IssueListParams as IssueListParams, type IssueSearchParams as IssueSearchParams, type IssueSnoozeParams as IssueSnoozeParams, }; export { Messages as Messages, type MessageRedactResponse as MessageRedactResponse, type MessageRedactParams as MessageRedactParams, }; }