/*
 * 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";

/**
 * The summary of the envelope in the workspace
 */
export type WorkspaceEnvelopeSummary = {
  /**
   * The ID of the envelope
   */
  envelopeId: string | null;
  /**
   * The status of the envelope in the workspace
   */
  status: string | null;
  /**
   * The envelope name
   */
  name?: string | null | undefined;
  /**
   * The envelope subject
   */
  subject?: string | null | undefined;
  /**
   * The date the envelope was created
   */
  createdDate?: Date | null | undefined;
  /**
   * The date the envelope was last updated
   */
  lastUpdatedDate?: Date | null | undefined;
};

/** @internal */
export const WorkspaceEnvelopeSummary$inboundSchema: z.ZodType<
  WorkspaceEnvelopeSummary,
  z.ZodTypeDef,
  unknown
> = z.object({
  envelope_id: types.nullable(types.string()),
  status: types.nullable(types.string()),
  name: z.nullable(types.string()).optional(),
  subject: z.nullable(types.string()).optional(),
  created_date: z.nullable(types.date()).optional(),
  last_updated_date: z.nullable(types.date()).optional(),
}).transform((v) => {
  return remap$(v, {
    "envelope_id": "envelopeId",
    "created_date": "createdDate",
    "last_updated_date": "lastUpdatedDate",
  });
});

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