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

import * as z from "zod";
import { remap as remap$ } from "../../lib/primitives.js";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import {
  Thread,
  Thread$inboundSchema,
  Thread$Outbound,
  Thread$outboundSchema,
} from "../components/thread.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

export type GetV2ThreadsRequest = {
  recordId?: string | undefined;
  object?: string | undefined;
  entryId?: string | undefined;
  list?: string | undefined;
  limit?: number | undefined;
  offset?: number | undefined;
};

/**
 * Success
 */
export type GetV2ThreadsResponse = {
  data: Array<Thread>;
};

/** @internal */
export const GetV2ThreadsRequest$inboundSchema: z.ZodType<
  GetV2ThreadsRequest,
  z.ZodTypeDef,
  unknown
> = z.object({
  record_id: z.string().optional(),
  object: z.string().optional(),
  entry_id: z.string().optional(),
  list: z.string().optional(),
  limit: z.number().int().optional(),
  offset: z.number().int().optional(),
}).transform((v) => {
  return remap$(v, {
    "record_id": "recordId",
    "entry_id": "entryId",
  });
});

/** @internal */
export type GetV2ThreadsRequest$Outbound = {
  record_id?: string | undefined;
  object?: string | undefined;
  entry_id?: string | undefined;
  list?: string | undefined;
  limit?: number | undefined;
  offset?: number | undefined;
};

/** @internal */
export const GetV2ThreadsRequest$outboundSchema: z.ZodType<
  GetV2ThreadsRequest$Outbound,
  z.ZodTypeDef,
  GetV2ThreadsRequest
> = z.object({
  recordId: z.string().optional(),
  object: z.string().optional(),
  entryId: z.string().optional(),
  list: z.string().optional(),
  limit: z.number().int().optional(),
  offset: z.number().int().optional(),
}).transform((v) => {
  return remap$(v, {
    recordId: "record_id",
    entryId: "entry_id",
  });
});

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

export function getV2ThreadsRequestToJSON(
  getV2ThreadsRequest: GetV2ThreadsRequest,
): string {
  return JSON.stringify(
    GetV2ThreadsRequest$outboundSchema.parse(getV2ThreadsRequest),
  );
}

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

/** @internal */
export const GetV2ThreadsResponse$inboundSchema: z.ZodType<
  GetV2ThreadsResponse,
  z.ZodTypeDef,
  unknown
> = z.object({
  data: z.array(Thread$inboundSchema),
});

/** @internal */
export type GetV2ThreadsResponse$Outbound = {
  data: Array<Thread$Outbound>;
};

/** @internal */
export const GetV2ThreadsResponse$outboundSchema: z.ZodType<
  GetV2ThreadsResponse$Outbound,
  z.ZodTypeDef,
  GetV2ThreadsResponse
> = z.object({
  data: z.array(Thread$outboundSchema),
});

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

export function getV2ThreadsResponseToJSON(
  getV2ThreadsResponse: GetV2ThreadsResponse,
): string {
  return JSON.stringify(
    GetV2ThreadsResponse$outboundSchema.parse(getV2ThreadsResponse),
  );
}

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