Skip to content

Commit

Permalink
feat: invoicing api (#1641)
Browse files Browse the repository at this point in the history
The goal of this PR is to unblock the development of the invoicing for
a single use-case: a manually added line-item.

 Integration with Plans and subscriptions to come later.
  • Loading branch information
turip authored Oct 17, 2024
1 parent 92de1c6 commit 8b0b9fc
Show file tree
Hide file tree
Showing 22 changed files with 12,272 additions and 4,254 deletions.
8,085 changes: 5,548 additions & 2,537 deletions api/api.gen.go

Large diffs are not rendered by default.

6,683 changes: 5,059 additions & 1,624 deletions api/openapi.yaml

Large diffs are not rendered by default.

79 changes: 0 additions & 79 deletions api/spec/src/billing.tsp

This file was deleted.

122 changes: 122 additions & 0 deletions api/spec/src/billing/customeroverride.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
using TypeSpec.Http;
using TypeSpec.OpenAPI;

namespace OpenMeter.Billing;

@route("/api/v1/billing/customer")
@tag("Billing (Experimental)")
interface CustomerOverrides {
/**
* List customer overrides
*/
@get
@summary("List customer overrides")
@operationId("billingListCustomerOverrides")
list(
@query
billingProfile?: Array<ULID>,

...OpenMeter.QueryPagination,
...OpenMeter.QueryLimitOffset,
...OpenMeter.QueryOrdering<CustomerOverrideOrderBy>,
): OpenMeter.PaginatedResponse<CustomerOverride> | OpenMeter.CommonErrors;

/**
* Create/update a new customer override.
*/
@post
@route("/{customerIdOrKey}")
@summary("Create/update a customer override")
@operationId("billingUpsertCustomerOverride")
upsert(
@path
customerIdOrKey: ULIDOrKey,

@body
request: CustomerWorkflowOverride,
):
| {
// Updated
@statusCode _: 200;

@body body: CustomerOverride;
}
| {
// Created
@statusCode _: 201;

@body body: CustomerOverride;
}
| OpenMeter.NotFoundError
| OpenMeter.CommonErrors;

/**
* Get a customer override by id.
*/
@get
@route("/{customerIdOrKey}")
@summary("Get a customer override")
@operationId("billingGetCustomerOverrideById")
get(
@path
customerIdOrKey: ULIDOrKey,
): CustomerOverride | OpenMeter.NotFoundError | OpenMeter.CommonErrors;

/**
* Delete a customer override by id.
*/
@delete
@route("/{customerIdOrKey}")
@summary("Delete a customer override")
@operationId("billingDeleteCustomerOverride")
delete(
@path
customerIdOrKey: ULIDOrKey,
): {
@statusCode _: 204;
} | OpenMeter.NotFoundError | OpenMeter.CommonErrors;
}

/**
* Order by options for customers.
*/
@friendlyName("BillingCustomerOverrideOrderBy")
enum CustomerOverrideOrderBy {
id: "id",
}

/**
* Customer specific workflow overrides.
*/
@friendlyName("BillingCustomerOverride")
model CustomerOverride {
...ResourceTimestamps;
workflow: CustomerWorkflowOverride;

/**
* The billing profile this override is associated with.
*
* If not provided, the default billing profile is chosen if available.
*/
billingProfile?: ULID;
}

@friendlyName("BillingCustomerWorkflowOverride")
model CustomerWorkflowOverride {
...OmitProperties<Workflow, "taxApp" | "invoicingApp" | "paymentApp">;

// Note: these are only available for read, as provider override is not supported via the customer override.
// to do that the customer should be assocatied with a new billing profile instead.

@summary("The tax app used for this workflow")
@visibility("read", "query")
taxApp: OpenMeter.App.App;

@summary("The invoicing app used for this workflow")
@visibility("read", "query")
invoicingApp: OpenMeter.App.App;

@summary("The payment app used for this workflow")
@visibility("read", "query")
paymentApp: OpenMeter.App.App;
}
Loading

0 comments on commit 8b0b9fc

Please sign in to comment.