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
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "2.0.1"
".": "2.1.0"
}
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# Changelog

## 2.1.0 (2024-03-21)

Full Changelog: [v2.0.1...v2.1.0](https://github.com/orbcorp/orb-node/compare/v2.0.1...v2.1.0)

### Features

* **api:** introduce credits status ([e719163](https://github.com/orbcorp/orb-node/commit/e7191637842912dbf05d98f2f811fbbde69645b1))
* **api:** remove `scaling_factor` ([#136](https://github.com/orbcorp/orb-node/issues/136)) ([e719163](https://github.com/orbcorp/orb-node/commit/e7191637842912dbf05d98f2f811fbbde69645b1))


### Chores

* **errors:** fallback to empty array for validation errors ([#135](https://github.com/orbcorp/orb-node/issues/135)) ([50352c2](https://github.com/orbcorp/orb-node/commit/50352c2d8a1e148b7251894fee8e8d1a752deffd))


### Documentation

* **readme:** consistent use of sentence case in headings ([#132](https://github.com/orbcorp/orb-node/issues/132)) ([ef902e3](https://github.com/orbcorp/orb-node/commit/ef902e3165d5c83ca7a3154f80d226f514509279))
* **readme:** document how to make undocumented requests ([#134](https://github.com/orbcorp/orb-node/issues/134)) ([a84bdad](https://github.com/orbcorp/orb-node/commit/a84bdad2e586a6aa9cee16a79213cc2d4c261162))

## 2.0.1 (2024-03-19)

Full Changelog: [v2.0.0...v2.0.1](https://github.com/orbcorp/orb-node/compare/v2.0.0...v2.0.1)
Expand Down
52 changes: 49 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,51 @@ console.log(raw.headers.get('X-My-Header'));
console.log(customer.id);
```

## Customizing the fetch client
### Making custom/undocumented requests

This library is typed for convenient access to the documented API. If you need to access undocumented
endpoints, params, or response properties, the library can still be used.

#### Undocumented endpoints

To make requests to undocumented endpoints, you can use `client.get`, `client.post`, and other HTTP verbs.
Options on the client, such as retries, will be respected when making these requests.

```ts
await client.post('/some/path', {
body: { some_prop: 'foo' },
query: { some_query_arg: 'bar' },
});
```

#### Undocumented params

To make requests using undocumented parameters, you may use `// @ts-expect-error` on the undocumented
parameter. This library doesn't validate at runtime that the request matches the type, so any extra values you
send will be sent as-is.

```ts
client.foo.create({
foo: 'my_param',
bar: 12,
// @ts-expect-error baz is not yet public
baz: 'undocumented option',
});
```

For requests with the `GET` verb, any extra params will be in the query, all other requests will send the
extra param in the body.

If you want to explicitly send an extra argument, you can do so with the `query`, `body`, and `headers` request
options.

#### Undocumented properties

To access undocumented response properties, you may access the response object with `// @ts-expect-error` on
the response object, or cast the response object to the requisite type. Like the request params, we do not
validate or strip extra properties from the response from the API.

### Customizing the fetch client

By default, this library uses `node-fetch` in Node, and expects a global `fetch` function in other environments.

Expand All @@ -209,6 +253,8 @@ import Orb from 'orb-billing';
To do the inverse, add `import "orb-billing/shims/node"` (which does import polyfills).
This can also be useful if you are getting the wrong TypeScript types for `Response` ([more details](https://github.com/orbcorp/orb-node/tree/main/src/_shims#readme)).

### Logging and middleware

You may also provide a custom `fetch` function when instantiating the client,
which can be used to inspect or alter the `Request` or `Response` before/after each request:

Expand All @@ -229,7 +275,7 @@ const client = new Orb({
Note that if given a `DEBUG=true` environment variable, this library will log all requests and responses automatically.
This is intended for debugging purposes only and may change in the future without notice.

## Configuring an HTTP(S) Agent (e.g., for proxies)
### Configuring an HTTP(S) Agent (e.g., for proxies)

By default, this library uses a stable agent for all http/https requests to reuse TCP connections, eliminating many TCP & TLS handshakes and shaving around 100ms off most requests.

Expand All @@ -254,7 +300,7 @@ await orb.customers.create(
);
```

## Semantic Versioning
## Semantic versioning

This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "orb-billing",
"version": "2.0.1",
"version": "2.1.0",
"description": "The official TypeScript library for the Orb API",
"author": "Orb <team@withorb.com>",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ export class RequestValidationError extends BadRequestError {

this.status = data?.['status'];
this.type = data?.['type'];
this.validation_errors = data?.['validation_errors'];
this.validation_errors = data?.['validation_errors'] ?? [];
this.detail = data?.['detail'];
this.title = data?.['title'];
}
Expand Down
4 changes: 2 additions & 2 deletions src/resources/customers/costs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ export namespace CostListResponse {
* }
* ```
*
* ### Fixed fees
* ## Fixed fees
*
* Fixed fees are prices that are applied independent of usage quantities, and
* follow unit pricing. They also have an additional parameter
Expand Down Expand Up @@ -836,7 +836,7 @@ export namespace CostListByExternalIDResponse {
* }
* ```
*
* ### Fixed fees
* ## Fixed fees
*
* Fixed fees are prices that are applied independent of usage quantities, and
* follow unit pricing. They also have an additional parameter
Expand Down
4 changes: 4 additions & 0 deletions src/resources/customers/credits/credits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ export interface CreditListResponse {
expiry_date: string | null;

per_unit_cost_basis: string | null;

status: 'active' | 'pending_payment';
}

export interface CreditListByExternalIDResponse {
Expand All @@ -88,6 +90,8 @@ export interface CreditListByExternalIDResponse {
expiry_date: string | null;

per_unit_cost_basis: string | null;

status: 'active' | 'pending_payment';
}

export interface CreditListParams extends PageParams {
Expand Down
2 changes: 1 addition & 1 deletion src/resources/invoice-line-items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ export interface InvoiceLineItemCreateResponse {
* }
* ```
*
* ### Fixed fees
* ## Fixed fees
*
* Fixed fees are prices that are applied independent of usage quantities, and
* follow unit pricing. They also have an additional parameter
Expand Down
21 changes: 8 additions & 13 deletions src/resources/invoices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ export namespace Invoice {
* }
* ```
*
* ### Fixed fees
* ## Fixed fees
*
* Fixed fees are prices that are applied independent of usage quantities, and
* follow unit pricing. They also have an additional parameter
Expand Down Expand Up @@ -2050,7 +2050,7 @@ export namespace InvoiceFetchUpcomingResponse {
* }
* ```
*
* ### Fixed fees
* ## Fixed fees
*
* Fixed fees are prices that are applied independent of usage quantities, and
* follow unit pricing. They also have an additional parameter
Expand Down Expand Up @@ -2373,11 +2373,6 @@ export namespace InvoiceCreateParams {
* Rate per unit of usage
*/
unit_amount: string;

/**
* Multiplier to scale rated quantity by
*/
scaling_factor?: number | null;
}
}
}
Expand Down Expand Up @@ -2424,19 +2419,19 @@ export interface InvoiceFetchUpcomingParams {

export interface InvoiceMarkPaidParams {
/**
* An optional external ID to associate with the payment.
* A date string to specify the date of the payment.
*/
external_id: string | null;
payment_received_date: string;

/**
* An optional note to associate with the payment.
* An optional external ID to associate with the payment.
*/
notes: string | null;
external_id?: string | null;

/**
* A date string to specify the date of the payment.
* An optional note to associate with the payment.
*/
payment_received_date: string;
notes?: string | null;
}

export namespace Invoices {
Expand Down
16 changes: 0 additions & 16 deletions src/resources/plans/plans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,11 +396,6 @@ export namespace PlanCreateParams {
* Rate per unit of usage
*/
unit_amount: string;

/**
* Multiplier to scale rated quantity by
*/
scaling_factor?: number | null;
}
}

Expand Down Expand Up @@ -533,12 +528,6 @@ export namespace PlanCreateParams {
* Matrix values for specified matrix grouping keys
*/
matrix_values: Array<MatrixConfig.MatrixValue>;

/**
* Default optional multiplier to scale rated quantities that fall into the default
* bucket by
*/
scaling_factor?: number | null;
}

export namespace MatrixConfig {
Expand All @@ -554,11 +543,6 @@ export namespace PlanCreateParams {
* Unit price for the specified dimension_values
*/
unit_amount: string;

/**
* Optional multiplier to scale rated quantities by
*/
scaling_factor?: number | null;
}
}
}
Expand Down
56 changes: 1 addition & 55 deletions src/resources/prices/prices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ export class PricesPage extends Page<Price> {}
* }
* ```
*
* ### Fixed fees
* ## Fixed fees
*
* Fixed fees are prices that are applied independent of usage quantities, and
* follow unit pricing. They also have an additional parameter
Expand Down Expand Up @@ -383,11 +383,6 @@ export namespace Price {
* Rate per unit of usage
*/
unit_amount: string;

/**
* Multiplier to scale rated quantity by
*/
scaling_factor?: number | null;
}
}

Expand Down Expand Up @@ -544,12 +539,6 @@ export namespace Price {
* Matrix values for specified matrix grouping keys
*/
matrix_values: Array<MatrixConfig.MatrixValue>;

/**
* Default optional multiplier to scale rated quantities that fall into the default
* bucket by
*/
scaling_factor?: number | null;
}

export namespace MatrixConfig {
Expand All @@ -565,11 +554,6 @@ export namespace Price {
* Unit price for the specified dimension_values
*/
unit_amount: string;

/**
* Optional multiplier to scale rated quantities by
*/
scaling_factor?: number | null;
}
}

Expand Down Expand Up @@ -1547,12 +1531,6 @@ export namespace Price {
* Matrix values for specified matrix grouping keys
*/
matrix_values: Array<MatrixWithAllocationConfig.MatrixValue>;

/**
* Default optional multiplier to scale rated quantities that fall into the default
* bucket by
*/
scaling_factor?: number | null;
}

export namespace MatrixWithAllocationConfig {
Expand All @@ -1568,11 +1546,6 @@ export namespace Price {
* Unit price for the specified dimension_values
*/
unit_amount: string;

/**
* Optional multiplier to scale rated quantities by
*/
scaling_factor?: number | null;
}
}

Expand Down Expand Up @@ -1682,11 +1655,6 @@ export namespace PriceCreateParams {
* Rate per unit of usage
*/
unit_amount: string;

/**
* Multiplier to scale rated quantity by
*/
scaling_factor?: number | null;
}
}

Expand Down Expand Up @@ -1829,12 +1797,6 @@ export namespace PriceCreateParams {
* Matrix values for specified matrix grouping keys
*/
matrix_values: Array<MatrixConfig.MatrixValue>;

/**
* Default optional multiplier to scale rated quantities that fall into the default
* bucket by
*/
scaling_factor?: number | null;
}

export namespace MatrixConfig {
Expand All @@ -1850,11 +1812,6 @@ export namespace PriceCreateParams {
* Unit price for the specified dimension_values
*/
unit_amount: string;

/**
* Optional multiplier to scale rated quantities by
*/
scaling_factor?: number | null;
}
}
}
Expand Down Expand Up @@ -1934,12 +1891,6 @@ export namespace PriceCreateParams {
* Matrix values for specified matrix grouping keys
*/
matrix_values: Array<MatrixWithAllocationConfig.MatrixValue>;

/**
* Default optional multiplier to scale rated quantities that fall into the default
* bucket by
*/
scaling_factor?: number | null;
}

export namespace MatrixWithAllocationConfig {
Expand All @@ -1955,11 +1906,6 @@ export namespace PriceCreateParams {
* Unit price for the specified dimension_values
*/
unit_amount: string;

/**
* Optional multiplier to scale rated quantities by
*/
scaling_factor?: number | null;
}
}
}
Expand Down
Loading