/*
 * 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 { Metric, Metric$inboundSchema } from "./metric.js";

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

/** @internal */
export const Metrics$inboundSchema: z.ZodMiniType<Metrics, unknown> = z.pipe(
  z.object({
    active_subscriptions: z.optional(z.nullable(Metric$inboundSchema)),
    committed_subscriptions: z.optional(z.nullable(Metric$inboundSchema)),
    monthly_recurring_revenue: z.optional(z.nullable(Metric$inboundSchema)),
    trial_monthly_recurring_revenue: z.optional(
      z.nullable(Metric$inboundSchema),
    ),
    committed_monthly_recurring_revenue: z.optional(
      z.nullable(Metric$inboundSchema),
    ),
    trial_committed_monthly_recurring_revenue: z.optional(
      z.nullable(Metric$inboundSchema),
    ),
    average_revenue_per_user: z.optional(z.nullable(Metric$inboundSchema)),
    checkouts: z.optional(z.nullable(Metric$inboundSchema)),
    succeeded_checkouts: z.optional(z.nullable(Metric$inboundSchema)),
    churned_subscriptions: z.optional(z.nullable(Metric$inboundSchema)),
    churn_rate: z.optional(z.nullable(Metric$inboundSchema)),
    seats_total: z.optional(z.nullable(Metric$inboundSchema)),
    seats_claimed: z.optional(z.nullable(Metric$inboundSchema)),
    seats_pending: z.optional(z.nullable(Metric$inboundSchema)),
    seat_customers: z.optional(z.nullable(Metric$inboundSchema)),
    new_seat_customers: z.optional(z.nullable(Metric$inboundSchema)),
    churned_seat_customers: z.optional(z.nullable(Metric$inboundSchema)),
    orders: z.optional(z.nullable(Metric$inboundSchema)),
    revenue: z.optional(z.nullable(Metric$inboundSchema)),
    net_revenue: z.optional(z.nullable(Metric$inboundSchema)),
    cumulative_revenue: z.optional(z.nullable(Metric$inboundSchema)),
    net_cumulative_revenue: z.optional(z.nullable(Metric$inboundSchema)),
    costs: z.optional(z.nullable(Metric$inboundSchema)),
    cumulative_costs: z.optional(z.nullable(Metric$inboundSchema)),
    average_order_value: z.optional(z.nullable(Metric$inboundSchema)),
    net_average_order_value: z.optional(z.nullable(Metric$inboundSchema)),
    cost_per_user: z.optional(z.nullable(Metric$inboundSchema)),
    active_user_by_event: z.optional(z.nullable(Metric$inboundSchema)),
    one_time_products: z.optional(z.nullable(Metric$inboundSchema)),
    one_time_products_revenue: z.optional(z.nullable(Metric$inboundSchema)),
    one_time_products_net_revenue: z.optional(z.nullable(Metric$inboundSchema)),
    new_subscriptions: z.optional(z.nullable(Metric$inboundSchema)),
    new_subscriptions_revenue: z.optional(z.nullable(Metric$inboundSchema)),
    new_subscriptions_net_revenue: z.optional(z.nullable(Metric$inboundSchema)),
    renewed_subscriptions: z.optional(z.nullable(Metric$inboundSchema)),
    renewed_subscriptions_revenue: z.optional(z.nullable(Metric$inboundSchema)),
    renewed_subscriptions_net_revenue: z.optional(
      z.nullable(Metric$inboundSchema),
    ),
    canceled_subscriptions: z.optional(z.nullable(Metric$inboundSchema)),
    canceled_subscriptions_customer_service: z.optional(
      z.nullable(Metric$inboundSchema),
    ),
    canceled_subscriptions_low_quality: z.optional(
      z.nullable(Metric$inboundSchema),
    ),
    canceled_subscriptions_missing_features: z.optional(
      z.nullable(Metric$inboundSchema),
    ),
    canceled_subscriptions_switched_service: z.optional(
      z.nullable(Metric$inboundSchema),
    ),
    canceled_subscriptions_too_complex: z.optional(
      z.nullable(Metric$inboundSchema),
    ),
    canceled_subscriptions_too_expensive: z.optional(
      z.nullable(Metric$inboundSchema),
    ),
    canceled_subscriptions_unused: z.optional(z.nullable(Metric$inboundSchema)),
    canceled_subscriptions_other: z.optional(z.nullable(Metric$inboundSchema)),
    annual_recurring_revenue: z.optional(z.nullable(Metric$inboundSchema)),
    committed_annual_recurring_revenue: z.optional(
      z.nullable(Metric$inboundSchema),
    ),
    checkouts_conversion: z.optional(z.nullable(Metric$inboundSchema)),
    ltv: z.optional(z.nullable(Metric$inboundSchema)),
    gross_margin: z.optional(z.nullable(Metric$inboundSchema)),
    gross_margin_percentage: z.optional(z.nullable(Metric$inboundSchema)),
    cashflow: z.optional(z.nullable(Metric$inboundSchema)),
    average_seats_per_customer: z.optional(z.nullable(Metric$inboundSchema)),
    seat_utilization_rate: z.optional(z.nullable(Metric$inboundSchema)),
  }),
  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 metricsFromJSON(
  jsonString: string,
): SafeParseResult<Metrics, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => Metrics$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'Metrics' from JSON`,
  );
}
