/*
 * 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 {
  ListResourceCustomerPaymentMethod,
  ListResourceCustomerPaymentMethod$inboundSchema,
} from "../components/listresourcecustomerpaymentmethod.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

export type CustomerPortalCustomersListPaymentMethodsSecurity = {
  customerSession?: string | undefined;
  memberSession?: string | undefined;
};

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

export type CustomerPortalCustomersListPaymentMethodsResponse = {
  result: ListResourceCustomerPaymentMethod;
};

/** @internal */
export type CustomerPortalCustomersListPaymentMethodsSecurity$Outbound = {
  customer_session?: string | undefined;
  member_session?: string | undefined;
};

/** @internal */
export const CustomerPortalCustomersListPaymentMethodsSecurity$outboundSchema:
  z.ZodMiniType<
    CustomerPortalCustomersListPaymentMethodsSecurity$Outbound,
    CustomerPortalCustomersListPaymentMethodsSecurity
  > = z.pipe(
    z.object({
      customerSession: z.optional(z.string()),
      memberSession: z.optional(z.string()),
    }),
    z.transform((v) => {
      return remap$(v, {
        customerSession: "customer_session",
        memberSession: "member_session",
      });
    }),
  );

export function customerPortalCustomersListPaymentMethodsSecurityToJSON(
  customerPortalCustomersListPaymentMethodsSecurity:
    CustomerPortalCustomersListPaymentMethodsSecurity,
): string {
  return JSON.stringify(
    CustomerPortalCustomersListPaymentMethodsSecurity$outboundSchema.parse(
      customerPortalCustomersListPaymentMethodsSecurity,
    ),
  );
}

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

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

export function customerPortalCustomersListPaymentMethodsRequestToJSON(
  customerPortalCustomersListPaymentMethodsRequest:
    CustomerPortalCustomersListPaymentMethodsRequest,
): string {
  return JSON.stringify(
    CustomerPortalCustomersListPaymentMethodsRequest$outboundSchema.parse(
      customerPortalCustomersListPaymentMethodsRequest,
    ),
  );
}

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

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