/*
 * 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 {
  S3FileCreateMultipart,
  S3FileCreateMultipart$Outbound,
  S3FileCreateMultipart$outboundSchema,
} from "./s3filecreatemultipart.js";

/**
 * Schema to create a file to be associated with the downloadables benefit.
 */
export type DownloadableFileCreate = {
  organizationId?: string | null | undefined;
  name: string;
  mimeType: string;
  size: number;
  checksumSha256Base64?: string | null | undefined;
  upload: S3FileCreateMultipart;
  service: "downloadable";
  version?: string | null | undefined;
};

/** @internal */
export type DownloadableFileCreate$Outbound = {
  organization_id?: string | null | undefined;
  name: string;
  mime_type: string;
  size: number;
  checksum_sha256_base64?: string | null | undefined;
  upload: S3FileCreateMultipart$Outbound;
  service: "downloadable";
  version?: string | null | undefined;
};

/** @internal */
export const DownloadableFileCreate$outboundSchema: z.ZodMiniType<
  DownloadableFileCreate$Outbound,
  DownloadableFileCreate
> = z.pipe(
  z.object({
    organizationId: z.optional(z.nullable(z.string())),
    name: z.string(),
    mimeType: z.string(),
    size: z.int(),
    checksumSha256Base64: z.optional(z.nullable(z.string())),
    upload: S3FileCreateMultipart$outboundSchema,
    service: z.literal("downloadable"),
    version: z.optional(z.nullable(z.string())),
  }),
  z.transform((v) => {
    return remap$(v, {
      organizationId: "organization_id",
      mimeType: "mime_type",
      checksumSha256Base64: "checksum_sha256_base64",
    });
  }),
);

export function downloadableFileCreateToJSON(
  downloadableFileCreate: DownloadableFileCreate,
): string {
  return JSON.stringify(
    DownloadableFileCreate$outboundSchema.parse(downloadableFileCreate),
  );
}
