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

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

export type CustomerPortalLicenseKeysListRequest = {
  /**
   * Filter by a specific benefit
   */
  benefitId?: string | null | undefined;
  /**
   * Page number, defaults to 1.
   */
  page?: number | undefined;
  /**
   * Size of a page, defaults to 10. Maximum is 100.
   */
  limit?: number | undefined;
};

export type CustomerPortalLicenseKeysListResponse = {
  result: ListResourceLicenseKeyRead;
};

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

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

/** @internal */
export type CustomerPortalLicenseKeysListRequest$Outbound = {
  benefit_id?: string | null | undefined;
  page: number;
  limit: number;
};

/** @internal */
export const CustomerPortalLicenseKeysListRequest$outboundSchema: z.ZodMiniType<
  CustomerPortalLicenseKeysListRequest$Outbound,
  CustomerPortalLicenseKeysListRequest
> = z.pipe(
  z.object({
    benefitId: z.optional(z.nullable(z.string())),
    page: z._default(z.int(), 1),
    limit: z._default(z.int(), 10),
  }),
  z.transform((v) => {
    return remap$(v, {
      benefitId: "benefit_id",
    });
  }),
);

export function customerPortalLicenseKeysListRequestToJSON(
  customerPortalLicenseKeysListRequest: CustomerPortalLicenseKeysListRequest,
): string {
  return JSON.stringify(
    CustomerPortalLicenseKeysListRequest$outboundSchema.parse(
      customerPortalLicenseKeysListRequest,
    ),
  );
}

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

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