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

import * as z from "zod/v4";
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 {
  AuthenticationType,
  AuthenticationType$inboundSchema,
} from "./authenticationtype.js";
import {
  ConnectorAuthenticationHeader,
  ConnectorAuthenticationHeader$inboundSchema,
} from "./connectorauthenticationheader.js";

/**
 * Public view of an authentication method, without secrets.
 */
export type PublicAuthenticationMethod = {
  methodType: AuthenticationType;
  headers?: Array<ConnectorAuthenticationHeader> | null | undefined;
};

/** @internal */
export const PublicAuthenticationMethod$inboundSchema: z.ZodType<
  PublicAuthenticationMethod,
  unknown
> = z.object({
  method_type: AuthenticationType$inboundSchema,
  headers: z.nullable(z.array(ConnectorAuthenticationHeader$inboundSchema))
    .optional(),
}).transform((v) => {
  return remap$(v, {
    "method_type": "methodType",
  });
});

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