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

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

export type GetWorkspaceDocumentResponse = {
  /**
   * The ID of the workspace
   */
  workspaceId?: string | null | undefined;
  /**
   * The ID of the document
   */
  documentId: string;
  /**
   * The name of the document
   */
  name: string;
  /**
   * The ID of the owner of the document
   */
  ownerId?: string | null | undefined;
  /**
   * The size of the document in bytes
   */
  size?: number | null | undefined;
  /**
   * The date the document was created
   */
  createdDate?: Date | null | undefined;
  /**
   * The document content type
   */
  contentType?: string | null | undefined;
};

/** @internal */
export const GetWorkspaceDocumentResponse$inboundSchema: z.ZodType<
  GetWorkspaceDocumentResponse,
  z.ZodTypeDef,
  unknown
> = z.object({
  workspace_id: z.nullable(types.string()).optional(),
  document_id: types.string(),
  name: types.string(),
  owner_id: z.nullable(types.string()).optional(),
  size: z.nullable(types.number()).optional(),
  created_date: z.nullable(types.date()).optional(),
  content_type: z.nullable(types.string()).optional(),
}).transform((v) => {
  return remap$(v, {
    "workspace_id": "workspaceId",
    "document_id": "documentId",
    "owner_id": "ownerId",
    "created_date": "createdDate",
    "content_type": "contentType",
  });
});

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