/*
 * 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";
import { FileDownload, FileDownload$inboundSchema } from "./filedownload.js";

export type DownloadableRead = {
  id: string;
  benefitId: string;
  file: FileDownload;
};

/** @internal */
export const DownloadableRead$inboundSchema: z.ZodMiniType<
  DownloadableRead,
  unknown
> = z.pipe(
  z.object({
    id: z.string(),
    benefit_id: z.string(),
    file: FileDownload$inboundSchema,
  }),
  z.transform((v) => {
    return remap$(v, {
      "benefit_id": "benefitId",
    });
  }),
);

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