/* * 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 { ReceiptKind, ReceiptKind$inboundSchema, ReceiptKind$outboundSchema, } from "./receiptkind.js"; import { SentReceipt, SentReceipt$inboundSchema, SentReceipt$Outbound, SentReceipt$outboundSchema, } from "./sentreceipt.js"; export type ReceiptResponse = { /** * Unique identifier for the receipt request. */ receiptID: string; /** * AccountID for which the receipt request was created. */ createdBy: string; /** * The date and time the receipt was disabled. */ disabledOn?: Date | undefined; /** * The type of receipt. */ kind: ReceiptKind; /** * The email address the receipt is sent to. * * @remarks * Either email or emailAccountID will be in the response, but not both. */ email?: string | undefined; /** * The accountID the receipt is sent to. * * @remarks * Either email or emailAccountID will be in the response, but not both. */ emailAccountID?: string | undefined; /** * The ID of the transfer associated with this receipt. * * @remarks * Exactly one of forTransferID, forScheduleID, or forOccurrenceID must be provided. */ forTransferID?: string | undefined; /** * The ID of the schedule associated with this receipt. * * @remarks * Exactly one of forTransferID, forScheduleID, or forOccurrenceID must be provided. */ forScheduleID?: string | undefined; /** * The ID of the schedule occurrence associated with this receipt. * * @remarks * Exactly one of forTransferID, forScheduleID, or forOccurrenceID must be provided. */ forOccurrenceID?: string | undefined; /** * The list of receipts that have been sent. */ sentFor?: Array | undefined; }; /** @internal */ export const ReceiptResponse$inboundSchema: z.ZodType< ReceiptResponse, z.ZodTypeDef, unknown > = z.object({ receiptID: z.string(), createdBy: z.string(), disabledOn: z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), kind: ReceiptKind$inboundSchema, email: z.string().optional(), emailAccountID: z.string().optional(), forTransferID: z.string().optional(), forScheduleID: z.string().optional(), forOccurrenceID: z.string().optional(), sentFor: z.array(SentReceipt$inboundSchema).optional(), }); /** @internal */ export type ReceiptResponse$Outbound = { receiptID: string; createdBy: string; disabledOn?: string | undefined; kind: string; email?: string | undefined; emailAccountID?: string | undefined; forTransferID?: string | undefined; forScheduleID?: string | undefined; forOccurrenceID?: string | undefined; sentFor?: Array | undefined; }; /** @internal */ export const ReceiptResponse$outboundSchema: z.ZodType< ReceiptResponse$Outbound, z.ZodTypeDef, ReceiptResponse > = z.object({ receiptID: z.string(), createdBy: z.string(), disabledOn: z.date().transform(v => v.toISOString()).optional(), kind: ReceiptKind$outboundSchema, email: z.string().optional(), emailAccountID: z.string().optional(), forTransferID: z.string().optional(), forScheduleID: z.string().optional(), forOccurrenceID: z.string().optional(), sentFor: z.array(SentReceipt$outboundSchema).optional(), }); export function receiptResponseToJSON( receiptResponse: ReceiptResponse, ): string { return JSON.stringify(ReceiptResponse$outboundSchema.parse(receiptResponse)); } export function receiptResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ReceiptResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ReceiptResponse' from JSON`, ); }