/* * 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 { CommitmentInfo, CommitmentInfo$Outbound, CommitmentInfo$outboundSchema, } from "./commitment-info.js"; export type CreateInvoiceLineItemRequest = { /** * adjusted_entitlement_quantity is the entitlement-covered units deducted from raw usage. */ adjustedEntitlementQuantity?: string | undefined; /** * amount is the monetary amount for this line item */ amount: string; commitmentInfo?: CommitmentInfo | undefined; /** * display_name is the optional human-readable name for this line item */ displayName?: string | undefined; /** * entity_id is the optional unique identifier of the entity associated with this line item */ entityId?: string | undefined; /** * entity_type is the optional type of the entity associated with this line item */ entityType?: 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; /** * meter_display_name is the optional human-readable name of the meter */ meterDisplayName?: string | undefined; /** * meter_id is the optional unique identifier of the meter used for usage tracking */ meterId?: string | undefined; /** * period_end is the optional end date of the period this line item covers */ periodEnd?: Date | undefined; /** * period_start is the optional start date of the period this line item covers */ periodStart?: Date | undefined; /** * plan_display_name is the optional human-readable name of the plan */ planDisplayName?: string | undefined; /** * TODO: !REMOVE after migration * * @remarks * plan_id is the optional unique identifier of the plan associated with this line item */ planId?: string | undefined; /** * prepaid_credits_applied is the amount in invoice currency reduced from this line item due to prepaid credits application. */ prepaidCreditsApplied?: string | undefined; /** * price_id is the optional unique identifier of the price associated with this line item */ priceId?: string | undefined; /** * price_type indicates the type of pricing (fixed, usage, tiered, etc.) */ priceType?: string | undefined; /** * price_unit is the optional 3-digit ISO code of the price unit associated with this line item */ priceUnit?: string | undefined; /** * price_unit_amount is the optional amount converted to the price unit currency */ priceUnitAmount?: string | undefined; /** * quantity is the quantity of units for this line item */ quantity: string; /** * subscription_id overrides the invoice's subscription_id for this specific line item. * * @remarks * Used for grouped invoicing where child line items belong to child subscriptions. */ subscriptionId?: string | undefined; /** * sub_line_item_id links this line item to the subscription_line_item that generated it. */ subscriptionLineItemId?: string | undefined; }; /** @internal */ export type CreateInvoiceLineItemRequest$Outbound = { adjusted_entitlement_quantity?: string | undefined; amount: string; commitment_info?: CommitmentInfo$Outbound | undefined; display_name?: string | undefined; entity_id?: string | undefined; entity_type?: string | undefined; invoice_level_discount?: string | undefined; line_item_discount?: string | undefined; metadata?: { [k: string]: string } | undefined; meter_display_name?: string | undefined; meter_id?: string | undefined; period_end?: string | undefined; period_start?: string | undefined; plan_display_name?: string | undefined; plan_id?: string | undefined; prepaid_credits_applied?: string | undefined; price_id?: string | undefined; price_type?: string | undefined; price_unit?: string | undefined; price_unit_amount?: string | undefined; quantity: string; subscription_id?: string | undefined; subscription_line_item_id?: string | undefined; }; /** @internal */ export const CreateInvoiceLineItemRequest$outboundSchema: z.ZodMiniType< CreateInvoiceLineItemRequest$Outbound, CreateInvoiceLineItemRequest > = z.pipe( z.object({ adjustedEntitlementQuantity: z.optional(z.string()), amount: z.string(), commitmentInfo: z.optional(CommitmentInfo$outboundSchema), displayName: z.optional(z.string()), entityId: z.optional(z.string()), entityType: z.optional(z.string()), invoiceLevelDiscount: z.optional(z.string()), lineItemDiscount: z.optional(z.string()), metadata: z.optional(z.record(z.string(), z.string())), meterDisplayName: z.optional(z.string()), meterId: z.optional(z.string()), periodEnd: z.optional(z.pipe(z.date(), z.transform(v => v.toISOString()))), periodStart: z.optional( z.pipe(z.date(), z.transform(v => v.toISOString())), ), planDisplayName: z.optional(z.string()), planId: z.optional(z.string()), prepaidCreditsApplied: z.optional(z.string()), priceId: z.optional(z.string()), priceType: z.optional(z.string()), priceUnit: z.optional(z.string()), priceUnitAmount: z.optional(z.string()), quantity: z.string(), subscriptionId: z.optional(z.string()), subscriptionLineItemId: z.optional(z.string()), }), z.transform((v) => { return remap$(v, { adjustedEntitlementQuantity: "adjusted_entitlement_quantity", commitmentInfo: "commitment_info", displayName: "display_name", entityId: "entity_id", entityType: "entity_type", invoiceLevelDiscount: "invoice_level_discount", lineItemDiscount: "line_item_discount", meterDisplayName: "meter_display_name", meterId: "meter_id", periodEnd: "period_end", periodStart: "period_start", planDisplayName: "plan_display_name", planId: "plan_id", prepaidCreditsApplied: "prepaid_credits_applied", priceId: "price_id", priceType: "price_type", priceUnit: "price_unit", priceUnitAmount: "price_unit_amount", subscriptionId: "subscription_id", subscriptionLineItemId: "subscription_line_item_id", }); }), ); export function createInvoiceLineItemRequestToJSON( createInvoiceLineItemRequest: CreateInvoiceLineItemRequest, ): string { return JSON.stringify( CreateInvoiceLineItemRequest$outboundSchema.parse( createInvoiceLineItemRequest, ), ); }