/*
 * 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 BenefitGrantDiscordProperties = {
  accountId?: string | null | undefined;
  guildId?: string | undefined;
  roleId?: string | undefined;
  grantedAccountId?: string | undefined;
};

/** @internal */
export const BenefitGrantDiscordProperties$inboundSchema: z.ZodMiniType<
  BenefitGrantDiscordProperties,
  unknown
> = z.pipe(
  z.object({
    account_id: z.optional(z.nullable(z.string())),
    guild_id: z.optional(z.string()),
    role_id: z.optional(z.string()),
    granted_account_id: z.optional(z.string()),
  }),
  z.transform((v) => {
    return remap$(v, {
      "account_id": "accountId",
      "guild_id": "guildId",
      "role_id": "roleId",
      "granted_account_id": "grantedAccountId",
    });
  }),
);
/** @internal */
export type BenefitGrantDiscordProperties$Outbound = {
  account_id?: string | null | undefined;
  guild_id?: string | undefined;
  role_id?: string | undefined;
  granted_account_id?: string | undefined;
};

/** @internal */
export const BenefitGrantDiscordProperties$outboundSchema: z.ZodMiniType<
  BenefitGrantDiscordProperties$Outbound,
  BenefitGrantDiscordProperties
> = z.pipe(
  z.object({
    accountId: z.optional(z.nullable(z.string())),
    guildId: z.optional(z.string()),
    roleId: z.optional(z.string()),
    grantedAccountId: z.optional(z.string()),
  }),
  z.transform((v) => {
    return remap$(v, {
      accountId: "account_id",
      guildId: "guild_id",
      roleId: "role_id",
      grantedAccountId: "granted_account_id",
    });
  }),
);

export function benefitGrantDiscordPropertiesToJSON(
  benefitGrantDiscordProperties: BenefitGrantDiscordProperties,
): string {
  return JSON.stringify(
    BenefitGrantDiscordProperties$outboundSchema.parse(
      benefitGrantDiscordProperties,
    ),
  );
}
export function benefitGrantDiscordPropertiesFromJSON(
  jsonString: string,
): SafeParseResult<BenefitGrantDiscordProperties, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => BenefitGrantDiscordProperties$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'BenefitGrantDiscordProperties' from JSON`,
  );
}
