/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 * @generated-id: 873ca51c5774
 */

import * as z from "zod/v4";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

export type OAuth2TokenAuth = {
  type: "oauth2-token";
  value: string;
};

/** @internal */
export const OAuth2TokenAuth$inboundSchema: z.ZodType<
  OAuth2TokenAuth,
  unknown
> = z.object({
  type: z.literal("oauth2-token"),
  value: z.string(),
});
/** @internal */
export type OAuth2TokenAuth$Outbound = {
  type: "oauth2-token";
  value: string;
};

/** @internal */
export const OAuth2TokenAuth$outboundSchema: z.ZodType<
  OAuth2TokenAuth$Outbound,
  OAuth2TokenAuth
> = z.object({
  type: z.literal("oauth2-token"),
  value: z.string(),
});

export function oAuth2TokenAuthToJSON(
  oAuth2TokenAuth: OAuth2TokenAuth,
): string {
  return JSON.stringify(OAuth2TokenAuth$outboundSchema.parse(oAuth2TokenAuth));
}
export function oAuth2TokenAuthFromJSON(
  jsonString: string,
): SafeParseResult<OAuth2TokenAuth, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => OAuth2TokenAuth$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'OAuth2TokenAuth' from JSON`,
  );
}
