/*
 * 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 * as types from "../types/primitives.js";
import { SDKValidationError } from "./sdkvalidationerror.js";

export type GetCertByIdRequest = {
  /**
   * The cert id
   */
  id: string;
  /**
   * The Team identifier to perform the request on behalf of.
   */
  teamId?: string | undefined;
  /**
   * The Team slug to perform the request on behalf of.
   */
  slug?: string | undefined;
};

export type GetCertByIdResponseBody = {
  id: string;
  createdAt: number;
  expiresAt: number;
  autoRenew: boolean;
  cns: Array<string>;
};

/** @internal */
export type GetCertByIdRequest$Outbound = {
  id: string;
  teamId?: string | undefined;
  slug?: string | undefined;
};

/** @internal */
export const GetCertByIdRequest$outboundSchema: z.ZodType<
  GetCertByIdRequest$Outbound,
  z.ZodTypeDef,
  GetCertByIdRequest
> = z.object({
  id: z.string(),
  teamId: z.string().optional(),
  slug: z.string().optional(),
});

export function getCertByIdRequestToJSON(
  getCertByIdRequest: GetCertByIdRequest,
): string {
  return JSON.stringify(
    GetCertByIdRequest$outboundSchema.parse(getCertByIdRequest),
  );
}

/** @internal */
export const GetCertByIdResponseBody$inboundSchema: z.ZodType<
  GetCertByIdResponseBody,
  z.ZodTypeDef,
  unknown
> = z.object({
  id: types.string(),
  createdAt: types.number(),
  expiresAt: types.number(),
  autoRenew: types.boolean(),
  cns: z.array(types.string()),
});

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