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

/**
 * Feature flags exposed to the customer portal.
 */
export type CustomerOrganizationFeatureSettings = {
  /**
   * Whether the member model is enabled for this organization.
   */
  memberModelEnabled: boolean;
  /**
   * Whether localization is enabled for this organization.
   */
  checkoutLocalizationEnabled: boolean;
};

/** @internal */
export const CustomerOrganizationFeatureSettings$inboundSchema: z.ZodMiniType<
  CustomerOrganizationFeatureSettings,
  unknown
> = z.pipe(
  z.object({
    member_model_enabled: z._default(z.boolean(), false),
    checkout_localization_enabled: z._default(z.boolean(), false),
  }),
  z.transform((v) => {
    return remap$(v, {
      "member_model_enabled": "memberModelEnabled",
      "checkout_localization_enabled": "checkoutLocalizationEnabled",
    });
  }),
);

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