/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import * as components from "../components/index.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type GuestPaymentsInitializeSecurity = { apiKey: string; }; export type GuestPaymentsInitializeRequest = { /** * The publicly shareable identifier used to identify your Bolt merchant division. */ xPublishableKey: string; /** * A unique identifier for a shopper's device, generated by Bolt. The value is retrieved with `Bolt.state.merchantClientId` in your frontend context, per-shopper. This header is required for proper attribution of this operation to your analytics reports. Omitting this header may result in incorrect statistics. */ xMerchantClientId?: string | undefined; guestPaymentInitializeRequest: components.GuestPaymentInitializeRequest; }; export type GuestPaymentsInitializeResponse = { /** * HTTP response content type for this operation */ contentType: string; /** * HTTP response status code for this operation */ statusCode: number; /** * Raw HTTP response; suitable for custom response parsing */ rawResponse: Response; /** * The payment was successfully initialized, and was either immediately finalized or is pending */ paymentResponse?: components.PaymentResponse | undefined; }; /** @internal */ export const GuestPaymentsInitializeSecurity$inboundSchema: z.ZodType< GuestPaymentsInitializeSecurity, z.ZodTypeDef, unknown > = z.object({ "api-key": z.string(), }).transform((v) => { return remap$(v, { "api-key": "apiKey", }); }); /** @internal */ export type GuestPaymentsInitializeSecurity$Outbound = { "api-key": string; }; /** @internal */ export const GuestPaymentsInitializeSecurity$outboundSchema: z.ZodType< GuestPaymentsInitializeSecurity$Outbound, z.ZodTypeDef, GuestPaymentsInitializeSecurity > = z.object({ apiKey: z.string(), }).transform((v) => { return remap$(v, { apiKey: "api-key", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace GuestPaymentsInitializeSecurity$ { /** @deprecated use `GuestPaymentsInitializeSecurity$inboundSchema` instead. */ export const inboundSchema = GuestPaymentsInitializeSecurity$inboundSchema; /** @deprecated use `GuestPaymentsInitializeSecurity$outboundSchema` instead. */ export const outboundSchema = GuestPaymentsInitializeSecurity$outboundSchema; /** @deprecated use `GuestPaymentsInitializeSecurity$Outbound` instead. */ export type Outbound = GuestPaymentsInitializeSecurity$Outbound; } export function guestPaymentsInitializeSecurityToJSON( guestPaymentsInitializeSecurity: GuestPaymentsInitializeSecurity, ): string { return JSON.stringify( GuestPaymentsInitializeSecurity$outboundSchema.parse( guestPaymentsInitializeSecurity, ), ); } export function guestPaymentsInitializeSecurityFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GuestPaymentsInitializeSecurity$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GuestPaymentsInitializeSecurity' from JSON`, ); } /** @internal */ export const GuestPaymentsInitializeRequest$inboundSchema: z.ZodType< GuestPaymentsInitializeRequest, z.ZodTypeDef, unknown > = z.object({ "X-Publishable-Key": z.string(), "X-Merchant-Client-Id": z.string().optional(), "guest-payment-initialize-request": components.GuestPaymentInitializeRequest$inboundSchema, }).transform((v) => { return remap$(v, { "X-Publishable-Key": "xPublishableKey", "X-Merchant-Client-Id": "xMerchantClientId", "guest-payment-initialize-request": "guestPaymentInitializeRequest", }); }); /** @internal */ export type GuestPaymentsInitializeRequest$Outbound = { "X-Publishable-Key": string; "X-Merchant-Client-Id"?: string | undefined; "guest-payment-initialize-request": components.GuestPaymentInitializeRequest$Outbound; }; /** @internal */ export const GuestPaymentsInitializeRequest$outboundSchema: z.ZodType< GuestPaymentsInitializeRequest$Outbound, z.ZodTypeDef, GuestPaymentsInitializeRequest > = z.object({ xPublishableKey: z.string(), xMerchantClientId: z.string().optional(), guestPaymentInitializeRequest: components.GuestPaymentInitializeRequest$outboundSchema, }).transform((v) => { return remap$(v, { xPublishableKey: "X-Publishable-Key", xMerchantClientId: "X-Merchant-Client-Id", guestPaymentInitializeRequest: "guest-payment-initialize-request", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace GuestPaymentsInitializeRequest$ { /** @deprecated use `GuestPaymentsInitializeRequest$inboundSchema` instead. */ export const inboundSchema = GuestPaymentsInitializeRequest$inboundSchema; /** @deprecated use `GuestPaymentsInitializeRequest$outboundSchema` instead. */ export const outboundSchema = GuestPaymentsInitializeRequest$outboundSchema; /** @deprecated use `GuestPaymentsInitializeRequest$Outbound` instead. */ export type Outbound = GuestPaymentsInitializeRequest$Outbound; } export function guestPaymentsInitializeRequestToJSON( guestPaymentsInitializeRequest: GuestPaymentsInitializeRequest, ): string { return JSON.stringify( GuestPaymentsInitializeRequest$outboundSchema.parse( guestPaymentsInitializeRequest, ), ); } export function guestPaymentsInitializeRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GuestPaymentsInitializeRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GuestPaymentsInitializeRequest' from JSON`, ); } /** @internal */ export const GuestPaymentsInitializeResponse$inboundSchema: z.ZodType< GuestPaymentsInitializeResponse, z.ZodTypeDef, unknown > = z.object({ ContentType: z.string(), StatusCode: z.number().int(), RawResponse: z.instanceof(Response), "payment-response": components.PaymentResponse$inboundSchema.optional(), }).transform((v) => { return remap$(v, { "ContentType": "contentType", "StatusCode": "statusCode", "RawResponse": "rawResponse", "payment-response": "paymentResponse", }); }); /** @internal */ export type GuestPaymentsInitializeResponse$Outbound = { ContentType: string; StatusCode: number; RawResponse: never; "payment-response"?: components.PaymentResponse$Outbound | undefined; }; /** @internal */ export const GuestPaymentsInitializeResponse$outboundSchema: z.ZodType< GuestPaymentsInitializeResponse$Outbound, z.ZodTypeDef, GuestPaymentsInitializeResponse > = z.object({ contentType: z.string(), statusCode: z.number().int(), rawResponse: z.instanceof(Response).transform(() => { throw new Error("Response cannot be serialized"); }), paymentResponse: components.PaymentResponse$outboundSchema.optional(), }).transform((v) => { return remap$(v, { contentType: "ContentType", statusCode: "StatusCode", rawResponse: "RawResponse", paymentResponse: "payment-response", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace GuestPaymentsInitializeResponse$ { /** @deprecated use `GuestPaymentsInitializeResponse$inboundSchema` instead. */ export const inboundSchema = GuestPaymentsInitializeResponse$inboundSchema; /** @deprecated use `GuestPaymentsInitializeResponse$outboundSchema` instead. */ export const outboundSchema = GuestPaymentsInitializeResponse$outboundSchema; /** @deprecated use `GuestPaymentsInitializeResponse$Outbound` instead. */ export type Outbound = GuestPaymentsInitializeResponse$Outbound; } export function guestPaymentsInitializeResponseToJSON( guestPaymentsInitializeResponse: GuestPaymentsInitializeResponse, ): string { return JSON.stringify( GuestPaymentsInitializeResponse$outboundSchema.parse( guestPaymentsInitializeResponse, ), ); } export function guestPaymentsInitializeResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GuestPaymentsInitializeResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GuestPaymentsInitializeResponse' from JSON`, ); }