/*
 * 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";

export type OrganizationFeatureSettings = {
  /**
   * If this organization has issue funding enabled
   */
  issueFundingEnabled?: boolean | undefined;
  /**
   * If this organization has seat-based pricing enabled
   */
  seatBasedPricingEnabled?: boolean | undefined;
  /**
   * If this organization has Wallets enabled
   */
  walletsEnabled?: boolean | undefined;
  /**
   * If this organization has the Member model enabled
   */
  memberModelEnabled?: boolean | undefined;
  /**
   * If this organization has checkout localization enabled
   */
  checkoutLocalizationEnabled?: boolean | undefined;
  /**
   * Ordered list of metric slugs shown on the dashboard overview.
   */
  overviewMetrics?: Array<string> | null | undefined;
  /**
   * If this organization has access to reset proration behavior.
   */
  resetProrationBehaviorEnabled?: boolean | undefined;
  /**
   * If this organization can create and finalize draft orders via the API (off-session charges against a saved payment method).
   */
  offSessionChargesEnabled?: boolean | undefined;
  /**
   * Enables the slack shared channel benefit
   */
  slackBenefitEnabled?: boolean | undefined;
  /**
   * If this organization has preview access to new features enabled
   */
  previewAccessEnabled?: boolean | undefined;
  /**
   * If this organization has the disputes dashboard enabled
   */
  disputesEnabled?: boolean | undefined;
  /**
   * If this organization has single sign-on configuration enabled
   */
  ssoEnabled?: boolean | undefined;
  /**
   * If this organization has the split product navigation (Billing / Compass / Customers) enabled in the dashboard
   */
  compassEnabled?: boolean | undefined;
  /**
   * If this organization can migrate its billing from another provider (e.g. Stripe) to Polar.
   */
  merchantMigrationEnabled?: boolean | undefined;
};

/** @internal */
export const OrganizationFeatureSettings$inboundSchema: z.ZodMiniType<
  OrganizationFeatureSettings,
  unknown
> = z.pipe(
  z.object({
    issue_funding_enabled: z._default(z.boolean(), false),
    seat_based_pricing_enabled: z._default(z.boolean(), false),
    wallets_enabled: z._default(z.boolean(), false),
    member_model_enabled: z._default(z.boolean(), false),
    checkout_localization_enabled: z._default(z.boolean(), false),
    overview_metrics: z.optional(z.nullable(z.array(z.string()))),
    reset_proration_behavior_enabled: z._default(z.boolean(), false),
    off_session_charges_enabled: z._default(z.boolean(), false),
    slack_benefit_enabled: z._default(z.boolean(), false),
    preview_access_enabled: z._default(z.boolean(), false),
    disputes_enabled: z._default(z.boolean(), false),
    sso_enabled: z._default(z.boolean(), false),
    compass_enabled: z._default(z.boolean(), false),
    merchant_migration_enabled: z._default(z.boolean(), false),
  }),
  z.transform((v) => {
    return remap$(v, {
      "issue_funding_enabled": "issueFundingEnabled",
      "seat_based_pricing_enabled": "seatBasedPricingEnabled",
      "wallets_enabled": "walletsEnabled",
      "member_model_enabled": "memberModelEnabled",
      "checkout_localization_enabled": "checkoutLocalizationEnabled",
      "overview_metrics": "overviewMetrics",
      "reset_proration_behavior_enabled": "resetProrationBehaviorEnabled",
      "off_session_charges_enabled": "offSessionChargesEnabled",
      "slack_benefit_enabled": "slackBenefitEnabled",
      "preview_access_enabled": "previewAccessEnabled",
      "disputes_enabled": "disputesEnabled",
      "sso_enabled": "ssoEnabled",
      "compass_enabled": "compassEnabled",
      "merchant_migration_enabled": "merchantMigrationEnabled",
    });
  }),
);
/** @internal */
export type OrganizationFeatureSettings$Outbound = {
  issue_funding_enabled: boolean;
  seat_based_pricing_enabled: boolean;
  wallets_enabled: boolean;
  member_model_enabled: boolean;
  checkout_localization_enabled: boolean;
  overview_metrics?: Array<string> | null | undefined;
  reset_proration_behavior_enabled: boolean;
  off_session_charges_enabled: boolean;
  slack_benefit_enabled: boolean;
  preview_access_enabled: boolean;
  disputes_enabled: boolean;
  sso_enabled: boolean;
  compass_enabled: boolean;
  merchant_migration_enabled: boolean;
};

/** @internal */
export const OrganizationFeatureSettings$outboundSchema: z.ZodMiniType<
  OrganizationFeatureSettings$Outbound,
  OrganizationFeatureSettings
> = z.pipe(
  z.object({
    issueFundingEnabled: z._default(z.boolean(), false),
    seatBasedPricingEnabled: z._default(z.boolean(), false),
    walletsEnabled: z._default(z.boolean(), false),
    memberModelEnabled: z._default(z.boolean(), false),
    checkoutLocalizationEnabled: z._default(z.boolean(), false),
    overviewMetrics: z.optional(z.nullable(z.array(z.string()))),
    resetProrationBehaviorEnabled: z._default(z.boolean(), false),
    offSessionChargesEnabled: z._default(z.boolean(), false),
    slackBenefitEnabled: z._default(z.boolean(), false),
    previewAccessEnabled: z._default(z.boolean(), false),
    disputesEnabled: z._default(z.boolean(), false),
    ssoEnabled: z._default(z.boolean(), false),
    compassEnabled: z._default(z.boolean(), false),
    merchantMigrationEnabled: z._default(z.boolean(), false),
  }),
  z.transform((v) => {
    return remap$(v, {
      issueFundingEnabled: "issue_funding_enabled",
      seatBasedPricingEnabled: "seat_based_pricing_enabled",
      walletsEnabled: "wallets_enabled",
      memberModelEnabled: "member_model_enabled",
      checkoutLocalizationEnabled: "checkout_localization_enabled",
      overviewMetrics: "overview_metrics",
      resetProrationBehaviorEnabled: "reset_proration_behavior_enabled",
      offSessionChargesEnabled: "off_session_charges_enabled",
      slackBenefitEnabled: "slack_benefit_enabled",
      previewAccessEnabled: "preview_access_enabled",
      disputesEnabled: "disputes_enabled",
      ssoEnabled: "sso_enabled",
      compassEnabled: "compass_enabled",
      merchantMigrationEnabled: "merchant_migration_enabled",
    });
  }),
);

export function organizationFeatureSettingsToJSON(
  organizationFeatureSettings: OrganizationFeatureSettings,
): string {
  return JSON.stringify(
    OrganizationFeatureSettings$outboundSchema.parse(
      organizationFeatureSettings,
    ),
  );
}
export function organizationFeatureSettingsFromJSON(
  jsonString: string,
): SafeParseResult<OrganizationFeatureSettings, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => OrganizationFeatureSettings$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'OrganizationFeatureSettings' from JSON`,
  );
}
