/* * 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 { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ReportCreatorType, ReportCreatorType$inboundSchema, } from "./reportcreatortype.js"; import { ReportExecutionSummary, ReportExecutionSummary$inboundSchema, } from "./reportexecutionsummary.js"; import { ReportSchedule, ReportSchedule$inboundSchema, } from "./reportschedule.js"; import { ReportSpec, ReportSpec$inboundSchema } from "./reportspec.js"; export type Report = { /** * Always `report`. */ type: "report"; /** * The unique ID for the report. */ id: string; /** * The merchant account ID this report belongs to. */ merchantAccountId: string; /** * The name of the report. */ name: string; /** * The ID of the user who created the report. */ creatorId?: string | null | undefined; /** * The display name of the report creator. */ creatorDisplayName?: string | null | undefined; /** * The type of the report creator. */ creatorType?: ReportCreatorType | null | undefined; /** * The date this report was created at. */ createdAt: Date; /** * The date this report was last updated. */ updatedAt: Date; /** * The next scheduled execution time for the report. */ nextExecutionAt?: Date | null | undefined; /** * A description of the report. */ description?: string | null | undefined; schedule: ReportSchedule; /** * Whether the report schedule is enabled. */ scheduleEnabled: boolean; /** * The timezone for the report schedule. */ scheduleTimezone: string; spec: ReportSpec; /** * The latest execution summary for the report. */ latestExecution?: ReportExecutionSummary | null | undefined; }; /** @internal */ export const Report$inboundSchema: z.ZodType = z .object({ type: z.literal("report").default("report"), id: z.string(), merchant_account_id: z.string(), name: z.string(), creator_id: z.nullable(z.string()).optional(), creator_display_name: z.nullable(z.string()).optional(), creator_type: z.nullable(ReportCreatorType$inboundSchema).optional(), created_at: z.string().datetime({ offset: true }).transform(v => new Date(v) ), updated_at: z.string().datetime({ offset: true }).transform(v => new Date(v) ), next_execution_at: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), description: z.nullable(z.string()).optional(), schedule: ReportSchedule$inboundSchema, schedule_enabled: z.boolean(), schedule_timezone: z.string(), spec: ReportSpec$inboundSchema, latest_execution: z.nullable(ReportExecutionSummary$inboundSchema) .optional(), }).transform((v) => { return remap$(v, { "merchant_account_id": "merchantAccountId", "creator_id": "creatorId", "creator_display_name": "creatorDisplayName", "creator_type": "creatorType", "created_at": "createdAt", "updated_at": "updatedAt", "next_execution_at": "nextExecutionAt", "schedule_enabled": "scheduleEnabled", "schedule_timezone": "scheduleTimezone", "latest_execution": "latestExecution", }); }); export function reportFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Report$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Report' from JSON`, ); }