Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions api/spec/packages/aip-client-javascript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ TypeSpec definitions and ships fully-typed request and response models.
- [EntitlementAccess](#entitlementaccess)
- [Notifications](#notifications)
- [Internal Operations](#internal-operations)
- [Internal Customers](#internal-customers)
- [Internal Subscriptions](#internal-subscriptions)
- [Internal Apps](#internal-apps)
- [Internal Notifications](#internal-notifications)
Expand Down Expand Up @@ -498,6 +499,12 @@ Operations marked internal in the API definition are exposed under
intended for customer use: they may require additional permissions, and
they can change or be removed without notice or semver consideration.

### Internal Customers

| Method | HTTP | Description |
| ------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `client.internal.customers.charges.invoice` | `POST /openmeter/customers/{customerId}/charges/invoice` | Invoice a customer's charges outside the normal billing cycle. Collection alignment is bypassed. The customer's progressive billing setting applies unless explicitly overridden. All eligible pending lines are considered. Returns the created standard invoices, one per collected currency. Lines blocked by their owning engine remain pending. If all eligible lines are blocked or no lines are eligible, returns a validation error. |

### Internal Subscriptions

| Method | HTTP | Description |
Expand Down
52 changes: 52 additions & 0 deletions api/spec/packages/aip-client-javascript/src/funcs/customers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ import type {
ListCustomerChargesResponse,
CreateCustomerChargesRequest,
CreateCustomerChargesResponse,
InvoiceCustomerChargesRequest,
InvoiceCustomerChargesResponse,
} from '../models/operations/customers.js'

/**
Expand Down Expand Up @@ -1607,3 +1609,53 @@ export function createCustomerCharges(
})
})
}

/**
* Invoice a customer's charges
*
* Invoice a customer's charges outside the normal billing cycle. Collection
* alignment is bypassed. The customer's progressive billing setting applies unless
* explicitly overridden. All eligible pending lines are considered.
*
* Returns the created standard invoices, one per collected currency. Lines blocked
* by their owning engine remain pending. If all eligible lines are blocked or no
* lines are eligible, returns a validation error.
*
* POST /openmeter/customers/{customerId}/charges/invoice
*/
export function invoiceCustomerCharges(
client: Client,
req: InvoiceCustomerChargesRequest,
options?: RequestOptions,
): Promise<Result<InvoiceCustomerChargesResponse>> {
return request(() => {
const pathParamsInput = {
customerId: req.customerId,
}
const pathParams = client._options.validate
? toPathWire(pathParamsInput, schemas.invoiceCustomerChargesPathParams)
: pathParamsInput
if (client._options.validate) {
assertValid(schemas.invoiceCustomerChargesPathParamsWire, pathParams)
}
const path = `openmeter/customers/${(() => {
if (pathParams.customerId === undefined) {
throw new Error('missing path parameter: customerId')
}
return encodeURIComponent(String(pathParams.customerId))
})()}/charges/invoice`
const body = toWire(req.body, schemas.invoiceCustomerChargesBody)
if (client._options.validate && body !== undefined) {
assertValid(schemas.invoiceCustomerChargesBodyWire, body)
}
return http(client)
.post(path, { ...options, json: body })
.json()
.then((data) => {
if (client._options.validate) {
assertValid(schemas.invoiceCustomerChargesResponseWire, data)
}
return fromWire(data, schemas.invoiceCustomerChargesResponse)
})
})
}
17 changes: 10 additions & 7 deletions api/spec/packages/aip-client-javascript/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export type {
WorkflowPaymentChargeAutomaticallySettings,
WorkflowPaymentSendInvoiceSettings,
ChargeFlatFeeDiscounts,
InvoiceLineExternalReferences,
SubscriptionEditRemoveItem,
SubscriptionEditUnscheduleEdit,
UpdateLabels,
Expand All @@ -99,7 +100,6 @@ export type {
InstallAppSandbox,
InstallAppExternalInvoicing,
WorkflowCollectionAlignmentSubscription,
InvoiceLineExternalReferences,
UpdateBillingInvoiceWorkflowInvoicingSettings,
UpdateBillingWorkflowPaymentChargeAutomaticallySettings,
UpdateBillingWorkflowPaymentSendInvoiceSettings,
Expand Down Expand Up @@ -166,8 +166,8 @@ export type {
SubscriptionReference,
AppReference,
ChargeRealizationInvoiceReference,
AddonReference,
ChargeReference,
AddonReference,
UpdateResourceReference,
NotificationChannelReference,
NotificationEventFeatureReference,
Expand All @@ -179,6 +179,7 @@ export type {
AppStripeCreateCustomerPortalSessionResult,
ClosedPeriod,
ChargeResolvedCostBasis,
InvoiceCustomerChargesInput,
SubscriptionAddonTimelineSegment,
UpdateClosedPeriod,
CostBasis,
Expand Down Expand Up @@ -238,6 +239,9 @@ export type {
UpdateBillingPartyTaxIdentity,
InvoiceAvailableActions,
ChargeRealizationPayment,
InvoiceLineAmountDiscount,
InvoiceLineUsageDiscount,
InvoiceLineBaseDiscount,
SubscriptionEditRemovePhase,
TaxCodeAppMapping,
AppCapability,
Expand All @@ -246,9 +250,6 @@ export type {
UpdateAppSandboxRequest,
UpdateAppExternalInvoicingRequest,
WorkflowInvoicingSettings,
InvoiceLineAmountDiscount,
InvoiceLineUsageDiscount,
InvoiceLineBaseDiscount,
ListCurrenciesParamsFilter,
EntitlementAccessQueryRequest,
EntitlementFeatureAccessReason,
Expand Down Expand Up @@ -342,12 +343,12 @@ export type {
SubscriptionBase,
InvoiceStatusDetails,
InvoiceWorkflow,
InvoiceLineDiscounts,
SubscriptionCancel,
SubscriptionMigrate,
SubscriptionAddonUpdate,
TaxCode,
AppCatalogItem,
InvoiceLineDiscounts,
UpdateBillingInvoiceWorkflow,
EntitlementFeatureAccess,
NotificationChannelPagePaginatedResponse,
Expand Down Expand Up @@ -386,6 +387,7 @@ export type {
CreateEntitlementMeteredRequest,
EntitlementGrantPagePaginatedResponse,
InvoiceWorkflowSettings,
InvoiceDetailedLine,
TaxCodePagePaginatedResponse,
AppStripe,
AppSandbox,
Expand All @@ -394,7 +396,6 @@ export type {
InstalledAppStripe,
InstalledAppSandbox,
InstalledAppExternalInvoicing,
InvoiceDetailedLine,
UpdateInvoiceWorkflowSettings,
EntitlementAccessQueryResult,
NotificationEventBalanceThresholdPayload,
Expand Down Expand Up @@ -453,6 +454,7 @@ export type {
SubscriptionMigrateResponse,
ChargeFlatFee,
ChargeUsageBased,
InvoiceCustomerChargesResult,
InvoicePagePaginatedResponse,
ChargePagePaginatedResponse,
StringFieldFilter,
Expand Down Expand Up @@ -604,6 +606,7 @@ export type {
SubscriptionMigrateResponseInput,
ChargeFlatFeeInput,
ChargeUsageBasedInput,
InvoiceCustomerChargesResultInput,
InvoicePagePaginatedResponseInput,
ChargePagePaginatedResponseInput,
WorkflowPaymentSettingsInput,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import type {
EntitlementHistoryWindowSize,
EntitlementPagePaginatedResponse,
GetCreditBalanceParamsFilter,
InvoiceCustomerChargesInput,
InvoiceCustomerChargesResult,
ListCreditGrantsParamsFilter,
ListCreditTransactionsParamsFilter,
ListCustomerChargesParamsFilter,
Expand Down Expand Up @@ -391,3 +393,9 @@ export type CreateCustomerChargesRequest = AcceptDateStrings<{
body: CreateChargeRequestInput
}>
export type CreateCustomerChargesResponse = Charge

export type InvoiceCustomerChargesRequest = AcceptDateStrings<{
customerId: string
body?: InvoiceCustomerChargesInput
}>
export type InvoiceCustomerChargesResponse = InvoiceCustomerChargesResult
Loading
Loading