/*
 * 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 { SDKValidationError } from "../errors/sdkvalidationerror.js";
import {
  BenefitLicenseKeyActivationProperties,
  BenefitLicenseKeyActivationProperties$inboundSchema,
} from "./benefitlicensekeyactivationproperties.js";
import {
  BenefitLicenseKeyExpirationProperties,
  BenefitLicenseKeyExpirationProperties$inboundSchema,
} from "./benefitlicensekeyexpirationproperties.js";

export type BenefitLicenseKeysSubscriberProperties = {
  prefix: string | null;
  expires: BenefitLicenseKeyExpirationProperties | null;
  activations: BenefitLicenseKeyActivationProperties | null;
  limitUsage: number | null;
};

/** @internal */
export const BenefitLicenseKeysSubscriberProperties$inboundSchema:
  z.ZodMiniType<BenefitLicenseKeysSubscriberProperties, unknown> = z.pipe(
    z.object({
      prefix: z.nullable(z.string()),
      expires: z.nullable(BenefitLicenseKeyExpirationProperties$inboundSchema),
      activations: z.nullable(
        BenefitLicenseKeyActivationProperties$inboundSchema,
      ),
      limit_usage: z.nullable(z.int()),
    }),
    z.transform((v) => {
      return remap$(v, {
        "limit_usage": "limitUsage",
      });
    }),
  );

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