/* * 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 { BillingPeriod, BillingPeriod$inboundSchema, BillingPeriod$outboundSchema, } from "./billing-period.js"; import { CommitmentType, CommitmentType$inboundSchema, CommitmentType$outboundSchema, } from "./commitment-type.js"; import { SDKValidationError } from "./sdk-validation-error.js"; export type CommitmentInfo = { amount?: string | undefined; computedCommitmentUtilizedAmount?: string | undefined; computedOverageAmount?: string | undefined; /** * total_cost = computed_commitment_utilized_amount + computed_overage_amount + computed_true_up_amount */ computedTrueUpAmount?: string | undefined; duration?: BillingPeriod | undefined; isWindowed?: boolean | undefined; overageFactor?: string | undefined; /** * Only used for quantity-based commitments */ quantity?: string | undefined; trueUpEnabled?: boolean | undefined; type?: CommitmentType | undefined; }; /** @internal */ export const CommitmentInfo$inboundSchema: z.ZodMiniType< CommitmentInfo, unknown > = z.pipe( z.object({ amount: types.optional(types.string()), computed_commitment_utilized_amount: types.optional(types.string()), computed_overage_amount: types.optional(types.string()), computed_true_up_amount: types.optional(types.string()), duration: types.optional(BillingPeriod$inboundSchema), is_windowed: types.optional(types.boolean()), overage_factor: types.optional(types.string()), quantity: types.optional(types.string()), true_up_enabled: types.optional(types.boolean()), type: types.optional(CommitmentType$inboundSchema), }), z.transform((v) => { return remap$(v, { "computed_commitment_utilized_amount": "computedCommitmentUtilizedAmount", "computed_overage_amount": "computedOverageAmount", "computed_true_up_amount": "computedTrueUpAmount", "is_windowed": "isWindowed", "overage_factor": "overageFactor", "true_up_enabled": "trueUpEnabled", }); }), ); /** @internal */ export type CommitmentInfo$Outbound = { amount?: string | undefined; computed_commitment_utilized_amount?: string | undefined; computed_overage_amount?: string | undefined; computed_true_up_amount?: string | undefined; duration?: string | undefined; is_windowed?: boolean | undefined; overage_factor?: string | undefined; quantity?: string | undefined; true_up_enabled?: boolean | undefined; type?: string | undefined; }; /** @internal */ export const CommitmentInfo$outboundSchema: z.ZodMiniType< CommitmentInfo$Outbound, CommitmentInfo > = z.pipe( z.object({ amount: z.optional(z.string()), computedCommitmentUtilizedAmount: z.optional(z.string()), computedOverageAmount: z.optional(z.string()), computedTrueUpAmount: z.optional(z.string()), duration: z.optional(BillingPeriod$outboundSchema), isWindowed: z.optional(z.boolean()), overageFactor: z.optional(z.string()), quantity: z.optional(z.string()), trueUpEnabled: z.optional(z.boolean()), type: z.optional(CommitmentType$outboundSchema), }), z.transform((v) => { return remap$(v, { computedCommitmentUtilizedAmount: "computed_commitment_utilized_amount", computedOverageAmount: "computed_overage_amount", computedTrueUpAmount: "computed_true_up_amount", isWindowed: "is_windowed", overageFactor: "overage_factor", trueUpEnabled: "true_up_enabled", }); }), ); export function commitmentInfoToJSON(commitmentInfo: CommitmentInfo): string { return JSON.stringify(CommitmentInfo$outboundSchema.parse(commitmentInfo)); } export function commitmentInfoFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CommitmentInfo$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CommitmentInfo' from JSON`, ); }