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

import * as z from "zod/v4-mini";
import { remap as remap$ } from "../../lib/primitives.js";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import {
  ListResourcePaymentMethod,
  ListResourcePaymentMethod$inboundSchema,
} from "../components/listresourcepaymentmethod.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

export type CustomersListPaymentMethodsRequest = {
  /**
   * The customer ID.
   */
  id: string;
  /**
   * Page number, defaults to 1.
   */
  page?: number | undefined;
  /**
   * Size of a page, defaults to 10. Maximum is 100.
   */
  limit?: number | undefined;
};

export type CustomersListPaymentMethodsResponse = {
  result: ListResourcePaymentMethod;
};

/** @internal */
export type CustomersListPaymentMethodsRequest$Outbound = {
  id: string;
  page: number;
  limit: number;
};

/** @internal */
export const CustomersListPaymentMethodsRequest$outboundSchema: z.ZodMiniType<
  CustomersListPaymentMethodsRequest$Outbound,
  CustomersListPaymentMethodsRequest
> = z.object({
  id: z.string(),
  page: z._default(z.int(), 1),
  limit: z._default(z.int(), 10),
});

export function customersListPaymentMethodsRequestToJSON(
  customersListPaymentMethodsRequest: CustomersListPaymentMethodsRequest,
): string {
  return JSON.stringify(
    CustomersListPaymentMethodsRequest$outboundSchema.parse(
      customersListPaymentMethodsRequest,
    ),
  );
}

/** @internal */
export const CustomersListPaymentMethodsResponse$inboundSchema: z.ZodMiniType<
  CustomersListPaymentMethodsResponse,
  unknown
> = z.pipe(
  z.object({
    Result: ListResourcePaymentMethod$inboundSchema,
  }),
  z.transform((v) => {
    return remap$(v, {
      "Result": "result",
    });
  }),
);

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