/* * 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 { CommitmentInfo, CommitmentInfo$inboundSchema, } from "./commitment-info.js"; import { SDKValidationError } from "./sdk-validation-error.js"; import { SourceUsageItem, SourceUsageItem$inboundSchema, } from "./source-usage-item.js"; import { Status, Status$inboundSchema } from "./status.js"; import { UsageBreakdownItem, UsageBreakdownItem$inboundSchema, } from "./usage-breakdown-item.js"; export type InvoiceLineItemResponse = { /** * adjusted_entitlement_quantity is the entitlement-covered portion deducted from raw usage. * * @remarks * Nil when no entitlement was applied. Raw usage = Quantity + AdjustedEntitlementQuantity. */ adjustedEntitlementQuantity?: string | undefined; amount?: string | undefined; commitmentInfo?: CommitmentInfo | undefined; createdAt?: Date | undefined; createdBy?: string | undefined; currency?: string | undefined; customerId?: string | undefined; displayName?: string | undefined; entityId?: string | undefined; entityType?: string | undefined; environmentId?: string | undefined; id?: string | undefined; invoiceId?: string | undefined; /** * invoice_level_discount is the discount amount in invoice currency applied to all line items on the invoice. */ invoiceLevelDiscount?: string | undefined; /** * line_item_discount is the discount amount in invoice currency applied directly to this line item. */ lineItemDiscount?: string | undefined; metadata?: { [k: string]: string } | undefined; meterDisplayName?: string | undefined; meterId?: string | undefined; /** * parent_line_item_id links this line item to the line item it replaced, if it was created by editing * * @remarks * an existing line item. Forms a linked-list chain across edits; nil for line items that were never edited. */ parentLineItemId?: string | undefined; periodEnd?: Date | undefined; periodStart?: Date | undefined; planDisplayName?: string | undefined; /** * prepaid_credits_applied is the amount in invoice currency reduced from this line item due to prepaid credits application. */ prepaidCreditsApplied?: string | undefined; priceId?: string | undefined; priceType?: string | undefined; priceUnit?: string | undefined; priceUnitAmount?: string | undefined; priceUnitId?: string | undefined; quantity?: string | undefined; status?: Status | undefined; subscriptionId?: string | undefined; /** * sub_line_item_id links this invoice line item to the subscription_line_item that generated it. */ subscriptionLineItemId?: string | undefined; tenantId?: string | undefined; updatedAt?: Date | undefined; updatedBy?: string | undefined; /** * usage_analytics contains usage analytics for this line item (legacy - grouped by source) */ usageAnalytics?: Array | undefined; /** * usage_breakdown contains flexible usage breakdown for this line item (supports any grouping) */ usageBreakdown?: Array | undefined; }; /** @internal */ export const InvoiceLineItemResponse$inboundSchema: z.ZodMiniType< InvoiceLineItemResponse, unknown > = z.pipe( z.object({ adjusted_entitlement_quantity: types.optional(types.string()), amount: types.optional(types.string()), commitment_info: types.optional(CommitmentInfo$inboundSchema), created_at: types.optional(types.date()), created_by: types.optional(types.string()), currency: types.optional(types.string()), customer_id: types.optional(types.string()), display_name: types.optional(types.string()), entity_id: types.optional(types.string()), entity_type: types.optional(types.string()), environment_id: types.optional(types.string()), id: types.optional(types.string()), invoice_id: types.optional(types.string()), invoice_level_discount: types.optional(types.string()), line_item_discount: types.optional(types.string()), metadata: types.optional(z.record(z.string(), types.string())), meter_display_name: types.optional(types.string()), meter_id: types.optional(types.string()), parent_line_item_id: types.optional(types.string()), period_end: types.optional(types.date()), period_start: types.optional(types.date()), plan_display_name: types.optional(types.string()), prepaid_credits_applied: types.optional(types.string()), price_id: types.optional(types.string()), price_type: types.optional(types.string()), price_unit: types.optional(types.string()), price_unit_amount: types.optional(types.string()), price_unit_id: types.optional(types.string()), quantity: types.optional(types.string()), status: types.optional(Status$inboundSchema), subscription_id: types.optional(types.string()), subscription_line_item_id: types.optional(types.string()), tenant_id: types.optional(types.string()), updated_at: types.optional(types.date()), updated_by: types.optional(types.string()), usage_analytics: types.optional(z.array(SourceUsageItem$inboundSchema)), usage_breakdown: types.optional(z.array(UsageBreakdownItem$inboundSchema)), }), z.transform((v) => { return remap$(v, { "adjusted_entitlement_quantity": "adjustedEntitlementQuantity", "commitment_info": "commitmentInfo", "created_at": "createdAt", "created_by": "createdBy", "customer_id": "customerId", "display_name": "displayName", "entity_id": "entityId", "entity_type": "entityType", "environment_id": "environmentId", "invoice_id": "invoiceId", "invoice_level_discount": "invoiceLevelDiscount", "line_item_discount": "lineItemDiscount", "meter_display_name": "meterDisplayName", "meter_id": "meterId", "parent_line_item_id": "parentLineItemId", "period_end": "periodEnd", "period_start": "periodStart", "plan_display_name": "planDisplayName", "prepaid_credits_applied": "prepaidCreditsApplied", "price_id": "priceId", "price_type": "priceType", "price_unit": "priceUnit", "price_unit_amount": "priceUnitAmount", "price_unit_id": "priceUnitId", "subscription_id": "subscriptionId", "subscription_line_item_id": "subscriptionLineItemId", "tenant_id": "tenantId", "updated_at": "updatedAt", "updated_by": "updatedBy", "usage_analytics": "usageAnalytics", "usage_breakdown": "usageBreakdown", }); }), ); export function invoiceLineItemResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => InvoiceLineItemResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'InvoiceLineItemResponse' from JSON`, ); }