/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */

import * as z from "zod/v3";
import { safeParse } from "../lib/schemas.js";
import { Result as SafeParseResult } from "../types/fp.js";
import * as types from "../types/primitives.js";
import { SDKValidationError } from "./sdkvalidationerror.js";

/**
 * An object describing the reason why the User account is being deleted.
 */
export type RequestDeleteReasons = {
  /**
   * Idenitifier slug of the reason why the User account is being deleted.
   */
  slug: string;
  /**
   * Description of the reason why the User account is being deleted.
   */
  description: string;
};

export type RequestDeleteRequestBody = {
  /**
   * Optional array of objects that describe the reason why the User account is being deleted.
   */
  reasons?: Array<RequestDeleteReasons> | undefined;
};

/**
 * Response indicating that the User deletion process has been initiated, and a confirmation email has been sent.
 */
export type RequestDeleteResponseBody = {
  /**
   * Unique identifier of the User who has initiated deletion.
   */
  id: string;
  /**
   * Email address of the User who has initiated deletion.
   */
  email: string;
  /**
   * User deletion progress status.
   */
  message: string;
};

/** @internal */
export type RequestDeleteReasons$Outbound = {
  slug: string;
  description: string;
};

/** @internal */
export const RequestDeleteReasons$outboundSchema: z.ZodType<
  RequestDeleteReasons$Outbound,
  z.ZodTypeDef,
  RequestDeleteReasons
> = z.object({
  slug: z.string(),
  description: z.string(),
});

export function requestDeleteReasonsToJSON(
  requestDeleteReasons: RequestDeleteReasons,
): string {
  return JSON.stringify(
    RequestDeleteReasons$outboundSchema.parse(requestDeleteReasons),
  );
}

/** @internal */
export type RequestDeleteRequestBody$Outbound = {
  reasons?: Array<RequestDeleteReasons$Outbound> | undefined;
};

/** @internal */
export const RequestDeleteRequestBody$outboundSchema: z.ZodType<
  RequestDeleteRequestBody$Outbound,
  z.ZodTypeDef,
  RequestDeleteRequestBody
> = z.object({
  reasons: z.array(z.lazy(() => RequestDeleteReasons$outboundSchema))
    .optional(),
});

export function requestDeleteRequestBodyToJSON(
  requestDeleteRequestBody: RequestDeleteRequestBody,
): string {
  return JSON.stringify(
    RequestDeleteRequestBody$outboundSchema.parse(requestDeleteRequestBody),
  );
}

/** @internal */
export const RequestDeleteResponseBody$inboundSchema: z.ZodType<
  RequestDeleteResponseBody,
  z.ZodTypeDef,
  unknown
> = z.object({
  id: types.string(),
  email: types.string(),
  message: types.string(),
});

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