/* * 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 OauthGetTokenRequest = { /** * 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; tokenRequest: components.TokenRequest; }; export type OauthGetTokenResponse = { /** * 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; /** * Access token is successfully fetched */ getAccessTokenResponse?: components.GetAccessTokenResponse | undefined; }; /** @internal */ export const OauthGetTokenRequest$inboundSchema: z.ZodType< OauthGetTokenRequest, z.ZodTypeDef, unknown > = z.object({ "X-Merchant-Client-Id": z.string().optional(), "token-request": components.TokenRequest$inboundSchema, }).transform((v) => { return remap$(v, { "X-Merchant-Client-Id": "xMerchantClientId", "token-request": "tokenRequest", }); }); /** @internal */ export type OauthGetTokenRequest$Outbound = { "X-Merchant-Client-Id"?: string | undefined; "token-request": components.TokenRequest$Outbound; }; /** @internal */ export const OauthGetTokenRequest$outboundSchema: z.ZodType< OauthGetTokenRequest$Outbound, z.ZodTypeDef, OauthGetTokenRequest > = z.object({ xMerchantClientId: z.string().optional(), tokenRequest: components.TokenRequest$outboundSchema, }).transform((v) => { return remap$(v, { xMerchantClientId: "X-Merchant-Client-Id", tokenRequest: "token-request", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace OauthGetTokenRequest$ { /** @deprecated use `OauthGetTokenRequest$inboundSchema` instead. */ export const inboundSchema = OauthGetTokenRequest$inboundSchema; /** @deprecated use `OauthGetTokenRequest$outboundSchema` instead. */ export const outboundSchema = OauthGetTokenRequest$outboundSchema; /** @deprecated use `OauthGetTokenRequest$Outbound` instead. */ export type Outbound = OauthGetTokenRequest$Outbound; } export function oauthGetTokenRequestToJSON( oauthGetTokenRequest: OauthGetTokenRequest, ): string { return JSON.stringify( OauthGetTokenRequest$outboundSchema.parse(oauthGetTokenRequest), ); } export function oauthGetTokenRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => OauthGetTokenRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'OauthGetTokenRequest' from JSON`, ); } /** @internal */ export const OauthGetTokenResponse$inboundSchema: z.ZodType< OauthGetTokenResponse, z.ZodTypeDef, unknown > = z.object({ ContentType: z.string(), StatusCode: z.number().int(), RawResponse: z.instanceof(Response), "get-access-token-response": components.GetAccessTokenResponse$inboundSchema .optional(), }).transform((v) => { return remap$(v, { "ContentType": "contentType", "StatusCode": "statusCode", "RawResponse": "rawResponse", "get-access-token-response": "getAccessTokenResponse", }); }); /** @internal */ export type OauthGetTokenResponse$Outbound = { ContentType: string; StatusCode: number; RawResponse: never; "get-access-token-response"?: | components.GetAccessTokenResponse$Outbound | undefined; }; /** @internal */ export const OauthGetTokenResponse$outboundSchema: z.ZodType< OauthGetTokenResponse$Outbound, z.ZodTypeDef, OauthGetTokenResponse > = z.object({ contentType: z.string(), statusCode: z.number().int(), rawResponse: z.instanceof(Response).transform(() => { throw new Error("Response cannot be serialized"); }), getAccessTokenResponse: components.GetAccessTokenResponse$outboundSchema .optional(), }).transform((v) => { return remap$(v, { contentType: "ContentType", statusCode: "StatusCode", rawResponse: "RawResponse", getAccessTokenResponse: "get-access-token-response", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace OauthGetTokenResponse$ { /** @deprecated use `OauthGetTokenResponse$inboundSchema` instead. */ export const inboundSchema = OauthGetTokenResponse$inboundSchema; /** @deprecated use `OauthGetTokenResponse$outboundSchema` instead. */ export const outboundSchema = OauthGetTokenResponse$outboundSchema; /** @deprecated use `OauthGetTokenResponse$Outbound` instead. */ export type Outbound = OauthGetTokenResponse$Outbound; } export function oauthGetTokenResponseToJSON( oauthGetTokenResponse: OauthGetTokenResponse, ): string { return JSON.stringify( OauthGetTokenResponse$outboundSchema.parse(oauthGetTokenResponse), ); } export function oauthGetTokenResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => OauthGetTokenResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'OauthGetTokenResponse' from JSON`, ); }