/* * 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"; export type GetCostsRequest = { startTime: number; endTime: number; groupBy?: string | undefined; orgId?: string | undefined; }; export type GetCostsData = { service: string | null; taskType: string | null; model: string | null; apiKeyId: string | null; teamId: string | null; userId: string | null; externalUserId: string | null; orgId: string | null; cost: number; }; /** * OK */ export type GetCostsResponseBody = { currency: string; startTime: number; endTime: number; groupBy: Array; data: Array; totalCost: number; }; /** @internal */ export const GetCostsRequest$inboundSchema: z.ZodType< GetCostsRequest, z.ZodTypeDef, unknown > = z.object({ start_time: z.number().int(), end_time: z.number().int(), group_by: z.string().default(""), org_id: z.string().optional(), }).transform((v) => { return remap$(v, { "start_time": "startTime", "end_time": "endTime", "group_by": "groupBy", "org_id": "orgId", }); }); /** @internal */ export type GetCostsRequest$Outbound = { start_time: number; end_time: number; group_by: string; org_id?: string | undefined; }; /** @internal */ export const GetCostsRequest$outboundSchema: z.ZodType< GetCostsRequest$Outbound, z.ZodTypeDef, GetCostsRequest > = z.object({ startTime: z.number().int(), endTime: z.number().int(), groupBy: z.string().default(""), orgId: z.string().optional(), }).transform((v) => { return remap$(v, { startTime: "start_time", endTime: "end_time", groupBy: "group_by", orgId: "org_id", }); }); export function getCostsRequestToJSON( getCostsRequest: GetCostsRequest, ): string { return JSON.stringify(GetCostsRequest$outboundSchema.parse(getCostsRequest)); } export function getCostsRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetCostsRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetCostsRequest' from JSON`, ); } /** @internal */ export const GetCostsData$inboundSchema: z.ZodType< GetCostsData, z.ZodTypeDef, unknown > = z.object({ service: z.nullable(z.string()), task_type: z.nullable(z.string()), model: z.nullable(z.string()), api_key_id: z.nullable(z.string()), team_id: z.nullable(z.string()), user_id: z.nullable(z.string()), external_user_id: z.nullable(z.string()), org_id: z.nullable(z.string()), cost: z.number(), }).transform((v) => { return remap$(v, { "task_type": "taskType", "api_key_id": "apiKeyId", "team_id": "teamId", "user_id": "userId", "external_user_id": "externalUserId", "org_id": "orgId", }); }); /** @internal */ export type GetCostsData$Outbound = { service: string | null; task_type: string | null; model: string | null; api_key_id: string | null; team_id: string | null; user_id: string | null; external_user_id: string | null; org_id: string | null; cost: number; }; /** @internal */ export const GetCostsData$outboundSchema: z.ZodType< GetCostsData$Outbound, z.ZodTypeDef, GetCostsData > = z.object({ service: z.nullable(z.string()), taskType: z.nullable(z.string()), model: z.nullable(z.string()), apiKeyId: z.nullable(z.string()), teamId: z.nullable(z.string()), userId: z.nullable(z.string()), externalUserId: z.nullable(z.string()), orgId: z.nullable(z.string()), cost: z.number(), }).transform((v) => { return remap$(v, { taskType: "task_type", apiKeyId: "api_key_id", teamId: "team_id", userId: "user_id", externalUserId: "external_user_id", orgId: "org_id", }); }); export function getCostsDataToJSON(getCostsData: GetCostsData): string { return JSON.stringify(GetCostsData$outboundSchema.parse(getCostsData)); } export function getCostsDataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetCostsData$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetCostsData' from JSON`, ); } /** @internal */ export const GetCostsResponseBody$inboundSchema: z.ZodType< GetCostsResponseBody, z.ZodTypeDef, unknown > = z.object({ currency: z.string(), start_time: z.number(), end_time: z.number(), group_by: z.array(z.string()), data: z.array(z.lazy(() => GetCostsData$inboundSchema)), total_cost: z.number(), }).transform((v) => { return remap$(v, { "start_time": "startTime", "end_time": "endTime", "group_by": "groupBy", "total_cost": "totalCost", }); }); /** @internal */ export type GetCostsResponseBody$Outbound = { currency: string; start_time: number; end_time: number; group_by: Array; data: Array; total_cost: number; }; /** @internal */ export const GetCostsResponseBody$outboundSchema: z.ZodType< GetCostsResponseBody$Outbound, z.ZodTypeDef, GetCostsResponseBody > = z.object({ currency: z.string(), startTime: z.number(), endTime: z.number(), groupBy: z.array(z.string()), data: z.array(z.lazy(() => GetCostsData$outboundSchema)), totalCost: z.number(), }).transform((v) => { return remap$(v, { startTime: "start_time", endTime: "end_time", groupBy: "group_by", totalCost: "total_cost", }); }); export function getCostsResponseBodyToJSON( getCostsResponseBody: GetCostsResponseBody, ): string { return JSON.stringify( GetCostsResponseBody$outboundSchema.parse(getCostsResponseBody), ); } export function getCostsResponseBodyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetCostsResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetCostsResponseBody' from JSON`, ); }