/* * 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 { GiftCardErrorCode, GiftCardErrorCode$inboundSchema, } from "./giftcarderrorcode.js"; import { GiftCardRedemptionStatus, GiftCardRedemptionStatus$inboundSchema, } from "./giftcardredemptionstatus.js"; import { TransactionGiftCard, TransactionGiftCard$inboundSchema, } from "./transactiongiftcard.js"; export type GiftCardRedemption = { /** * Always `gift-card-redemption`. */ type: "gift-card-redemption"; /** * The ID for the gift card redemption. */ id: string; status: GiftCardRedemptionStatus; /** * The amount redeemed for this gift card. */ amount: number; /** * The amount refunded for this gift card. This can not be larger than `amount`. */ refundedAmount: number; /** * The gift card service's unique ID for the redemption. */ giftCardServiceRedemptionId?: string | null | undefined; /** * If this gift card redemption resulted in an error, this will contain the internal code for the error. */ errorCode?: GiftCardErrorCode | null | undefined; /** * If this gift card redemption resulted in an error, this will contain the raw error code received from the gift card provider. */ rawErrorCode?: string | null | undefined; /** * If this gift card redemption resulted in an error, this will contain the raw error message received from the gift card provider. */ rawErrorMessage?: string | null | undefined; giftCard: TransactionGiftCard; }; /** @internal */ export const GiftCardRedemption$inboundSchema: z.ZodType< GiftCardRedemption, z.ZodTypeDef, unknown > = z.object({ type: z.literal("gift-card-redemption").default("gift-card-redemption"), id: z.string(), status: GiftCardRedemptionStatus$inboundSchema, amount: z.number().int(), refunded_amount: z.number().int(), gift_card_service_redemption_id: z.nullable(z.string()).optional(), error_code: z.nullable(GiftCardErrorCode$inboundSchema).optional(), raw_error_code: z.nullable(z.string()).optional(), raw_error_message: z.nullable(z.string()).optional(), gift_card: TransactionGiftCard$inboundSchema, }).transform((v) => { return remap$(v, { "refunded_amount": "refundedAmount", "gift_card_service_redemption_id": "giftCardServiceRedemptionId", "error_code": "errorCode", "raw_error_code": "rawErrorCode", "raw_error_message": "rawErrorMessage", "gift_card": "giftCard", }); }); export function giftCardRedemptionFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GiftCardRedemption$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GiftCardRedemption' from JSON`, ); }