/* * 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 * as types from "../../types/primitives.js"; import { CostAnalyticItem, CostAnalyticItem$inboundSchema, } from "./cost-analytic-item.js"; import { SDKValidationError } from "./sdk-validation-error.js"; export type GetDetailedCostAnalyticsResponse = { /** * Cost analytics array (flattened from nested structure) */ costAnalytics?: Array | undefined; currency?: string | undefined; endTime?: Date | undefined; /** * Revenue - Cost */ margin?: string | undefined; /** * (Margin / Revenue) * 100 */ marginPercent?: string | undefined; /** * (Revenue - Cost) / Cost */ roi?: string | undefined; /** * ROI * 100 */ roiPercent?: string | undefined; startTime?: Date | undefined; totalCost?: string | undefined; /** * Derived metrics */ totalRevenue?: string | undefined; }; /** @internal */ export const GetDetailedCostAnalyticsResponse$inboundSchema: z.ZodMiniType< GetDetailedCostAnalyticsResponse, unknown > = z.pipe( z.object({ cost_analytics: types.optional(z.array(CostAnalyticItem$inboundSchema)), currency: types.optional(types.string()), end_time: types.optional(types.date()), margin: types.optional(types.string()), margin_percent: types.optional(types.string()), roi: types.optional(types.string()), roi_percent: types.optional(types.string()), start_time: types.optional(types.date()), total_cost: types.optional(types.string()), total_revenue: types.optional(types.string()), }), z.transform((v) => { return remap$(v, { "cost_analytics": "costAnalytics", "end_time": "endTime", "margin_percent": "marginPercent", "roi_percent": "roiPercent", "start_time": "startTime", "total_cost": "totalCost", "total_revenue": "totalRevenue", }); }), ); export function getDetailedCostAnalyticsResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetDetailedCostAnalyticsResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetDetailedCostAnalyticsResponse' from JSON`, ); }