UNPKG

orb-billing

Version:

The official TypeScript library for the Orb API

46 lines 1.83 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../resource.mjs"; import { isRequestOptions } from "../../core.mjs"; import * as SubscriptionsAPI from "./subscriptions.mjs"; import { Subscriptions } from "./subscriptions.mjs"; import { Page } from "../../pagination.mjs"; export class Coupons extends APIResource { constructor() { super(...arguments); this.subscriptions = new SubscriptionsAPI.Subscriptions(this._client); } /** * This endpoint allows the creation of coupons, which can then be redeemed at * subscription creation or plan change. */ create(body, options) { return this._client.post('/coupons', { body, ...options }); } list(query = {}, options) { if (isRequestOptions(query)) { return this.list({}, query); } return this._client.getAPIList('/coupons', CouponsPage, { query, ...options }); } /** * This endpoint allows a coupon to be archived. Archived coupons can no longer be * redeemed, and will be hidden from lists of active coupons. Additionally, once a * coupon is archived, its redemption code can be reused for a different coupon. */ archive(couponId, options) { return this._client.post(`/coupons/${couponId}/archive`, options); } /** * This endpoint retrieves a coupon by its ID. To fetch coupons by their redemption * code, use the [List coupons](list-coupons) endpoint with the redemption_code * parameter. */ fetch(couponId, options) { return this._client.get(`/coupons/${couponId}`, options); } } export class CouponsPage extends Page { } Coupons.CouponsPage = CouponsPage; Coupons.Subscriptions = Subscriptions; //# sourceMappingURL=coupons.mjs.map