/* * 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 { PaymentMethodStatus, PaymentMethodStatus$inboundSchema, } from "./paymentmethodstatus.js"; export type PaymentServiceToken = { /** * Always `payment-service-token`. */ type: "payment-service-token"; /** * The ID for the payment service token. */ id: string; /** * The optional URL that the buyer needs to be redirected to to further authorize the token creation. */ approvalUrl?: string | null | undefined; /** * The ID of the payment method used to generate this token */ paymentMethodId: string; /** * The ID of the payment method used to generate this token. */ paymentServiceId: string; status: PaymentMethodStatus; /** * The token value. Will be present if succeeded. */ token?: string | null | undefined; /** * The date and time when this payment service token was first created in our system. */ createdAt: Date; /** * The date and time when this payment service token was last updated in our system. */ updatedAt: Date; }; /** @internal */ export const PaymentServiceToken$inboundSchema: z.ZodType< PaymentServiceToken, z.ZodTypeDef, unknown > = z.object({ type: z.literal("payment-service-token").default("payment-service-token"), id: z.string(), approval_url: z.nullable(z.string()).optional(), payment_method_id: z.string(), payment_service_id: z.string(), status: PaymentMethodStatus$inboundSchema, token: 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, { "approval_url": "approvalUrl", "payment_method_id": "paymentMethodId", "payment_service_id": "paymentServiceId", "created_at": "createdAt", "updated_at": "updatedAt", }); }); export function paymentServiceTokenFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PaymentServiceToken$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PaymentServiceToken' from JSON`, ); }