/* * 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 { IssuedCardAuthorizationEventResult, IssuedCardAuthorizationEventResult$inboundSchema, IssuedCardAuthorizationEventResult$outboundSchema, } from "./issuedcardauthorizationeventresult.js"; import { IssuedCardEventType, IssuedCardEventType$inboundSchema, IssuedCardEventType$outboundSchema, } from "./issuedcardeventtype.js"; export type IssuedCardAuthorizationEvent = { /** * The identifier for this event. Use the `eventType` field to determine what resource is identified by this ID (`authorization`, `reversal`, etc.). */ eventID: string; /** * The type of event that occurred on the card. */ eventType: IssuedCardEventType; /** * A decimal-formatted numerical string that represents up to 2 decimal place precision. In USD for example, 12.34 is $12.34 and 0.99 is $0.99. */ amount: string; /** * The result of an event. */ result: IssuedCardAuthorizationEventResult; createdOn: Date; }; /** @internal */ export const IssuedCardAuthorizationEvent$inboundSchema: z.ZodType< IssuedCardAuthorizationEvent, z.ZodTypeDef, unknown > = z.object({ eventID: z.string(), eventType: IssuedCardEventType$inboundSchema, amount: z.string(), result: IssuedCardAuthorizationEventResult$inboundSchema, createdOn: z.string().datetime({ offset: true }).transform(v => new Date(v)), }); /** @internal */ export type IssuedCardAuthorizationEvent$Outbound = { eventID: string; eventType: string; amount: string; result: string; createdOn: string; }; /** @internal */ export const IssuedCardAuthorizationEvent$outboundSchema: z.ZodType< IssuedCardAuthorizationEvent$Outbound, z.ZodTypeDef, IssuedCardAuthorizationEvent > = z.object({ eventID: z.string(), eventType: IssuedCardEventType$outboundSchema, amount: z.string(), result: IssuedCardAuthorizationEventResult$outboundSchema, createdOn: z.date().transform(v => v.toISOString()), }); export function issuedCardAuthorizationEventToJSON( issuedCardAuthorizationEvent: IssuedCardAuthorizationEvent, ): string { return JSON.stringify( IssuedCardAuthorizationEvent$outboundSchema.parse( issuedCardAuthorizationEvent, ), ); } export function issuedCardAuthorizationEventFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => IssuedCardAuthorizationEvent$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'IssuedCardAuthorizationEvent' from JSON`, ); }