/* * 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 { NetworkTokenStatus, NetworkTokenStatus$inboundSchema, } from "./networktokenstatus.js"; export type NetworkToken = { /** * Always `network-token`. */ type: "network-token"; /** * The ID for the network token. */ id: string; /** * The expiration date for the network token. */ expirationDate: string; /** * The ID of the payment method used to generate this token */ paymentMethodId: string; status: NetworkTokenStatus; /** * The token value. Will be present if succeeded. */ token: string; /** * The date and time when this network token was first created in our system. */ createdAt: Date; /** * The date and time when this network token was last updated in our system. */ updatedAt: Date; }; /** @internal */ export const NetworkToken$inboundSchema: z.ZodType< NetworkToken, z.ZodTypeDef, unknown > = z.object({ type: z.literal("network-token").default("network-token"), id: z.string(), expiration_date: z.string(), payment_method_id: z.string(), status: NetworkTokenStatus$inboundSchema, token: z.string(), 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, { "expiration_date": "expirationDate", "payment_method_id": "paymentMethodId", "created_at": "createdAt", "updated_at": "updatedAt", }); }); export function networkTokenFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => NetworkToken$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'NetworkToken' from JSON`, ); }