/*
 * 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 BenefitSlackSharedChannelProperties = {
  /**
   * Polar Slack integration linked to this benefit.
   */
  slackIntegrationId: string;
  /**
   * Template for the channel name. Supports placeholders: {customer_name}, {customer_email_local}, and {metadata.<key>} for any value stored in customer user metadata.
   */
  channelNameTemplate: string;
  /**
   * Create the channel as private (recommended).
   */
  private?: boolean | undefined;
  /**
   * Optional message posted to the channel right after creation.
   */
  welcomeMessage?: string | null | undefined;
  /**
   * Archive the channel when the benefit is revoked.
   */
  archiveOnRevoke?: boolean | undefined;
  /**
   * Slack user IDs from the merchant workspace to invite to every channel created for this benefit.
   */
  teamInvitees?: Array<string> | undefined;
};

/** @internal */
export const BenefitSlackSharedChannelProperties$inboundSchema: z.ZodMiniType<
  BenefitSlackSharedChannelProperties,
  unknown
> = z.pipe(
  z.object({
    slack_integration_id: z.string(),
    channel_name_template: z.string(),
    private: z._default(z.boolean(), true),
    welcome_message: z.optional(z.nullable(z.string())),
    archive_on_revoke: z._default(z.boolean(), true),
    team_invitees: z.optional(z.array(z.string())),
  }),
  z.transform((v) => {
    return remap$(v, {
      "slack_integration_id": "slackIntegrationId",
      "channel_name_template": "channelNameTemplate",
      "welcome_message": "welcomeMessage",
      "archive_on_revoke": "archiveOnRevoke",
      "team_invitees": "teamInvitees",
    });
  }),
);
/** @internal */
export type BenefitSlackSharedChannelProperties$Outbound = {
  slack_integration_id: string;
  channel_name_template: string;
  private: boolean;
  welcome_message?: string | null | undefined;
  archive_on_revoke: boolean;
  team_invitees?: Array<string> | undefined;
};

/** @internal */
export const BenefitSlackSharedChannelProperties$outboundSchema: z.ZodMiniType<
  BenefitSlackSharedChannelProperties$Outbound,
  BenefitSlackSharedChannelProperties
> = z.pipe(
  z.object({
    slackIntegrationId: z.string(),
    channelNameTemplate: z.string(),
    private: z._default(z.boolean(), true),
    welcomeMessage: z.optional(z.nullable(z.string())),
    archiveOnRevoke: z._default(z.boolean(), true),
    teamInvitees: z.optional(z.array(z.string())),
  }),
  z.transform((v) => {
    return remap$(v, {
      slackIntegrationId: "slack_integration_id",
      channelNameTemplate: "channel_name_template",
      welcomeMessage: "welcome_message",
      archiveOnRevoke: "archive_on_revoke",
      teamInvitees: "team_invitees",
    });
  }),
);

export function benefitSlackSharedChannelPropertiesToJSON(
  benefitSlackSharedChannelProperties: BenefitSlackSharedChannelProperties,
): string {
  return JSON.stringify(
    BenefitSlackSharedChannelProperties$outboundSchema.parse(
      benefitSlackSharedChannelProperties,
    ),
  );
}
export function benefitSlackSharedChannelPropertiesFromJSON(
  jsonString: string,
): SafeParseResult<BenefitSlackSharedChannelProperties, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) =>
      BenefitSlackSharedChannelProperties$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'BenefitSlackSharedChannelProperties' from JSON`,
  );
}
