/* * 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 { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The type of OAuth 2.0 grant being utilized. */ export enum RefreshTokenRequestGrantType { RefreshToken = "refresh_token", } export enum RefreshTokenRequestScope { BoltAccountManage = "bolt.account.manage", BoltAccountView = "bolt.account.view", Openid = "openid", } export type RefreshTokenRequest = { /** * The type of OAuth 2.0 grant being utilized. */ grantType: RefreshTokenRequestGrantType; /** * The value of the refresh token issued to you in the originating OAuth token request. */ refreshToken: string; /** * The OAuth client ID, which corresponds to the merchant publishable key, which can be retrieved in your Merchant Dashboard. */ clientId: string; /** * The OAuth client secret, which corresponds the merchant API key, which can be retrieved in your Merchant Dashboard. */ clientSecret: string; /** * The requested scopes. If the request is successful, the OAuth client will be able to perform operations requiring these scopes. */ scope: Array; /** * A randomly generated string sent along with an authorization code. This must be included if provided. It is used to prevent cross-site request forgery (CSRF) attacks. */ state?: string | undefined; }; /** @internal */ export const RefreshTokenRequestGrantType$inboundSchema: z.ZodNativeEnum< typeof RefreshTokenRequestGrantType > = z.nativeEnum(RefreshTokenRequestGrantType); /** @internal */ export const RefreshTokenRequestGrantType$outboundSchema: z.ZodNativeEnum< typeof RefreshTokenRequestGrantType > = RefreshTokenRequestGrantType$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace RefreshTokenRequestGrantType$ { /** @deprecated use `RefreshTokenRequestGrantType$inboundSchema` instead. */ export const inboundSchema = RefreshTokenRequestGrantType$inboundSchema; /** @deprecated use `RefreshTokenRequestGrantType$outboundSchema` instead. */ export const outboundSchema = RefreshTokenRequestGrantType$outboundSchema; } /** @internal */ export const RefreshTokenRequestScope$inboundSchema: z.ZodNativeEnum< typeof RefreshTokenRequestScope > = z.nativeEnum(RefreshTokenRequestScope); /** @internal */ export const RefreshTokenRequestScope$outboundSchema: z.ZodNativeEnum< typeof RefreshTokenRequestScope > = RefreshTokenRequestScope$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace RefreshTokenRequestScope$ { /** @deprecated use `RefreshTokenRequestScope$inboundSchema` instead. */ export const inboundSchema = RefreshTokenRequestScope$inboundSchema; /** @deprecated use `RefreshTokenRequestScope$outboundSchema` instead. */ export const outboundSchema = RefreshTokenRequestScope$outboundSchema; } /** @internal */ export const RefreshTokenRequest$inboundSchema: z.ZodType< RefreshTokenRequest, z.ZodTypeDef, unknown > = z.object({ grant_type: RefreshTokenRequestGrantType$inboundSchema, refresh_token: z.string(), client_id: z.string(), client_secret: z.string(), scope: z.array(RefreshTokenRequestScope$inboundSchema), state: z.string().optional(), }).transform((v) => { return remap$(v, { "grant_type": "grantType", "refresh_token": "refreshToken", "client_id": "clientId", "client_secret": "clientSecret", }); }); /** @internal */ export type RefreshTokenRequest$Outbound = { grant_type: string; refresh_token: string; client_id: string; client_secret: string; scope: Array; state?: string | undefined; }; /** @internal */ export const RefreshTokenRequest$outboundSchema: z.ZodType< RefreshTokenRequest$Outbound, z.ZodTypeDef, RefreshTokenRequest > = z.object({ grantType: RefreshTokenRequestGrantType$outboundSchema, refreshToken: z.string(), clientId: z.string(), clientSecret: z.string(), scope: z.array(RefreshTokenRequestScope$outboundSchema), state: z.string().optional(), }).transform((v) => { return remap$(v, { grantType: "grant_type", refreshToken: "refresh_token", clientId: "client_id", clientSecret: "client_secret", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace RefreshTokenRequest$ { /** @deprecated use `RefreshTokenRequest$inboundSchema` instead. */ export const inboundSchema = RefreshTokenRequest$inboundSchema; /** @deprecated use `RefreshTokenRequest$outboundSchema` instead. */ export const outboundSchema = RefreshTokenRequest$outboundSchema; /** @deprecated use `RefreshTokenRequest$Outbound` instead. */ export type Outbound = RefreshTokenRequest$Outbound; } export function refreshTokenRequestToJSON( refreshTokenRequest: RefreshTokenRequest, ): string { return JSON.stringify( RefreshTokenRequest$outboundSchema.parse(refreshTokenRequest), ); } export function refreshTokenRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => RefreshTokenRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'RefreshTokenRequest' from JSON`, ); }