/* * 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 PaymentsActionRequest = { /** * The ID of the payment to operate on */ id: string; /** * 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; paymentActionRequest: components.PaymentActionRequest; }; export type PaymentsActionResponse = { /** * 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 action was successfully applied to the pending payment */ paymentResponse?: components.PaymentResponse | undefined; }; /** @internal */ export const PaymentsActionRequest$inboundSchema: z.ZodType< PaymentsActionRequest, z.ZodTypeDef, unknown > = z.object({ id: z.string(), "X-Publishable-Key": z.string(), "X-Merchant-Client-Id": z.string().optional(), "payment-action-request": components.PaymentActionRequest$inboundSchema, }).transform((v) => { return remap$(v, { "X-Publishable-Key": "xPublishableKey", "X-Merchant-Client-Id": "xMerchantClientId", "payment-action-request": "paymentActionRequest", }); }); /** @internal */ export type PaymentsActionRequest$Outbound = { id: string; "X-Publishable-Key": string; "X-Merchant-Client-Id"?: string | undefined; "payment-action-request": components.PaymentActionRequest$Outbound; }; /** @internal */ export const PaymentsActionRequest$outboundSchema: z.ZodType< PaymentsActionRequest$Outbound, z.ZodTypeDef, PaymentsActionRequest > = z.object({ id: z.string(), xPublishableKey: z.string(), xMerchantClientId: z.string().optional(), paymentActionRequest: components.PaymentActionRequest$outboundSchema, }).transform((v) => { return remap$(v, { xPublishableKey: "X-Publishable-Key", xMerchantClientId: "X-Merchant-Client-Id", paymentActionRequest: "payment-action-request", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace PaymentsActionRequest$ { /** @deprecated use `PaymentsActionRequest$inboundSchema` instead. */ export const inboundSchema = PaymentsActionRequest$inboundSchema; /** @deprecated use `PaymentsActionRequest$outboundSchema` instead. */ export const outboundSchema = PaymentsActionRequest$outboundSchema; /** @deprecated use `PaymentsActionRequest$Outbound` instead. */ export type Outbound = PaymentsActionRequest$Outbound; } export function paymentsActionRequestToJSON( paymentsActionRequest: PaymentsActionRequest, ): string { return JSON.stringify( PaymentsActionRequest$outboundSchema.parse(paymentsActionRequest), ); } export function paymentsActionRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PaymentsActionRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PaymentsActionRequest' from JSON`, ); } /** @internal */ export const PaymentsActionResponse$inboundSchema: z.ZodType< PaymentsActionResponse, 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 PaymentsActionResponse$Outbound = { ContentType: string; StatusCode: number; RawResponse: never; "payment-response"?: components.PaymentResponse$Outbound | undefined; }; /** @internal */ export const PaymentsActionResponse$outboundSchema: z.ZodType< PaymentsActionResponse$Outbound, z.ZodTypeDef, PaymentsActionResponse > = 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 PaymentsActionResponse$ { /** @deprecated use `PaymentsActionResponse$inboundSchema` instead. */ export const inboundSchema = PaymentsActionResponse$inboundSchema; /** @deprecated use `PaymentsActionResponse$outboundSchema` instead. */ export const outboundSchema = PaymentsActionResponse$outboundSchema; /** @deprecated use `PaymentsActionResponse$Outbound` instead. */ export type Outbound = PaymentsActionResponse$Outbound; } export function paymentsActionResponseToJSON( paymentsActionResponse: PaymentsActionResponse, ): string { return JSON.stringify( PaymentsActionResponse$outboundSchema.parse(paymentsActionResponse), ); } export function paymentsActionResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PaymentsActionResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PaymentsActionResponse' from JSON`, ); }