/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { GiftCardService, GiftCardService$inboundSchema, } from "./giftcardservice.js"; export type GiftCardIssuance = { /** * Always `gift-card-issuance`. */ type: "gift-card-issuance"; /** * The ID for the gift card issuance. */ id: string; /** * The ID of the merchant account this gift card issuance belongs to. */ merchantAccountId: string; giftCardService: GiftCardService; /** * The identifier for this issuance as provided by the gift card service. */ giftCardServicePaymentIssuanceId: string; /** * The URL for the issued gift card. */ url: string; /** * The amount loaded onto the gift card, in the smallest denomination for the currency. */ amount: number; /** * The ISO-4217 currency code for the `amount`. */ currency: string; /** * The external identifier provided when issuing the gift card. */ externalIdentifier?: string | null | undefined; /** * The date and time when this gift card was issued. */ createdAt: Date; /** * The date and time when this gift card issuance was last updated. */ updatedAt: Date; }; /** @internal */ export const GiftCardIssuance$inboundSchema: z.ZodType< GiftCardIssuance, z.ZodTypeDef, unknown > = z.object({ type: z.literal("gift-card-issuance").default("gift-card-issuance"), id: z.string(), merchant_account_id: z.string(), gift_card_service: GiftCardService$inboundSchema, gift_card_service_payment_issuance_id: z.string(), url: z.string(), amount: z.number().int(), currency: z.string(), external_identifier: z.nullable(z.string()).optional(), created_at: z.string().datetime({ offset: true }).transform(v => new Date(v)), updated_at: z.string().datetime({ offset: true }).transform(v => new Date(v)), }).transform((v) => { return remap$(v, { "merchant_account_id": "merchantAccountId", "gift_card_service": "giftCardService", "gift_card_service_payment_issuance_id": "giftCardServicePaymentIssuanceId", "external_identifier": "externalIdentifier", "created_at": "createdAt", "updated_at": "updatedAt", }); }); export function giftCardIssuanceFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GiftCardIssuance$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GiftCardIssuance' from JSON`, ); }