/*
 * 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 { smartUnion } from "../../types/smartUnion.js";
import {
  BenefitSlackSharedChannelCreateProperties,
  BenefitSlackSharedChannelCreateProperties$Outbound,
  BenefitSlackSharedChannelCreateProperties$outboundSchema,
} from "./benefitslacksharedchannelcreateproperties.js";
import {
  BenefitVisibility,
  BenefitVisibility$outboundSchema,
} from "./benefitvisibility.js";

export type BenefitSlackSharedChannelCreateMetadata =
  | string
  | number
  | number
  | boolean;

export type BenefitSlackSharedChannelCreate = {
  /**
   * Key-value object allowing you to store additional information.
   *
   * @remarks
   *
   * The key must be a string with a maximum length of **40 characters**.
   * The value must be either:
   *
   * * A string with a maximum length of **500 characters**
   * * An integer
   * * A floating-point number
   * * A boolean
   *
   * You can store up to **50 key-value pairs**.
   */
  metadata?: { [k: string]: string | number | number | boolean } | undefined;
  type: "slack_shared_channel";
  /**
   * The description of the benefit. Will be displayed on products having this benefit.
   */
  description: string;
  /**
   * The ID of the organization owning the benefit. **Required unless you use an organization token.**
   */
  organizationId?: string | null | undefined;
  /**
   * The visibility of the benefit in the customer portal.
   */
  visibility?: BenefitVisibility | null | undefined;
  properties: BenefitSlackSharedChannelCreateProperties;
};

/** @internal */
export type BenefitSlackSharedChannelCreateMetadata$Outbound =
  | string
  | number
  | number
  | boolean;

/** @internal */
export const BenefitSlackSharedChannelCreateMetadata$outboundSchema:
  z.ZodMiniType<
    BenefitSlackSharedChannelCreateMetadata$Outbound,
    BenefitSlackSharedChannelCreateMetadata
  > = smartUnion([z.string(), z.int(), z.number(), z.boolean()]);

export function benefitSlackSharedChannelCreateMetadataToJSON(
  benefitSlackSharedChannelCreateMetadata:
    BenefitSlackSharedChannelCreateMetadata,
): string {
  return JSON.stringify(
    BenefitSlackSharedChannelCreateMetadata$outboundSchema.parse(
      benefitSlackSharedChannelCreateMetadata,
    ),
  );
}

/** @internal */
export type BenefitSlackSharedChannelCreate$Outbound = {
  metadata?: { [k: string]: string | number | number | boolean } | undefined;
  type: "slack_shared_channel";
  description: string;
  organization_id?: string | null | undefined;
  visibility?: string | null | undefined;
  properties: BenefitSlackSharedChannelCreateProperties$Outbound;
};

/** @internal */
export const BenefitSlackSharedChannelCreate$outboundSchema: z.ZodMiniType<
  BenefitSlackSharedChannelCreate$Outbound,
  BenefitSlackSharedChannelCreate
> = z.pipe(
  z.object({
    metadata: z.optional(
      z.record(
        z.string(),
        smartUnion([z.string(), z.int(), z.number(), z.boolean()]),
      ),
    ),
    type: z.literal("slack_shared_channel"),
    description: z.string(),
    organizationId: z.optional(z.nullable(z.string())),
    visibility: z.optional(z.nullable(BenefitVisibility$outboundSchema)),
    properties: BenefitSlackSharedChannelCreateProperties$outboundSchema,
  }),
  z.transform((v) => {
    return remap$(v, {
      organizationId: "organization_id",
    });
  }),
);

export function benefitSlackSharedChannelCreateToJSON(
  benefitSlackSharedChannelCreate: BenefitSlackSharedChannelCreate,
): string {
  return JSON.stringify(
    BenefitSlackSharedChannelCreate$outboundSchema.parse(
      benefitSlackSharedChannelCreate,
    ),
  );
}
