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

import * as z from "zod/v4";
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";
import {
  VoiceAppearance,
  VoiceAppearance$inboundSchema,
} from "./voiceappearance.js";

/**
 * Schema for voice response
 */
export type VoiceResponse = {
  name: string;
  slug?: string | null | undefined;
  languages?: Array<string> | undefined;
  gender?: string | null | undefined;
  age?: number | null | undefined;
  tags?: Array<string> | null | undefined;
  color?: string | null | undefined;
  description?: string | null | undefined;
  appearance?: VoiceAppearance | null | undefined;
  retentionNotice: number;
  id: string;
  createdAt: Date;
  userId: string | null;
};

/** @internal */
export const VoiceResponse$inboundSchema: z.ZodType<VoiceResponse, unknown> = z
  .object({
    name: z.string(),
    slug: z.nullable(z.string()).optional(),
    languages: z.array(z.string()).optional(),
    gender: z.nullable(z.string()).optional(),
    age: z.nullable(z.int()).optional(),
    tags: z.nullable(z.array(z.string())).optional(),
    color: z.nullable(z.string()).optional(),
    description: z.nullable(z.string()).optional(),
    appearance: z.nullable(VoiceAppearance$inboundSchema).optional(),
    retention_notice: z.int().default(30),
    id: z.string(),
    created_at: z.iso.datetime({ offset: true }).transform(v => new Date(v)),
    user_id: z.nullable(z.string()),
  }).transform((v) => {
    return remap$(v, {
      "retention_notice": "retentionNotice",
      "created_at": "createdAt",
      "user_id": "userId",
    });
  });

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