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

import * as z from "zod";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import * as models from "../index.js";

export type ListLeadsRequest = {
  /**
   * Maximum number of leads to return
   */
  limit?: number | undefined;
  /**
   * Number of leads to skip
   */
  offset?: number | undefined;
};

/**
 * List of leads
 */
export type ListLeadsResponse = {
  leads?: Array<models.Lead> | undefined;
  total?: number | undefined;
};

/** @internal */
export const ListLeadsRequest$inboundSchema: z.ZodType<
  ListLeadsRequest,
  z.ZodTypeDef,
  unknown
> = z.object({
  limit: z.number().int().default(50),
  offset: z.number().int().default(0),
});

/** @internal */
export type ListLeadsRequest$Outbound = {
  limit: number;
  offset: number;
};

/** @internal */
export const ListLeadsRequest$outboundSchema: z.ZodType<
  ListLeadsRequest$Outbound,
  z.ZodTypeDef,
  ListLeadsRequest
> = z.object({
  limit: z.number().int().default(50),
  offset: z.number().int().default(0),
});

/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export namespace ListLeadsRequest$ {
  /** @deprecated use `ListLeadsRequest$inboundSchema` instead. */
  export const inboundSchema = ListLeadsRequest$inboundSchema;
  /** @deprecated use `ListLeadsRequest$outboundSchema` instead. */
  export const outboundSchema = ListLeadsRequest$outboundSchema;
  /** @deprecated use `ListLeadsRequest$Outbound` instead. */
  export type Outbound = ListLeadsRequest$Outbound;
}

export function listLeadsRequestToJSON(
  listLeadsRequest: ListLeadsRequest,
): string {
  return JSON.stringify(
    ListLeadsRequest$outboundSchema.parse(listLeadsRequest),
  );
}

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

/** @internal */
export const ListLeadsResponse$inboundSchema: z.ZodType<
  ListLeadsResponse,
  z.ZodTypeDef,
  unknown
> = z.object({
  leads: z.array(models.Lead$inboundSchema).optional(),
  total: z.number().int().optional(),
});

/** @internal */
export type ListLeadsResponse$Outbound = {
  leads?: Array<models.Lead$Outbound> | undefined;
  total?: number | undefined;
};

/** @internal */
export const ListLeadsResponse$outboundSchema: z.ZodType<
  ListLeadsResponse$Outbound,
  z.ZodTypeDef,
  ListLeadsResponse
> = z.object({
  leads: z.array(models.Lead$outboundSchema).optional(),
  total: z.number().int().optional(),
});

/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export namespace ListLeadsResponse$ {
  /** @deprecated use `ListLeadsResponse$inboundSchema` instead. */
  export const inboundSchema = ListLeadsResponse$inboundSchema;
  /** @deprecated use `ListLeadsResponse$outboundSchema` instead. */
  export const outboundSchema = ListLeadsResponse$outboundSchema;
  /** @deprecated use `ListLeadsResponse$Outbound` instead. */
  export type Outbound = ListLeadsResponse$Outbound;
}

export function listLeadsResponseToJSON(
  listLeadsResponse: ListLeadsResponse,
): string {
  return JSON.stringify(
    ListLeadsResponse$outboundSchema.parse(listLeadsResponse),
  );
}

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