/*
 * 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 { Pagination, Pagination$inboundSchema } from "./pagination.js";
import { SDKValidationError } from "./sdkvalidationerror.js";

export type GetCertsRequest = {
  /**
   * 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 Certs = {
  id: string;
  createdAt: number;
  expiresAt: number;
  autoRenew: boolean;
  cns: Array<string>;
};

export type GetCertsResponseBody = {
  certs: Array<Certs>;
  /**
   * This object contains information related to the pagination of the current request, including the necessary parameters to get the next or previous page of data.
   */
  pagination: Pagination;
};

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

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

export function getCertsRequestToJSON(
  getCertsRequest: GetCertsRequest,
): string {
  return JSON.stringify(GetCertsRequest$outboundSchema.parse(getCertsRequest));
}

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

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

/** @internal */
export const GetCertsResponseBody$inboundSchema: z.ZodType<
  GetCertsResponseBody,
  z.ZodTypeDef,
  unknown
> = z.object({
  certs: z.array(z.lazy(() => Certs$inboundSchema)),
  pagination: Pagination$inboundSchema,
});

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