/*
 * 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 {
  CustomerWalletSortProperty,
  CustomerWalletSortProperty$outboundSchema,
} from "../components/customerwalletsortproperty.js";
import {
  ListResourceCustomerWallet,
  ListResourceCustomerWallet$inboundSchema,
} from "../components/listresourcecustomerwallet.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

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

export type CustomerPortalWalletsListRequest = {
  /**
   * Page number, defaults to 1.
   */
  page?: number | undefined;
  /**
   * Size of a page, defaults to 10. Maximum is 100.
   */
  limit?: number | undefined;
  /**
   * Sorting criterion. Several criteria can be used simultaneously and will be applied in order. Add a minus sign `-` before the criteria name to sort by descending order.
   */
  sorting?: Array<CustomerWalletSortProperty> | null | undefined;
};

export type CustomerPortalWalletsListResponse = {
  result: ListResourceCustomerWallet;
};

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

/** @internal */
export const CustomerPortalWalletsListSecurity$outboundSchema: z.ZodMiniType<
  CustomerPortalWalletsListSecurity$Outbound,
  CustomerPortalWalletsListSecurity
> = 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 customerPortalWalletsListSecurityToJSON(
  customerPortalWalletsListSecurity: CustomerPortalWalletsListSecurity,
): string {
  return JSON.stringify(
    CustomerPortalWalletsListSecurity$outboundSchema.parse(
      customerPortalWalletsListSecurity,
    ),
  );
}

/** @internal */
export type CustomerPortalWalletsListRequest$Outbound = {
  page: number;
  limit: number;
  sorting?: Array<string> | null | undefined;
};

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

export function customerPortalWalletsListRequestToJSON(
  customerPortalWalletsListRequest: CustomerPortalWalletsListRequest,
): string {
  return JSON.stringify(
    CustomerPortalWalletsListRequest$outboundSchema.parse(
      customerPortalWalletsListRequest,
    ),
  );
}

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

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