/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { Mode, Mode$inboundSchema, Mode$outboundSchema } from "./mode.js"; import { OccurrenceStatus, OccurrenceStatus$inboundSchema, OccurrenceStatus$outboundSchema, } from "./occurrencestatus.js"; import { RunTransfer, RunTransfer$inboundSchema, RunTransfer$Outbound, RunTransfer$outboundSchema, } from "./runtransfer.js"; /** * Contains details on why the occurrence errored. */ export type ErrorT = { message?: string | undefined; }; export type OccurrencesResponse = { scheduleID?: string | undefined; occurrenceID?: string | undefined; /** * Sandbox or production account mode of this schedule. */ mode?: Mode | undefined; /** * True if this was generated by a RRule. */ generated?: boolean | undefined; /** * True if the RRule set runs indefinitely. */ indefinite?: boolean | undefined; canceledOn?: Date | undefined; runOn: Date; runTransfer: RunTransfer; ranOn?: Date | undefined; ranTransferID?: string | undefined; /** * Status of the completed occurrence. */ status?: OccurrenceStatus | undefined; /** * Contains details on why the occurrence errored. */ error?: ErrorT | undefined; }; /** @internal */ export const ErrorT$inboundSchema: z.ZodType = z .object({ message: z.string().optional(), }); /** @internal */ export type ErrorT$Outbound = { message?: string | undefined; }; /** @internal */ export const ErrorT$outboundSchema: z.ZodType< ErrorT$Outbound, z.ZodTypeDef, ErrorT > = z.object({ message: z.string().optional(), }); export function errorToJSON(errorT: ErrorT): string { return JSON.stringify(ErrorT$outboundSchema.parse(errorT)); } export function errorFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ErrorT$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ErrorT' from JSON`, ); } /** @internal */ export const OccurrencesResponse$inboundSchema: z.ZodType< OccurrencesResponse, z.ZodTypeDef, unknown > = z.object({ scheduleID: z.string().optional(), occurrenceID: z.string().optional(), mode: Mode$inboundSchema.optional(), generated: z.boolean().optional(), indefinite: z.boolean().optional(), canceledOn: z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), runOn: z.string().datetime({ offset: true }).transform(v => new Date(v)), runTransfer: RunTransfer$inboundSchema, ranOn: z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), ranTransferID: z.string().optional(), status: OccurrenceStatus$inboundSchema.optional(), error: z.lazy(() => ErrorT$inboundSchema).optional(), }); /** @internal */ export type OccurrencesResponse$Outbound = { scheduleID?: string | undefined; occurrenceID?: string | undefined; mode?: string | undefined; generated?: boolean | undefined; indefinite?: boolean | undefined; canceledOn?: string | undefined; runOn: string; runTransfer: RunTransfer$Outbound; ranOn?: string | undefined; ranTransferID?: string | undefined; status?: string | undefined; error?: ErrorT$Outbound | undefined; }; /** @internal */ export const OccurrencesResponse$outboundSchema: z.ZodType< OccurrencesResponse$Outbound, z.ZodTypeDef, OccurrencesResponse > = z.object({ scheduleID: z.string().optional(), occurrenceID: z.string().optional(), mode: Mode$outboundSchema.optional(), generated: z.boolean().optional(), indefinite: z.boolean().optional(), canceledOn: z.date().transform(v => v.toISOString()).optional(), runOn: z.date().transform(v => v.toISOString()), runTransfer: RunTransfer$outboundSchema, ranOn: z.date().transform(v => v.toISOString()).optional(), ranTransferID: z.string().optional(), status: OccurrenceStatus$outboundSchema.optional(), error: z.lazy(() => ErrorT$outboundSchema).optional(), }); export function occurrencesResponseToJSON( occurrencesResponse: OccurrencesResponse, ): string { return JSON.stringify( OccurrencesResponse$outboundSchema.parse(occurrencesResponse), ); } export function occurrencesResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => OccurrencesResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'OccurrencesResponse' from JSON`, ); }