/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */

import * as z from "zod/v3";
import { safeParse } from "../lib/schemas.js";
import { Result as SafeParseResult } from "../types/fp.js";
import { AuthToken, AuthToken$inboundSchema } from "./authtoken.js";
import { SDKValidationError } from "./sdkvalidationerror.js";

export type GetAuthTokenRequest = {
  /**
   * The identifier of the token to retrieve. The special value "current" may be supplied, which returns the metadata for the token that the current HTTP request is authenticated with.
   */
  tokenId: string;
};

/**
 * Successful response.
 */
export type GetAuthTokenResponseBody = {
  /**
   * Authentication token metadata.
   */
  token: AuthToken;
};

/** @internal */
export type GetAuthTokenRequest$Outbound = {
  tokenId: string;
};

/** @internal */
export const GetAuthTokenRequest$outboundSchema: z.ZodType<
  GetAuthTokenRequest$Outbound,
  z.ZodTypeDef,
  GetAuthTokenRequest
> = z.object({
  tokenId: z.string(),
});

export function getAuthTokenRequestToJSON(
  getAuthTokenRequest: GetAuthTokenRequest,
): string {
  return JSON.stringify(
    GetAuthTokenRequest$outboundSchema.parse(getAuthTokenRequest),
  );
}

/** @internal */
export const GetAuthTokenResponseBody$inboundSchema: z.ZodType<
  GetAuthTokenResponseBody,
  z.ZodTypeDef,
  unknown
> = z.object({
  token: AuthToken$inboundSchema,
});

export function getAuthTokenResponseBodyFromJSON(
  jsonString: string,
): SafeParseResult<GetAuthTokenResponseBody, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => GetAuthTokenResponseBody$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'GetAuthTokenResponseBody' from JSON`,
  );
}
