/* * 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 { GrantType, GrantType$inboundSchema, GrantType$outboundSchema, } from "./granttype.js"; export type AuthTokenRequest = { /** * The type of grant being requested. * * @remarks * * - `client_credentials`: A grant type used by clients to obtain an access token * - `refresh_token`: A grant type used by clients to obtain a new access token using a refresh token */ grantType: GrantType; /** * Client ID can be provided here in the body, or as the Username in HTTP Basic Auth. */ clientId?: string | undefined; /** * Client secret can be provided here in the body, or as the Password in HTTP Basic Auth. */ clientSecret?: string | undefined; /** * A space delimited list of scopes. Required when `grant_type` is `client_credentials`. */ scope?: string | undefined; /** * The refresh_token returned alongside the access token being refreshed. Required when `grant_type` is `refresh_token`. */ refreshToken?: string | undefined; }; /** @internal */ export const AuthTokenRequest$inboundSchema: z.ZodType< AuthTokenRequest, z.ZodTypeDef, unknown > = z.object({ grant_type: GrantType$inboundSchema, client_id: z.string().optional(), client_secret: z.string().optional(), scope: z.string().optional(), refresh_token: z.string().optional(), }).transform((v) => { return remap$(v, { "grant_type": "grantType", "client_id": "clientId", "client_secret": "clientSecret", "refresh_token": "refreshToken", }); }); /** @internal */ export type AuthTokenRequest$Outbound = { grant_type: string; client_id?: string | undefined; client_secret?: string | undefined; scope?: string | undefined; refresh_token?: string | undefined; }; /** @internal */ export const AuthTokenRequest$outboundSchema: z.ZodType< AuthTokenRequest$Outbound, z.ZodTypeDef, AuthTokenRequest > = z.object({ grantType: GrantType$outboundSchema, clientId: z.string().optional(), clientSecret: z.string().optional(), scope: z.string().optional(), refreshToken: z.string().optional(), }).transform((v) => { return remap$(v, { grantType: "grant_type", clientId: "client_id", clientSecret: "client_secret", refreshToken: "refresh_token", }); }); export function authTokenRequestToJSON( authTokenRequest: AuthTokenRequest, ): string { return JSON.stringify( AuthTokenRequest$outboundSchema.parse(authTokenRequest), ); } export function authTokenRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => AuthTokenRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AuthTokenRequest' from JSON`, ); }