/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { Assignee, Assignee$inboundSchema, Assignee$Outbound, Assignee$outboundSchema, } from "./assignee.js"; import { AssigneeInput, AssigneeInput$inboundSchema, AssigneeInput$Outbound, AssigneeInput$outboundSchema, } from "./assigneeinput.js"; import { CollectionTag, CollectionTag$inboundSchema, CollectionTag$Outbound, CollectionTag$outboundSchema, } from "./collectiontag.js"; import { CollectionTagInput, CollectionTagInput$inboundSchema, CollectionTagInput$Outbound, CollectionTagInput$outboundSchema, } from "./collectiontaginput.js"; import { CustomMappings, CustomMappings$inboundSchema, CustomMappings$Outbound, CustomMappings$outboundSchema, } from "./custommappings.js"; import { PassThroughBody, PassThroughBody$inboundSchema, PassThroughBody$Outbound, PassThroughBody$outboundSchema, } from "./passthroughbody.js"; /** * Priority of the ticket */ export const Priority = { Low: "low", Normal: "normal", High: "high", Urgent: "urgent", } as const; /** * Priority of the ticket */ export type Priority = ClosedEnum; export type Ticket = { /** * A unique identifier for an object. */ id: string; /** * The ticket's parent ID */ parentId?: string | null | undefined; /** * The ticket's collection ID */ collectionId?: string | null | undefined; /** * The ticket's type */ type?: string | null | undefined; /** * Subject of the ticket */ subject?: string | null | undefined; /** * The ticket's description. HTML version of description is mapped if supported by the third-party platform */ description?: string | null | undefined; /** * The current status of the ticket. Possible values include: open, in_progress, closed, or - in cases where there is no clear mapping - the original value passed through. */ status?: string | null | undefined; /** * Priority of the ticket */ priority?: Priority | null | undefined; assignees?: Array | undefined; /** * The date and time when the object was last updated. */ updatedAt?: Date | null | undefined; /** * The date and time when the object was created. */ createdAt?: Date | null | undefined; /** * The user who created the object. */ createdBy?: string | null | undefined; /** * Due date of the ticket */ dueDate?: Date | null | undefined; /** * When the ticket was completed */ completedAt?: Date | null | undefined; tags?: Array | undefined; /** * When custom mappings are configured on the resource, the result is included here. */ customMappings?: CustomMappings | null | undefined; /** * The pass_through property allows passing service-specific, custom data or structured modifications in request body when creating or updating resources. */ passThrough?: Array | undefined; }; export type TicketInput = { /** * The ticket's parent ID */ parentId?: string | null | undefined; /** * The ticket's type */ type?: string | null | undefined; /** * Subject of the ticket */ subject?: string | null | undefined; /** * The ticket's description. HTML version of description is mapped if supported by the third-party platform */ description?: string | null | undefined; /** * The current status of the ticket. Possible values include: open, in_progress, closed, or - in cases where there is no clear mapping - the original value passed through. */ status?: string | null | undefined; /** * Priority of the ticket */ priority?: Priority | null | undefined; assignees?: Array | undefined; /** * Due date of the ticket */ dueDate?: Date | null | undefined; tags?: Array | undefined; /** * The pass_through property allows passing service-specific, custom data or structured modifications in request body when creating or updating resources. */ passThrough?: Array | undefined; }; /** @internal */ export const Priority$inboundSchema: z.ZodNativeEnum = z .nativeEnum(Priority); /** @internal */ export const Priority$outboundSchema: z.ZodNativeEnum = Priority$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Priority$ { /** @deprecated use `Priority$inboundSchema` instead. */ export const inboundSchema = Priority$inboundSchema; /** @deprecated use `Priority$outboundSchema` instead. */ export const outboundSchema = Priority$outboundSchema; } /** @internal */ export const Ticket$inboundSchema: z.ZodType = z .object({ id: z.string(), parent_id: z.nullable(z.string()).optional(), collection_id: z.nullable(z.string()).optional(), type: z.nullable(z.string()).optional(), subject: z.nullable(z.string()).optional(), description: z.nullable(z.string()).optional(), status: z.nullable(z.string()).optional(), priority: z.nullable(Priority$inboundSchema).optional(), assignees: z.array(Assignee$inboundSchema).optional(), updated_at: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), created_at: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), created_by: z.nullable(z.string()).optional(), due_date: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), completed_at: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), tags: z.array(CollectionTag$inboundSchema).optional(), custom_mappings: z.nullable(CustomMappings$inboundSchema).optional(), pass_through: z.array(PassThroughBody$inboundSchema).optional(), }).transform((v) => { return remap$(v, { "parent_id": "parentId", "collection_id": "collectionId", "updated_at": "updatedAt", "created_at": "createdAt", "created_by": "createdBy", "due_date": "dueDate", "completed_at": "completedAt", "custom_mappings": "customMappings", "pass_through": "passThrough", }); }); /** @internal */ export type Ticket$Outbound = { id: string; parent_id?: string | null | undefined; collection_id?: string | null | undefined; type?: string | null | undefined; subject?: string | null | undefined; description?: string | null | undefined; status?: string | null | undefined; priority?: string | null | undefined; assignees?: Array | undefined; updated_at?: string | null | undefined; created_at?: string | null | undefined; created_by?: string | null | undefined; due_date?: string | null | undefined; completed_at?: string | null | undefined; tags?: Array | undefined; custom_mappings?: CustomMappings$Outbound | null | undefined; pass_through?: Array | undefined; }; /** @internal */ export const Ticket$outboundSchema: z.ZodType< Ticket$Outbound, z.ZodTypeDef, Ticket > = z.object({ id: z.string(), parentId: z.nullable(z.string()).optional(), collectionId: z.nullable(z.string()).optional(), type: z.nullable(z.string()).optional(), subject: z.nullable(z.string()).optional(), description: z.nullable(z.string()).optional(), status: z.nullable(z.string()).optional(), priority: z.nullable(Priority$outboundSchema).optional(), assignees: z.array(Assignee$outboundSchema).optional(), updatedAt: z.nullable(z.date().transform(v => v.toISOString())).optional(), createdAt: z.nullable(z.date().transform(v => v.toISOString())).optional(), createdBy: z.nullable(z.string()).optional(), dueDate: z.nullable(z.date().transform(v => v.toISOString())).optional(), completedAt: z.nullable(z.date().transform(v => v.toISOString())).optional(), tags: z.array(CollectionTag$outboundSchema).optional(), customMappings: z.nullable(CustomMappings$outboundSchema).optional(), passThrough: z.array(PassThroughBody$outboundSchema).optional(), }).transform((v) => { return remap$(v, { parentId: "parent_id", collectionId: "collection_id", updatedAt: "updated_at", createdAt: "created_at", createdBy: "created_by", dueDate: "due_date", completedAt: "completed_at", customMappings: "custom_mappings", passThrough: "pass_through", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Ticket$ { /** @deprecated use `Ticket$inboundSchema` instead. */ export const inboundSchema = Ticket$inboundSchema; /** @deprecated use `Ticket$outboundSchema` instead. */ export const outboundSchema = Ticket$outboundSchema; /** @deprecated use `Ticket$Outbound` instead. */ export type Outbound = Ticket$Outbound; } export function ticketToJSON(ticket: Ticket): string { return JSON.stringify(Ticket$outboundSchema.parse(ticket)); } export function ticketFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Ticket$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Ticket' from JSON`, ); } /** @internal */ export const TicketInput$inboundSchema: z.ZodType< TicketInput, z.ZodTypeDef, unknown > = z.object({ parent_id: z.nullable(z.string()).optional(), type: z.nullable(z.string()).optional(), subject: z.nullable(z.string()).optional(), description: z.nullable(z.string()).optional(), status: z.nullable(z.string()).optional(), priority: z.nullable(Priority$inboundSchema).optional(), assignees: z.array(AssigneeInput$inboundSchema).optional(), due_date: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), tags: z.array(CollectionTagInput$inboundSchema).optional(), pass_through: z.array(PassThroughBody$inboundSchema).optional(), }).transform((v) => { return remap$(v, { "parent_id": "parentId", "due_date": "dueDate", "pass_through": "passThrough", }); }); /** @internal */ export type TicketInput$Outbound = { parent_id?: string | null | undefined; type?: string | null | undefined; subject?: string | null | undefined; description?: string | null | undefined; status?: string | null | undefined; priority?: string | null | undefined; assignees?: Array | undefined; due_date?: string | null | undefined; tags?: Array | undefined; pass_through?: Array | undefined; }; /** @internal */ export const TicketInput$outboundSchema: z.ZodType< TicketInput$Outbound, z.ZodTypeDef, TicketInput > = z.object({ parentId: z.nullable(z.string()).optional(), type: z.nullable(z.string()).optional(), subject: z.nullable(z.string()).optional(), description: z.nullable(z.string()).optional(), status: z.nullable(z.string()).optional(), priority: z.nullable(Priority$outboundSchema).optional(), assignees: z.array(AssigneeInput$outboundSchema).optional(), dueDate: z.nullable(z.date().transform(v => v.toISOString())).optional(), tags: z.array(CollectionTagInput$outboundSchema).optional(), passThrough: z.array(PassThroughBody$outboundSchema).optional(), }).transform((v) => { return remap$(v, { parentId: "parent_id", dueDate: "due_date", passThrough: "pass_through", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace TicketInput$ { /** @deprecated use `TicketInput$inboundSchema` instead. */ export const inboundSchema = TicketInput$inboundSchema; /** @deprecated use `TicketInput$outboundSchema` instead. */ export const outboundSchema = TicketInput$outboundSchema; /** @deprecated use `TicketInput$Outbound` instead. */ export type Outbound = TicketInput$Outbound; } export function ticketInputToJSON(ticketInput: TicketInput): string { return JSON.stringify(TicketInput$outboundSchema.parse(ticketInput)); } export function ticketInputFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TicketInput$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TicketInput' from JSON`, ); }