/* * 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 { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ListUserBudgetEventsRequest = { id: string; orgId?: string | undefined; }; export const ListUserBudgetEventsType = { ThresholdAlert: "threshold_alert", Blocked: "blocked", } as const; export type ListUserBudgetEventsType = ClosedEnum< typeof ListUserBudgetEventsType >; export type ListUserBudgetEventsData = { id: string; budgetId: string; type: ListUserBudgetEventsType; pct: number | null; periodKey: string; targetId: string; spendSnapshot: number; limitSnapshot: number; createdAt: string; }; /** * OK */ export type ListUserBudgetEventsResponseBody = { object: "list"; data: Array; }; /** @internal */ export const ListUserBudgetEventsRequest$inboundSchema: z.ZodType< ListUserBudgetEventsRequest, z.ZodTypeDef, unknown > = z.object({ id: z.string(), org_id: z.string().optional(), }).transform((v) => { return remap$(v, { "org_id": "orgId", }); }); /** @internal */ export type ListUserBudgetEventsRequest$Outbound = { id: string; org_id?: string | undefined; }; /** @internal */ export const ListUserBudgetEventsRequest$outboundSchema: z.ZodType< ListUserBudgetEventsRequest$Outbound, z.ZodTypeDef, ListUserBudgetEventsRequest > = z.object({ id: z.string(), orgId: z.string().optional(), }).transform((v) => { return remap$(v, { orgId: "org_id", }); }); export function listUserBudgetEventsRequestToJSON( listUserBudgetEventsRequest: ListUserBudgetEventsRequest, ): string { return JSON.stringify( ListUserBudgetEventsRequest$outboundSchema.parse( listUserBudgetEventsRequest, ), ); } export function listUserBudgetEventsRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ListUserBudgetEventsRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ListUserBudgetEventsRequest' from JSON`, ); } /** @internal */ export const ListUserBudgetEventsType$inboundSchema: z.ZodNativeEnum< typeof ListUserBudgetEventsType > = z.nativeEnum(ListUserBudgetEventsType); /** @internal */ export const ListUserBudgetEventsType$outboundSchema: z.ZodNativeEnum< typeof ListUserBudgetEventsType > = ListUserBudgetEventsType$inboundSchema; /** @internal */ export const ListUserBudgetEventsData$inboundSchema: z.ZodType< ListUserBudgetEventsData, z.ZodTypeDef, unknown > = z.object({ id: z.string(), budget_id: z.string(), type: ListUserBudgetEventsType$inboundSchema, pct: z.nullable(z.number()), period_key: z.string(), target_id: z.string(), spend_snapshot: z.number(), limit_snapshot: z.number(), created_at: z.string(), }).transform((v) => { return remap$(v, { "budget_id": "budgetId", "period_key": "periodKey", "target_id": "targetId", "spend_snapshot": "spendSnapshot", "limit_snapshot": "limitSnapshot", "created_at": "createdAt", }); }); /** @internal */ export type ListUserBudgetEventsData$Outbound = { id: string; budget_id: string; type: string; pct: number | null; period_key: string; target_id: string; spend_snapshot: number; limit_snapshot: number; created_at: string; }; /** @internal */ export const ListUserBudgetEventsData$outboundSchema: z.ZodType< ListUserBudgetEventsData$Outbound, z.ZodTypeDef, ListUserBudgetEventsData > = z.object({ id: z.string(), budgetId: z.string(), type: ListUserBudgetEventsType$outboundSchema, pct: z.nullable(z.number()), periodKey: z.string(), targetId: z.string(), spendSnapshot: z.number(), limitSnapshot: z.number(), createdAt: z.string(), }).transform((v) => { return remap$(v, { budgetId: "budget_id", periodKey: "period_key", targetId: "target_id", spendSnapshot: "spend_snapshot", limitSnapshot: "limit_snapshot", createdAt: "created_at", }); }); export function listUserBudgetEventsDataToJSON( listUserBudgetEventsData: ListUserBudgetEventsData, ): string { return JSON.stringify( ListUserBudgetEventsData$outboundSchema.parse(listUserBudgetEventsData), ); } export function listUserBudgetEventsDataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ListUserBudgetEventsData$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ListUserBudgetEventsData' from JSON`, ); } /** @internal */ export const ListUserBudgetEventsResponseBody$inboundSchema: z.ZodType< ListUserBudgetEventsResponseBody, z.ZodTypeDef, unknown > = z.object({ object: z.literal("list"), data: z.array(z.lazy(() => ListUserBudgetEventsData$inboundSchema)), }); /** @internal */ export type ListUserBudgetEventsResponseBody$Outbound = { object: "list"; data: Array; }; /** @internal */ export const ListUserBudgetEventsResponseBody$outboundSchema: z.ZodType< ListUserBudgetEventsResponseBody$Outbound, z.ZodTypeDef, ListUserBudgetEventsResponseBody > = z.object({ object: z.literal("list"), data: z.array(z.lazy(() => ListUserBudgetEventsData$outboundSchema)), }); export function listUserBudgetEventsResponseBodyToJSON( listUserBudgetEventsResponseBody: ListUserBudgetEventsResponseBody, ): string { return JSON.stringify( ListUserBudgetEventsResponseBody$outboundSchema.parse( listUserBudgetEventsResponseBody, ), ); } export function listUserBudgetEventsResponseBodyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ListUserBudgetEventsResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ListUserBudgetEventsResponseBody' from JSON`, ); }