/* * 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 ListOrgBudgetEventsRequest = { orgId?: string | undefined; }; export const Type = { ThresholdAlert: "threshold_alert", Blocked: "blocked", } as const; export type Type = ClosedEnum; export type ListOrgBudgetEventsData = { id: string; budgetId: string; type: Type; pct: number | null; periodKey: string; targetId: string; spendSnapshot: number; limitSnapshot: number; createdAt: string; }; /** * OK */ export type ListOrgBudgetEventsResponseBody = { object: "list"; data: Array; }; /** @internal */ export const ListOrgBudgetEventsRequest$inboundSchema: z.ZodType< ListOrgBudgetEventsRequest, z.ZodTypeDef, unknown > = z.object({ org_id: z.string().optional(), }).transform((v) => { return remap$(v, { "org_id": "orgId", }); }); /** @internal */ export type ListOrgBudgetEventsRequest$Outbound = { org_id?: string | undefined; }; /** @internal */ export const ListOrgBudgetEventsRequest$outboundSchema: z.ZodType< ListOrgBudgetEventsRequest$Outbound, z.ZodTypeDef, ListOrgBudgetEventsRequest > = z.object({ orgId: z.string().optional(), }).transform((v) => { return remap$(v, { orgId: "org_id", }); }); export function listOrgBudgetEventsRequestToJSON( listOrgBudgetEventsRequest: ListOrgBudgetEventsRequest, ): string { return JSON.stringify( ListOrgBudgetEventsRequest$outboundSchema.parse(listOrgBudgetEventsRequest), ); } export function listOrgBudgetEventsRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ListOrgBudgetEventsRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ListOrgBudgetEventsRequest' from JSON`, ); } /** @internal */ export const Type$inboundSchema: z.ZodNativeEnum = z.nativeEnum( Type, ); /** @internal */ export const Type$outboundSchema: z.ZodNativeEnum = Type$inboundSchema; /** @internal */ export const ListOrgBudgetEventsData$inboundSchema: z.ZodType< ListOrgBudgetEventsData, z.ZodTypeDef, unknown > = z.object({ id: z.string(), budget_id: z.string(), type: Type$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 ListOrgBudgetEventsData$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 ListOrgBudgetEventsData$outboundSchema: z.ZodType< ListOrgBudgetEventsData$Outbound, z.ZodTypeDef, ListOrgBudgetEventsData > = z.object({ id: z.string(), budgetId: z.string(), type: Type$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 listOrgBudgetEventsDataToJSON( listOrgBudgetEventsData: ListOrgBudgetEventsData, ): string { return JSON.stringify( ListOrgBudgetEventsData$outboundSchema.parse(listOrgBudgetEventsData), ); } export function listOrgBudgetEventsDataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ListOrgBudgetEventsData$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ListOrgBudgetEventsData' from JSON`, ); } /** @internal */ export const ListOrgBudgetEventsResponseBody$inboundSchema: z.ZodType< ListOrgBudgetEventsResponseBody, z.ZodTypeDef, unknown > = z.object({ object: z.literal("list"), data: z.array(z.lazy(() => ListOrgBudgetEventsData$inboundSchema)), }); /** @internal */ export type ListOrgBudgetEventsResponseBody$Outbound = { object: "list"; data: Array; }; /** @internal */ export const ListOrgBudgetEventsResponseBody$outboundSchema: z.ZodType< ListOrgBudgetEventsResponseBody$Outbound, z.ZodTypeDef, ListOrgBudgetEventsResponseBody > = z.object({ object: z.literal("list"), data: z.array(z.lazy(() => ListOrgBudgetEventsData$outboundSchema)), }); export function listOrgBudgetEventsResponseBodyToJSON( listOrgBudgetEventsResponseBody: ListOrgBudgetEventsResponseBody, ): string { return JSON.stringify( ListOrgBudgetEventsResponseBody$outboundSchema.parse( listOrgBudgetEventsResponseBody, ), ); } export function listOrgBudgetEventsResponseBodyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ListOrgBudgetEventsResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ListOrgBudgetEventsResponseBody' from JSON`, ); }