/*
 * 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 {
  ConnectorAuthenticationHeader,
  ConnectorAuthenticationHeader$inboundSchema,
} from "./connectorauthenticationheader.js";
import {
  OutboundAuthenticationType,
  OutboundAuthenticationType$inboundSchema,
} from "./outboundauthenticationtype.js";

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

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

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