orb-billing
SDK Installation
NPM
npm add orb-billing
Yarn
yarn add orb-billing
SDK Example Usage
import { Orb } from "orb-billing";
(async() => {
const sdk = new Orb({
security: {
apiKeyAuth: "",
},
});
const res = await sdk.availability.ping();
if (res.statusCode == 200) {
}
})();
Some of the endpoints in this SDK support pagination. To use pagination, you make your SDK calls as usual, but the
returned response object will have a next
method that can be called to pull down the next group of results. If the
return value of next
is null
, then there are no more pages to be fetched.
Here's an example of one such pagination call:
import { Orb } from "orb-billing";
const sdk = new Orb({
security: {
apiKeyAuth: "",
},
});
async function paginationDemo() {
let cursor: string | undefined;
do {
const response = await sdk.coupon.list({ cursor, showArchived: false });
const { statusCode } = response;
if (statusCode !== 200) {
throw new Error(`Unexpected status code sent from server: ${statusCode}`);
}
cursor = response.coupons?.paginationMetadata.nextCursor;
const page = response.coupons?.data;
if (!page?.length) {
break;
}
page.forEach((coupon) => {
const { redemptionCode: code, timesRedeemed } = coupon;
console.log(`Coupon ${code} was redeemed ${timesRedeemed} times.`);
});
} while (cursor);
}
paginationDemo();
Available Resources and Operations
- ping - Check availability
- fetch - Fetch credit note
- list - List credit notes
Maturity
This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage
to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally
looking for the latest version.
Contributions
While we value open-source contributions to this SDK, this library is generated programmatically.
Feel free to open a PR or a Github issue as a proof of concept and we'll do our best to include it in a future release!