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
11 changes: 6 additions & 5 deletions api/spec/packages/aip-client-javascript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,12 @@ The full call path, HTTP route, and a short description are listed below.

### Invoices

| Method | HTTP | Description |
| ------------------------ | --------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `client.invoices.list` | `GET /openmeter/billing/invoices` | List billing invoices. Returns a page of invoices. Gathering invoices are never included. Use `filter` to narrow by status, customer, dates, or service period start. Use `sort` to control ordering. |
| `client.invoices.get` | `GET /openmeter/billing/invoices/{invoiceId}` | Get a billing invoice by ID. Returns the full invoice resource including line items, status details, totals, and workflow configuration snapshot. |
| `client.invoices.update` | `PUT /openmeter/billing/invoices/{invoiceId}` | Update a billing invoice. Only the mutable fields of the invoice can be edited: description, labels, supplier, customer, workflow settings, and top-level lines. Top-level lines are matched by `id`; lines without an `id` are created, and existing lines omitted from `lines` are deleted. Detailed (child) lines are always computed and cannot be edited directly. Only invoices in draft status can be updated. |
| Method | HTTP | Description |
| ------------------------ | ------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `client.invoices.list` | `GET /openmeter/billing/invoices` | List billing invoices. Returns a page of invoices. Gathering invoices are never included. Use `filter` to narrow by status, customer, dates, or service period start. Use `sort` to control ordering. |
| `client.invoices.get` | `GET /openmeter/billing/invoices/{invoiceId}` | Get a billing invoice by ID. Returns the full invoice resource including line items, status details, totals, and workflow configuration snapshot. |
| `client.invoices.update` | `PUT /openmeter/billing/invoices/{invoiceId}` | Update a billing invoice. Only the mutable fields of the invoice can be edited: description, labels, supplier, customer, workflow settings, and top-level lines. Top-level lines are matched by `id`; lines without an `id` are created, and existing lines omitted from `lines` are deleted. Detailed (child) lines are always computed and cannot be edited directly. Only invoices in draft status can be updated. |
| `client.invoices.delete` | `DELETE /openmeter/billing/invoices/{invoiceId}` | Delete a billing invoice. Only standard invoices in draft status can be deleted. Deleting an invoice will also delete all associated line items and workflow configuration. |

### Tax

Expand Down
18 changes: 18 additions & 0 deletions api/spec/packages/aip-client-javascript/src/funcs/invoices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import type {
GetInvoiceResponse,
UpdateInvoiceRequest,
UpdateInvoiceResponse,
DeleteInvoiceRequest,
DeleteInvoiceResponse,
} from '../models/operations/invoices.js'

export function listInvoices(
Expand Down Expand Up @@ -94,3 +96,19 @@ export function updateInvoice(
})
})
}

export function deleteInvoice(
client: Client,
req: DeleteInvoiceRequest,
options?: RequestOptions,
): Promise<Result<DeleteInvoiceResponse>> {
return request(async () => {
const path = `openmeter/billing/invoices/${(() => {
if (req.invoiceId === undefined) {
throw new Error('missing path parameter: invoiceId')
}
return encodeURIComponent(String(req.invoiceId))
})()}`
await http(client).delete(path, options)
})
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,8 @@ export type UpdateInvoiceRequest = {
export type UpdateInvoiceResponse = z.output<
typeof schemas.updateInvoiceResponse
>

export type DeleteInvoiceRequest = {
invoiceId: string
}
export type DeleteInvoiceResponse = void
Original file line number Diff line number Diff line change
Expand Up @@ -6120,6 +6120,10 @@ export const updateInvoiceBody = updateInvoiceRequest

export const updateInvoiceResponse = invoice

export const deleteInvoicePathParams = z.object({
invoiceId: ulid,
})

export const createTaxCodeBody = createTaxCodeRequest

export const createTaxCodeResponse = taxCode
Expand Down Expand Up @@ -12654,6 +12658,10 @@ export const updateInvoiceBodyWire = updateInvoiceRequestWire

export const updateInvoiceResponseWire = invoiceWire

export const deleteInvoicePathParamsWire = z.object({
invoiceId: ulidWire,
})

export const createTaxCodeBodyWire = createTaxCodeRequestWire

export const createTaxCodeResponseWire = taxCodeWire
Expand Down
16 changes: 15 additions & 1 deletion api/spec/packages/aip-client-javascript/src/sdk/invoices.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import { type Client } from '../core.js'
import { unwrap, type RequestOptions } from '../lib/types.js'
import { listInvoices, getInvoice, updateInvoice } from '../funcs/invoices.js'
import {
listInvoices,
getInvoice,
updateInvoice,
deleteInvoice,
} from '../funcs/invoices.js'
import type {
ListInvoicesRequest,
ListInvoicesResponse,
GetInvoiceRequest,
GetInvoiceResponse,
UpdateInvoiceRequest,
UpdateInvoiceResponse,
DeleteInvoiceRequest,
DeleteInvoiceResponse,
} from '../models/operations/invoices.js'

export class Invoices {
Expand All @@ -33,4 +40,11 @@ export class Invoices {
): Promise<UpdateInvoiceResponse> {
return unwrap(await updateInvoice(this._client, request, options))
}

async delete(
request: DeleteInvoiceRequest,
options?: RequestOptions,
): Promise<DeleteInvoiceResponse> {
return unwrap(await deleteInvoice(this._client, request, options))
}
}
17 changes: 17 additions & 0 deletions api/spec/packages/aip/src/invoices/operations.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,21 @@ interface InvoicesOperations {
@body
invoice: UpdateInvoiceRequest,
): Shared.UpdateResponse<Invoice> | Common.NotFound | Common.ErrorResponses;

/**
* Delete a billing invoice.
*
* Only standard invoices in draft status can be deleted. Deleting an invoice will
* also delete all associated line items and workflow configuration.
*/
@delete
@operationId("delete-invoice")
@summary("Delete a billing invoice")
@extension(Shared.UnstableExtension, true)
@extension(Shared.InternalExtension, true)
@extension(Shared.PrivateExtension, true)
delete(@path invoiceId: Shared.ULID):
| Shared.DeleteResponse
| Common.NotFound
| Common.ErrorResponses;
}
Loading
Loading