/*
 * 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 { smartUnion } from "../../types/smartUnion.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

export type ActiveSubscriptions = number | number;

export type CommittedSubscriptions = number | number;

export type MonthlyRecurringRevenue = number | number;

export type TrialMonthlyRecurringRevenue = number | number;

export type CommittedMonthlyRecurringRevenue = number | number;

export type TrialCommittedMonthlyRecurringRevenue = number | number;

export type AverageRevenuePerUser = number | number;

export type Checkouts = number | number;

export type SucceededCheckouts = number | number;

export type ChurnedSubscriptions = number | number;

export type ChurnRate = number | number;

export type SeatsTotal = number | number;

export type SeatsClaimed = number | number;

export type SeatsPending = number | number;

export type SeatCustomers = number | number;

export type NewSeatCustomers = number | number;

export type ChurnedSeatCustomers = number | number;

export type Orders = number | number;

export type Revenue = number | number;

export type NetRevenue = number | number;

export type CumulativeRevenue = number | number;

export type NetCumulativeRevenue = number | number;

export type Costs = number | number;

export type CumulativeCosts = number | number;

export type AverageOrderValue = number | number;

export type NetAverageOrderValue = number | number;

export type CostPerUser = number | number;

export type ActiveUserByEvent = number | number;

export type OneTimeProducts = number | number;

export type OneTimeProductsRevenue = number | number;

export type OneTimeProductsNetRevenue = number | number;

export type NewSubscriptions = number | number;

export type NewSubscriptionsRevenue = number | number;

export type NewSubscriptionsNetRevenue = number | number;

export type RenewedSubscriptions = number | number;

export type RenewedSubscriptionsRevenue = number | number;

export type RenewedSubscriptionsNetRevenue = number | number;

export type CanceledSubscriptions = number | number;

export type CanceledSubscriptionsCustomerService = number | number;

export type CanceledSubscriptionsLowQuality = number | number;

export type CanceledSubscriptionsMissingFeatures = number | number;

export type CanceledSubscriptionsSwitchedService = number | number;

export type CanceledSubscriptionsTooComplex = number | number;

export type CanceledSubscriptionsTooExpensive = number | number;

export type CanceledSubscriptionsUnused = number | number;

export type CanceledSubscriptionsOther = number | number;

export type AnnualRecurringRevenue = number | number;

export type CommittedAnnualRecurringRevenue = number | number;

export type CheckoutsConversion = number | number;

export type Ltv = number | number;

export type GrossMargin = number | number;

export type GrossMarginPercentage = number | number;

export type Cashflow = number | number;

export type AverageSeatsPerCustomer = number | number;

export type SeatUtilizationRate = number | number;

export type MetricPeriod = {
  /**
   * Timestamp of this period data.
   */
  timestamp: Date;
  activeSubscriptions?: number | number | null | undefined;
  committedSubscriptions?: number | number | null | undefined;
  monthlyRecurringRevenue?: number | number | null | undefined;
  trialMonthlyRecurringRevenue?: number | number | null | undefined;
  committedMonthlyRecurringRevenue?: number | number | null | undefined;
  trialCommittedMonthlyRecurringRevenue?: number | number | null | undefined;
  averageRevenuePerUser?: number | number | null | undefined;
  checkouts?: number | number | null | undefined;
  succeededCheckouts?: number | number | null | undefined;
  churnedSubscriptions?: number | number | null | undefined;
  churnRate?: number | number | null | undefined;
  seatsTotal?: number | number | null | undefined;
  seatsClaimed?: number | number | null | undefined;
  seatsPending?: number | number | null | undefined;
  seatCustomers?: number | number | null | undefined;
  newSeatCustomers?: number | number | null | undefined;
  churnedSeatCustomers?: number | number | null | undefined;
  orders?: number | number | null | undefined;
  revenue?: number | number | null | undefined;
  netRevenue?: number | number | null | undefined;
  cumulativeRevenue?: number | number | null | undefined;
  netCumulativeRevenue?: number | number | null | undefined;
  costs?: number | number | null | undefined;
  cumulativeCosts?: number | number | null | undefined;
  averageOrderValue?: number | number | null | undefined;
  netAverageOrderValue?: number | number | null | undefined;
  costPerUser?: number | number | null | undefined;
  activeUserByEvent?: number | number | null | undefined;
  oneTimeProducts?: number | number | null | undefined;
  oneTimeProductsRevenue?: number | number | null | undefined;
  oneTimeProductsNetRevenue?: number | number | null | undefined;
  newSubscriptions?: number | number | null | undefined;
  newSubscriptionsRevenue?: number | number | null | undefined;
  newSubscriptionsNetRevenue?: number | number | null | undefined;
  renewedSubscriptions?: number | number | null | undefined;
  renewedSubscriptionsRevenue?: number | number | null | undefined;
  renewedSubscriptionsNetRevenue?: number | number | null | undefined;
  canceledSubscriptions?: number | number | null | undefined;
  canceledSubscriptionsCustomerService?: number | number | null | undefined;
  canceledSubscriptionsLowQuality?: number | number | null | undefined;
  canceledSubscriptionsMissingFeatures?: number | number | null | undefined;
  canceledSubscriptionsSwitchedService?: number | number | null | undefined;
  canceledSubscriptionsTooComplex?: number | number | null | undefined;
  canceledSubscriptionsTooExpensive?: number | number | null | undefined;
  canceledSubscriptionsUnused?: number | number | null | undefined;
  canceledSubscriptionsOther?: number | number | null | undefined;
  annualRecurringRevenue?: number | number | null | undefined;
  committedAnnualRecurringRevenue?: number | number | null | undefined;
  checkoutsConversion?: number | number | null | undefined;
  ltv?: number | number | null | undefined;
  grossMargin?: number | number | null | undefined;
  grossMarginPercentage?: number | number | null | undefined;
  cashflow?: number | number | null | undefined;
  averageSeatsPerCustomer?: number | number | null | undefined;
  seatUtilizationRate?: number | number | null | undefined;
};

/** @internal */
export const ActiveSubscriptions$inboundSchema: z.ZodMiniType<
  ActiveSubscriptions,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const CommittedSubscriptions$inboundSchema: z.ZodMiniType<
  CommittedSubscriptions,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const MonthlyRecurringRevenue$inboundSchema: z.ZodMiniType<
  MonthlyRecurringRevenue,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const TrialMonthlyRecurringRevenue$inboundSchema: z.ZodMiniType<
  TrialMonthlyRecurringRevenue,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const CommittedMonthlyRecurringRevenue$inboundSchema: z.ZodMiniType<
  CommittedMonthlyRecurringRevenue,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const TrialCommittedMonthlyRecurringRevenue$inboundSchema: z.ZodMiniType<
  TrialCommittedMonthlyRecurringRevenue,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const AverageRevenuePerUser$inboundSchema: z.ZodMiniType<
  AverageRevenuePerUser,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const Checkouts$inboundSchema: z.ZodMiniType<Checkouts, unknown> =
  smartUnion([z.int(), z.number()]);

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

/** @internal */
export const SucceededCheckouts$inboundSchema: z.ZodMiniType<
  SucceededCheckouts,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const ChurnedSubscriptions$inboundSchema: z.ZodMiniType<
  ChurnedSubscriptions,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const ChurnRate$inboundSchema: z.ZodMiniType<ChurnRate, unknown> =
  smartUnion([z.int(), z.number()]);

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

/** @internal */
export const SeatsTotal$inboundSchema: z.ZodMiniType<SeatsTotal, unknown> =
  smartUnion([z.int(), z.number()]);

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

/** @internal */
export const SeatsClaimed$inboundSchema: z.ZodMiniType<SeatsClaimed, unknown> =
  smartUnion([z.int(), z.number()]);

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

/** @internal */
export const SeatsPending$inboundSchema: z.ZodMiniType<SeatsPending, unknown> =
  smartUnion([z.int(), z.number()]);

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

/** @internal */
export const SeatCustomers$inboundSchema: z.ZodMiniType<
  SeatCustomers,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const NewSeatCustomers$inboundSchema: z.ZodMiniType<
  NewSeatCustomers,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const ChurnedSeatCustomers$inboundSchema: z.ZodMiniType<
  ChurnedSeatCustomers,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const Orders$inboundSchema: z.ZodMiniType<Orders, unknown> = smartUnion([
  z.int(),
  z.number(),
]);

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

/** @internal */
export const Revenue$inboundSchema: z.ZodMiniType<Revenue, unknown> =
  smartUnion([z.int(), z.number()]);

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

/** @internal */
export const NetRevenue$inboundSchema: z.ZodMiniType<NetRevenue, unknown> =
  smartUnion([z.int(), z.number()]);

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

/** @internal */
export const CumulativeRevenue$inboundSchema: z.ZodMiniType<
  CumulativeRevenue,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const NetCumulativeRevenue$inboundSchema: z.ZodMiniType<
  NetCumulativeRevenue,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const Costs$inboundSchema: z.ZodMiniType<Costs, unknown> = smartUnion([
  z.int(),
  z.number(),
]);

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

/** @internal */
export const CumulativeCosts$inboundSchema: z.ZodMiniType<
  CumulativeCosts,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const AverageOrderValue$inboundSchema: z.ZodMiniType<
  AverageOrderValue,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const NetAverageOrderValue$inboundSchema: z.ZodMiniType<
  NetAverageOrderValue,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const CostPerUser$inboundSchema: z.ZodMiniType<CostPerUser, unknown> =
  smartUnion([z.int(), z.number()]);

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

/** @internal */
export const ActiveUserByEvent$inboundSchema: z.ZodMiniType<
  ActiveUserByEvent,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const OneTimeProducts$inboundSchema: z.ZodMiniType<
  OneTimeProducts,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const OneTimeProductsRevenue$inboundSchema: z.ZodMiniType<
  OneTimeProductsRevenue,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const OneTimeProductsNetRevenue$inboundSchema: z.ZodMiniType<
  OneTimeProductsNetRevenue,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const NewSubscriptions$inboundSchema: z.ZodMiniType<
  NewSubscriptions,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const NewSubscriptionsRevenue$inboundSchema: z.ZodMiniType<
  NewSubscriptionsRevenue,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const NewSubscriptionsNetRevenue$inboundSchema: z.ZodMiniType<
  NewSubscriptionsNetRevenue,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const RenewedSubscriptions$inboundSchema: z.ZodMiniType<
  RenewedSubscriptions,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const RenewedSubscriptionsRevenue$inboundSchema: z.ZodMiniType<
  RenewedSubscriptionsRevenue,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const RenewedSubscriptionsNetRevenue$inboundSchema: z.ZodMiniType<
  RenewedSubscriptionsNetRevenue,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const CanceledSubscriptions$inboundSchema: z.ZodMiniType<
  CanceledSubscriptions,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const CanceledSubscriptionsCustomerService$inboundSchema: z.ZodMiniType<
  CanceledSubscriptionsCustomerService,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const CanceledSubscriptionsLowQuality$inboundSchema: z.ZodMiniType<
  CanceledSubscriptionsLowQuality,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const CanceledSubscriptionsMissingFeatures$inboundSchema: z.ZodMiniType<
  CanceledSubscriptionsMissingFeatures,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const CanceledSubscriptionsSwitchedService$inboundSchema: z.ZodMiniType<
  CanceledSubscriptionsSwitchedService,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const CanceledSubscriptionsTooComplex$inboundSchema: z.ZodMiniType<
  CanceledSubscriptionsTooComplex,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const CanceledSubscriptionsTooExpensive$inboundSchema: z.ZodMiniType<
  CanceledSubscriptionsTooExpensive,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const CanceledSubscriptionsUnused$inboundSchema: z.ZodMiniType<
  CanceledSubscriptionsUnused,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const CanceledSubscriptionsOther$inboundSchema: z.ZodMiniType<
  CanceledSubscriptionsOther,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const AnnualRecurringRevenue$inboundSchema: z.ZodMiniType<
  AnnualRecurringRevenue,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const CommittedAnnualRecurringRevenue$inboundSchema: z.ZodMiniType<
  CommittedAnnualRecurringRevenue,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const CheckoutsConversion$inboundSchema: z.ZodMiniType<
  CheckoutsConversion,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const Ltv$inboundSchema: z.ZodMiniType<Ltv, unknown> = smartUnion([
  z.int(),
  z.number(),
]);

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

/** @internal */
export const GrossMargin$inboundSchema: z.ZodMiniType<GrossMargin, unknown> =
  smartUnion([z.int(), z.number()]);

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

/** @internal */
export const GrossMarginPercentage$inboundSchema: z.ZodMiniType<
  GrossMarginPercentage,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const Cashflow$inboundSchema: z.ZodMiniType<Cashflow, unknown> =
  smartUnion([z.int(), z.number()]);

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

/** @internal */
export const AverageSeatsPerCustomer$inboundSchema: z.ZodMiniType<
  AverageSeatsPerCustomer,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const SeatUtilizationRate$inboundSchema: z.ZodMiniType<
  SeatUtilizationRate,
  unknown
> = smartUnion([z.int(), z.number()]);

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

/** @internal */
export const MetricPeriod$inboundSchema: z.ZodMiniType<MetricPeriod, unknown> =
  z.pipe(
    z.object({
      timestamp: z.pipe(
        z.iso.datetime({ offset: true }),
        z.transform(v => new Date(v)),
      ),
      active_subscriptions: z.optional(
        z.nullable(smartUnion([z.int(), z.number()])),
      ),
      committed_subscriptions: z.optional(
        z.nullable(smartUnion([z.int(), z.number()])),
      ),
      monthly_recurring_revenue: z.optional(
        z.nullable(smartUnion([z.int(), z.number()])),
      ),
      trial_monthly_recurring_revenue: z.optional(
        z.nullable(smartUnion([z.int(), z.number()])),
      ),
      committed_monthly_recurring_revenue: z.optional(
        z.nullable(smartUnion([z.int(), z.number()])),
      ),
      trial_committed_monthly_recurring_revenue: z.optional(
        z.nullable(smartUnion([z.int(), z.number()])),
      ),
      average_revenue_per_user: z.optional(
        z.nullable(smartUnion([z.int(), z.number()])),
      ),
      checkouts: z.optional(z.nullable(smartUnion([z.int(), z.number()]))),
      succeeded_checkouts: z.optional(
        z.nullable(smartUnion([z.int(), z.number()])),
      ),
      churned_subscriptions: z.optional(
        z.nullable(smartUnion([z.int(), z.number()])),
      ),
      churn_rate: z.optional(z.nullable(smartUnion([z.int(), z.number()]))),
      seats_total: z.optional(z.nullable(smartUnion([z.int(), z.number()]))),
      seats_claimed: z.optional(z.nullable(smartUnion([z.int(), z.number()]))),
      seats_pending: z.optional(z.nullable(smartUnion([z.int(), z.number()]))),
      seat_customers: z.optional(z.nullable(smartUnion([z.int(), z.number()]))),
      new_seat_customers: z.optional(
        z.nullable(smartUnion([z.int(), z.number()])),
      ),
      churned_seat_customers: z.optional(
        z.nullable(smartUnion([z.int(), z.number()])),
      ),
      orders: z.optional(z.nullable(smartUnion([z.int(), z.number()]))),
      revenue: z.optional(z.nullable(smartUnion([z.int(), z.number()]))),
      net_revenue: z.optional(z.nullable(smartUnion([z.int(), z.number()]))),
      cumulative_revenue: z.optional(
        z.nullable(smartUnion([z.int(), z.number()])),
      ),
      net_cumulative_revenue: z.optional(
        z.nullable(smartUnion([z.int(), z.number()])),
      ),
      costs: z.optional(z.nullable(smartUnion([z.int(), z.number()]))),
      cumulative_costs: z.optional(
        z.nullable(smartUnion([z.int(), z.number()])),
      ),
      average_order_value: z.optional(
        z.nullable(smartUnion([z.int(), z.number()])),
      ),
      net_average_order_value: z.optional(
        z.nullable(smartUnion([z.int(), z.number()])),
      ),
      cost_per_user: z.optional(z.nullable(smartUnion([z.int(), z.number()]))),
      active_user_by_event: z.optional(
        z.nullable(smartUnion([z.int(), z.number()])),
      ),
      one_time_products: z.optional(
        z.nullable(smartUnion([z.int(), z.number()])),
      ),
      one_time_products_revenue: z.optional(
        z.nullable(smartUnion([z.int(), z.number()])),
      ),
      one_time_products_net_revenue: z.optional(
        z.nullable(smartUnion([z.int(), z.number()])),
      ),
      new_subscriptions: z.optional(
        z.nullable(smartUnion([z.int(), z.number()])),
      ),
      new_subscriptions_revenue: z.optional(
        z.nullable(smartUnion([z.int(), z.number()])),
      ),
      new_subscriptions_net_revenue: z.optional(
        z.nullable(smartUnion([z.int(), z.number()])),
      ),
      renewed_subscriptions: z.optional(
        z.nullable(smartUnion([z.int(), z.number()])),
      ),
      renewed_subscriptions_revenue: z.optional(
        z.nullable(smartUnion([z.int(), z.number()])),
      ),
      renewed_subscriptions_net_revenue: z.optional(
        z.nullable(smartUnion([z.int(), z.number()])),
      ),
      canceled_subscriptions: z.optional(
        z.nullable(smartUnion([z.int(), z.number()])),
      ),
      canceled_subscriptions_customer_service: z.optional(
        z.nullable(smartUnion([z.int(), z.number()])),
      ),
      canceled_subscriptions_low_quality: z.optional(
        z.nullable(smartUnion([z.int(), z.number()])),
      ),
      canceled_subscriptions_missing_features: z.optional(
        z.nullable(smartUnion([z.int(), z.number()])),
      ),
      canceled_subscriptions_switched_service: z.optional(
        z.nullable(smartUnion([z.int(), z.number()])),
      ),
      canceled_subscriptions_too_complex: z.optional(
        z.nullable(smartUnion([z.int(), z.number()])),
      ),
      canceled_subscriptions_too_expensive: z.optional(
        z.nullable(smartUnion([z.int(), z.number()])),
      ),
      canceled_subscriptions_unused: z.optional(
        z.nullable(smartUnion([z.int(), z.number()])),
      ),
      canceled_subscriptions_other: z.optional(
        z.nullable(smartUnion([z.int(), z.number()])),
      ),
      annual_recurring_revenue: z.optional(
        z.nullable(smartUnion([z.int(), z.number()])),
      ),
      committed_annual_recurring_revenue: z.optional(
        z.nullable(smartUnion([z.int(), z.number()])),
      ),
      checkouts_conversion: z.optional(
        z.nullable(smartUnion([z.int(), z.number()])),
      ),
      ltv: z.optional(z.nullable(smartUnion([z.int(), z.number()]))),
      gross_margin: z.optional(z.nullable(smartUnion([z.int(), z.number()]))),
      gross_margin_percentage: z.optional(
        z.nullable(smartUnion([z.int(), z.number()])),
      ),
      cashflow: z.optional(z.nullable(smartUnion([z.int(), z.number()]))),
      average_seats_per_customer: z.optional(
        z.nullable(smartUnion([z.int(), z.number()])),
      ),
      seat_utilization_rate: z.optional(
        z.nullable(smartUnion([z.int(), z.number()])),
      ),
    }),
    z.transform((v) => {
      return remap$(v, {
        "active_subscriptions": "activeSubscriptions",
        "committed_subscriptions": "committedSubscriptions",
        "monthly_recurring_revenue": "monthlyRecurringRevenue",
        "trial_monthly_recurring_revenue": "trialMonthlyRecurringRevenue",
        "committed_monthly_recurring_revenue":
          "committedMonthlyRecurringRevenue",
        "trial_committed_monthly_recurring_revenue":
          "trialCommittedMonthlyRecurringRevenue",
        "average_revenue_per_user": "averageRevenuePerUser",
        "succeeded_checkouts": "succeededCheckouts",
        "churned_subscriptions": "churnedSubscriptions",
        "churn_rate": "churnRate",
        "seats_total": "seatsTotal",
        "seats_claimed": "seatsClaimed",
        "seats_pending": "seatsPending",
        "seat_customers": "seatCustomers",
        "new_seat_customers": "newSeatCustomers",
        "churned_seat_customers": "churnedSeatCustomers",
        "net_revenue": "netRevenue",
        "cumulative_revenue": "cumulativeRevenue",
        "net_cumulative_revenue": "netCumulativeRevenue",
        "cumulative_costs": "cumulativeCosts",
        "average_order_value": "averageOrderValue",
        "net_average_order_value": "netAverageOrderValue",
        "cost_per_user": "costPerUser",
        "active_user_by_event": "activeUserByEvent",
        "one_time_products": "oneTimeProducts",
        "one_time_products_revenue": "oneTimeProductsRevenue",
        "one_time_products_net_revenue": "oneTimeProductsNetRevenue",
        "new_subscriptions": "newSubscriptions",
        "new_subscriptions_revenue": "newSubscriptionsRevenue",
        "new_subscriptions_net_revenue": "newSubscriptionsNetRevenue",
        "renewed_subscriptions": "renewedSubscriptions",
        "renewed_subscriptions_revenue": "renewedSubscriptionsRevenue",
        "renewed_subscriptions_net_revenue": "renewedSubscriptionsNetRevenue",
        "canceled_subscriptions": "canceledSubscriptions",
        "canceled_subscriptions_customer_service":
          "canceledSubscriptionsCustomerService",
        "canceled_subscriptions_low_quality": "canceledSubscriptionsLowQuality",
        "canceled_subscriptions_missing_features":
          "canceledSubscriptionsMissingFeatures",
        "canceled_subscriptions_switched_service":
          "canceledSubscriptionsSwitchedService",
        "canceled_subscriptions_too_complex": "canceledSubscriptionsTooComplex",
        "canceled_subscriptions_too_expensive":
          "canceledSubscriptionsTooExpensive",
        "canceled_subscriptions_unused": "canceledSubscriptionsUnused",
        "canceled_subscriptions_other": "canceledSubscriptionsOther",
        "annual_recurring_revenue": "annualRecurringRevenue",
        "committed_annual_recurring_revenue": "committedAnnualRecurringRevenue",
        "checkouts_conversion": "checkoutsConversion",
        "gross_margin": "grossMargin",
        "gross_margin_percentage": "grossMarginPercentage",
        "average_seats_per_customer": "averageSeatsPerCustomer",
        "seat_utilization_rate": "seatUtilizationRate",
      });
    }),
  );

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