@paddle/paddle-node-sdk 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +47 -7
  3. package/dist/entities/pricing-preview/index.d.ts +4 -0
  4. package/dist/entities/pricing-preview/index.js +20 -0
  5. package/dist/entities/pricing-preview/pricing-preview-details.d.ts +6 -0
  6. package/dist/entities/pricing-preview/pricing-preview-details.js +10 -0
  7. package/dist/entities/pricing-preview/pricing-preview-discounts.d.ts +8 -0
  8. package/dist/entities/pricing-preview/pricing-preview-discounts.js +12 -0
  9. package/dist/entities/pricing-preview/pricing-preview-line-item.d.ts +17 -0
  10. package/dist/entities/pricing-preview/pricing-preview-line-item.js +21 -0
  11. package/dist/entities/pricing-preview/pricing-preview.d.ts +15 -0
  12. package/dist/entities/pricing-preview/pricing-preview.js +19 -0
  13. package/dist/paddle.d.ts +2 -1
  14. package/dist/paddle.js +1 -0
  15. package/dist/resources/addresses/index.d.ts +2 -1
  16. package/dist/resources/addresses/index.js +10 -7
  17. package/dist/resources/adjustments/index.d.ts +1 -1
  18. package/dist/resources/adjustments/index.js +2 -4
  19. package/dist/resources/businesses/index.d.ts +2 -1
  20. package/dist/resources/businesses/index.js +10 -7
  21. package/dist/resources/customers/index.d.ts +2 -1
  22. package/dist/resources/customers/index.js +7 -4
  23. package/dist/resources/discounts/index.d.ts +2 -1
  24. package/dist/resources/discounts/index.js +7 -4
  25. package/dist/resources/index.d.ts +1 -0
  26. package/dist/resources/index.js +1 -0
  27. package/dist/resources/prices/index.d.ts +2 -1
  28. package/dist/resources/prices/index.js +7 -4
  29. package/dist/resources/pricing-preview/index.d.ts +7 -0
  30. package/dist/resources/pricing-preview/index.js +42 -0
  31. package/dist/resources/pricing-preview/operations/index.d.ts +1 -0
  32. package/dist/resources/pricing-preview/operations/index.js +17 -0
  33. package/dist/resources/pricing-preview/operations/pricing-preview-request-body.d.ts +17 -0
  34. package/dist/resources/pricing-preview/operations/pricing-preview-request-body.js +2 -0
  35. package/dist/resources/products/index.d.ts +2 -1
  36. package/dist/resources/products/index.js +7 -4
  37. package/dist/resources/subscriptions/index.d.ts +1 -1
  38. package/dist/resources/subscriptions/index.js +2 -4
  39. package/dist/resources/transactions/index.d.ts +1 -1
  40. package/dist/resources/transactions/index.js +2 -4
  41. package/dist/types/index.d.ts +1 -0
  42. package/dist/types/index.js +1 -0
  43. package/dist/types/pricing-preview/index.d.ts +5 -0
  44. package/dist/types/pricing-preview/index.js +21 -0
  45. package/dist/types/pricing-preview/pricing-preview-details-response.d.ts +4 -0
  46. package/dist/types/pricing-preview/pricing-preview-details-response.js +2 -0
  47. package/dist/types/pricing-preview/pricing-preview-discounts-response.d.ts +6 -0
  48. package/dist/types/pricing-preview/pricing-preview-discounts-response.js +2 -0
  49. package/dist/types/pricing-preview/pricing-preview-item-response.d.ts +4 -0
  50. package/dist/types/pricing-preview/pricing-preview-item-response.js +2 -0
  51. package/dist/types/pricing-preview/pricing-preview-line-item-response.d.ts +15 -0
  52. package/dist/types/pricing-preview/pricing-preview-line-item-response.js +2 -0
  53. package/dist/types/pricing-preview/pricing-preview-response.d.ts +15 -0
  54. package/dist/types/pricing-preview/pricing-preview-response.js +2 -0
  55. package/dist/version.d.ts +1 -1
  56. package/dist/version.js +1 -1
  57. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -8,6 +8,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
8
8
 
9
9
  Check our main [developer changelog](https://developer.paddle.com/?utm_source=dx&utm_medium=paddle-node-sdk) for information about changes to the Paddle Billing platform, the Paddle API, and other developer tools.
10
10
 
11
+ ## 0.2.1 - 2023-11-29
12
+
13
+ ### Added
14
+
15
+ - Added helper function to archive supported entities
16
+ - Added `pricingPreview.preview()` to [preview calculations for one or more prices](https://developer.paddle.com/api-reference/pricing-preview/preview-prices?utm_source=dx&utm_medium=paddle-node-sdk)
17
+
18
+ ### Changed
19
+
20
+ - **Breaking change:** Converted all `list` operations to be synchronous. They did not have any async operation within them, and it was incorrectly typed to return a `Promise`.
21
+
11
22
  ## 0.2.0 - 2023-11-28
12
23
 
13
24
  > **Breaking changes:** This version includes major improvements that introduce breaking changes. These are called out below.
package/README.md CHANGED
@@ -63,6 +63,13 @@ Keep in mind that API keys are separate for your sandbox and live accounts, so y
63
63
 
64
64
  This SDK comes with TypeScript definitions for the Paddle API. We recommend that you update frequently to keep the TypeScript definitions up-to-date with the API. Use `// @ts-ignore` to prevent any type error if you don't want to update.
65
65
 
66
+ ## Naming conventions
67
+
68
+ Properties in the Paddle API use `snake_case`. To follow JavaScript conventions, properties in this SDK use `camelCase`. This means:
69
+
70
+ * Convert `snake_case` field names in the API docs to `camelCase` when creating or updating entities using the SDK.
71
+ * Responses match the API docs, but field names are `camelCase` rather than `snake_case`.
72
+
66
73
  ## Examples
67
74
 
68
75
  ### List entities
@@ -74,16 +81,16 @@ import { Paddle } from '@paddle/paddle-node-sdk'
74
81
 
75
82
  const paddle = new Paddle('API_KEY')
76
83
 
77
- async function getProducts() {
84
+ function getProducts() {
78
85
  // creates an iterator instance
79
- const productCollection = await paddle.products.list()
86
+ const productCollection = paddle.products.list()
80
87
  return productCollection
81
88
  }
82
89
 
83
90
  try {
84
91
  // Creates an iterator to loop through paginated data.
85
92
  // At this point, It does not hold any data.
86
- const productCollection = await getProducts()
93
+ const productCollection = getProducts()
87
94
 
88
95
  // Call `next()` to retrieve first page of the dataset
89
96
  const firstPage = await productCollection.next()
@@ -117,7 +124,7 @@ async function createProduct(requestBody: CreateProductRequestBody) {
117
124
  }
118
125
  }
119
126
 
120
- const product = await createProduct({ name: 'ChatApp Education', tax_category: 'standard' })
127
+ const product = await createProduct({ name: 'ChatApp Education', taxCategory: 'standard' })
121
128
  console.log("Product", product)
122
129
  ```
123
130
 
@@ -164,7 +171,7 @@ async function getProduct(productId: string) {
164
171
  try {
165
172
  // Pass the product id get
166
173
  const product = await paddle.products.get(productId)
167
- // Returns an updated product entity
174
+ // Returns a product entity
168
175
  return product
169
176
  } catch (e) {
170
177
  // Handle Network/API errors
@@ -175,6 +182,39 @@ const product = await getProduct('id')
175
182
  console.log('Product', product)
176
183
  ```
177
184
 
185
+ ### Archive an entity
186
+
187
+ You can archive an entity with the `archive` function in the resource. It accepts the `id` of the entity to archive. The entity is returned.
188
+
189
+ #### Entities that support archival
190
+
191
+ - Products
192
+ - Prices
193
+ - Discounts
194
+ - Customers
195
+ - Addresses
196
+ - Businesses
197
+
198
+ ``` typescript
199
+ import { Paddle } from '@paddle/paddle-node-sdk'
200
+
201
+ const paddle = new Paddle('API_KEY')
202
+
203
+ async function archiveProduct(productId: string) {
204
+ try {
205
+ // Pass the product id archive
206
+ const product = await paddle.products.archive(productId)
207
+ // Returns an archived product entity
208
+ return product
209
+ } catch (e) {
210
+ // Handle Network/API errors
211
+ }
212
+ }
213
+
214
+ const product = await archiveProduct('id')
215
+ console.log('Product', product)
216
+ ```
217
+
178
218
  ## Resources
179
219
 
180
220
  ### Webhook signature verification
@@ -249,8 +289,8 @@ This table shows which operations are available as of the latest release.
249
289
  | **Adjustments** | **Full** |
250
290
  | List adjustments | ✅ |
251
291
  | Create an adjustment | ✅ |
252
- | **Pricing preview** | **None** |
253
- | Preview prices | ❌ |
292
+ | **Pricing preview** | **Full** |
293
+ | Preview prices | ✅ |
254
294
  | **Event types** | **None** |
255
295
  | List event types | ❌ |
256
296
  | **Events** | **None** |
@@ -0,0 +1,4 @@
1
+ export * from './pricing-preview-discounts';
2
+ export * from './pricing-preview-line-item';
3
+ export * from './pricing-preview-details';
4
+ export * from './pricing-preview';
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./pricing-preview-discounts"), exports);
18
+ __exportStar(require("./pricing-preview-line-item"), exports);
19
+ __exportStar(require("./pricing-preview-details"), exports);
20
+ __exportStar(require("./pricing-preview"), exports);
@@ -0,0 +1,6 @@
1
+ import { PricingPreviewLineItem } from './pricing-preview-line-item';
2
+ import { type IPricingPreviewDetailsResponse } from '../../types';
3
+ export declare class PricingPreviewDetails {
4
+ readonly lineItems: PricingPreviewLineItem[];
5
+ constructor(details: IPricingPreviewDetailsResponse);
6
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PricingPreviewDetails = void 0;
4
+ const pricing_preview_line_item_1 = require("./pricing-preview-line-item");
5
+ class PricingPreviewDetails {
6
+ constructor(details) {
7
+ this.lineItems = details.line_items.map((line_item) => new pricing_preview_line_item_1.PricingPreviewLineItem(line_item));
8
+ }
9
+ }
10
+ exports.PricingPreviewDetails = PricingPreviewDetails;
@@ -0,0 +1,8 @@
1
+ import { type IPricingPreviewDiscountsResponse } from '../../types';
2
+ import { Discount } from '../index';
3
+ export declare class PricingPreviewDiscounts {
4
+ readonly discount: Discount;
5
+ readonly total: string;
6
+ readonly formattedTotal: string;
7
+ constructor(previewDiscount: IPricingPreviewDiscountsResponse);
8
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PricingPreviewDiscounts = void 0;
4
+ const index_1 = require("../index");
5
+ class PricingPreviewDiscounts {
6
+ constructor(previewDiscount) {
7
+ this.discount = new index_1.Discount(previewDiscount.discount);
8
+ this.total = previewDiscount.total;
9
+ this.formattedTotal = previewDiscount.formatted_total;
10
+ }
11
+ }
12
+ exports.PricingPreviewDiscounts = PricingPreviewDiscounts;
@@ -0,0 +1,17 @@
1
+ import { Price } from '../price';
2
+ import { Totals } from '../shared';
3
+ import { Product } from '../product';
4
+ import { PricingPreviewDiscounts } from './pricing-preview-discounts';
5
+ import { type IPricingPreviewLineItemResponse } from '../../types';
6
+ export declare class PricingPreviewLineItem {
7
+ readonly price: Price;
8
+ readonly quantity: number;
9
+ readonly taxRate: string;
10
+ readonly unitTotals: Totals;
11
+ readonly formattedUnitTotals: Totals;
12
+ readonly totals: Totals;
13
+ readonly formattedTotals: Totals;
14
+ readonly product: Product;
15
+ readonly discounts: PricingPreviewDiscounts[];
16
+ constructor(lineItem: IPricingPreviewLineItemResponse);
17
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PricingPreviewLineItem = void 0;
4
+ const price_1 = require("../price");
5
+ const shared_1 = require("../shared");
6
+ const product_1 = require("../product");
7
+ const pricing_preview_discounts_1 = require("./pricing-preview-discounts");
8
+ class PricingPreviewLineItem {
9
+ constructor(lineItem) {
10
+ this.price = new price_1.Price(lineItem.price);
11
+ this.quantity = lineItem.quantity;
12
+ this.taxRate = lineItem.tax_rate;
13
+ this.unitTotals = new shared_1.Totals(lineItem.unit_totals);
14
+ this.formattedUnitTotals = new shared_1.Totals(lineItem.formatted_unit_totals);
15
+ this.totals = new shared_1.Totals(lineItem.totals);
16
+ this.formattedTotals = new shared_1.Totals(lineItem.formatted_totals);
17
+ this.product = new product_1.Product(lineItem.product);
18
+ this.discounts = lineItem.discounts.map((discount) => new pricing_preview_discounts_1.PricingPreviewDiscounts(discount));
19
+ }
20
+ }
21
+ exports.PricingPreviewLineItem = PricingPreviewLineItem;
@@ -0,0 +1,15 @@
1
+ import { type CurrencyCode } from '../../enums';
2
+ import { type IPricingPreviewResponse } from '../../types';
3
+ import { AddressPreview } from '../transaction';
4
+ import { PricingPreviewDetails } from './pricing-preview-details';
5
+ export declare class PricingPreview {
6
+ readonly customerId: string | null;
7
+ readonly addressId: string | null;
8
+ readonly businessId: string | null;
9
+ readonly currencyCode: CurrencyCode | null;
10
+ readonly discountId: string | null;
11
+ readonly address: AddressPreview | null;
12
+ readonly customerIpAddress: string | null;
13
+ readonly details: PricingPreviewDetails | null;
14
+ constructor(pricePreview: IPricingPreviewResponse);
15
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PricingPreview = void 0;
4
+ const transaction_1 = require("../transaction");
5
+ const pricing_preview_details_1 = require("./pricing-preview-details");
6
+ class PricingPreview {
7
+ constructor(pricePreview) {
8
+ var _a, _b, _c, _d, _e, _f;
9
+ this.customerId = (_a = pricePreview.customer_id) !== null && _a !== void 0 ? _a : null;
10
+ this.addressId = (_b = pricePreview.address_id) !== null && _b !== void 0 ? _b : null;
11
+ this.businessId = (_c = pricePreview.business_id) !== null && _c !== void 0 ? _c : null;
12
+ this.currencyCode = (_d = pricePreview.currency_code) !== null && _d !== void 0 ? _d : null;
13
+ this.discountId = (_e = pricePreview.discount_id) !== null && _e !== void 0 ? _e : null;
14
+ this.address = pricePreview.address ? new transaction_1.AddressPreview(pricePreview.address) : null;
15
+ this.customerIpAddress = (_f = pricePreview.customer_ip_address) !== null && _f !== void 0 ? _f : null;
16
+ this.details = pricePreview.details ? new pricing_preview_details_1.PricingPreviewDetails(pricePreview.details) : null;
17
+ }
18
+ }
19
+ exports.PricingPreview = PricingPreview;
package/dist/paddle.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AddressesResource, AdjustmentsResource, BusinessesResource, CustomersResource, DiscountsResource, PricesResource, ProductsResource, SubscriptionsResource, TransactionsResource } from './resources';
1
+ import { AddressesResource, AdjustmentsResource, BusinessesResource, CustomersResource, DiscountsResource, PricesResource, PricingPreviewResource, ProductsResource, SubscriptionsResource, TransactionsResource } from './resources';
2
2
  import { type PaddleOptions } from './internal';
3
3
  export declare class Paddle {
4
4
  private readonly client;
@@ -12,5 +12,6 @@ export declare class Paddle {
12
12
  businesses: BusinessesResource;
13
13
  discounts: DiscountsResource;
14
14
  subscriptions: SubscriptionsResource;
15
+ pricingPreview: PricingPreviewResource;
15
16
  constructor(apiKey: string, options: PaddleOptions);
16
17
  }
package/dist/paddle.js CHANGED
@@ -19,6 +19,7 @@ class Paddle {
19
19
  this.businesses = new resources_1.BusinessesResource(this.client);
20
20
  this.discounts = new resources_1.DiscountsResource(this.client);
21
21
  this.subscriptions = new resources_1.SubscriptionsResource(this.client);
22
+ this.pricingPreview = new resources_1.PricingPreviewResource(this.client);
22
23
  }
23
24
  }
24
25
  exports.Paddle = Paddle;
@@ -3,8 +3,9 @@ import { BaseResource } from '../../internal/base';
3
3
  import { type ListAddressQueryParameters, type CreateAddressRequestBody, type UpdateAddressRequestBody } from './operations';
4
4
  export * from './operations';
5
5
  export declare class AddressesResource extends BaseResource {
6
- list(customerId: string, queryParams?: ListAddressQueryParameters): Promise<AddressCollection>;
6
+ list(customerId: string, queryParams?: ListAddressQueryParameters): AddressCollection;
7
7
  create(customerId: string, createAddressParameters: CreateAddressRequestBody): Promise<Address>;
8
8
  get(customerId: string, addressId: string): Promise<Address>;
9
9
  update(customerId: string, addressId: string, updateAddress: UpdateAddressRequestBody): Promise<Address>;
10
+ archive(customerId: string, addressId: string): Promise<Address>;
10
11
  }
@@ -35,13 +35,11 @@ const AddressPaths = {
35
35
  __exportStar(require("./operations"), exports);
36
36
  class AddressesResource extends base_1.BaseResource {
37
37
  list(customerId, queryParams) {
38
- return __awaiter(this, void 0, void 0, function* () {
39
- const queryParameters = new base_1.QueryParameters(queryParams);
40
- const urlWithPathParams = new base_1.PathParameters(AddressPaths.list, {
41
- customer_id: customerId,
42
- }).deriveUrl();
43
- return new entities_1.AddressCollection(this.client, urlWithPathParams + queryParameters.toQueryString());
44
- });
38
+ const queryParameters = new base_1.QueryParameters(queryParams);
39
+ const urlWithPathParams = new base_1.PathParameters(AddressPaths.list, {
40
+ customer_id: customerId,
41
+ }).deriveUrl();
42
+ return new entities_1.AddressCollection(this.client, urlWithPathParams + queryParameters.toQueryString());
45
43
  }
46
44
  create(customerId, createAddressParameters) {
47
45
  return __awaiter(this, void 0, void 0, function* () {
@@ -75,5 +73,10 @@ class AddressesResource extends base_1.BaseResource {
75
73
  return new entities_1.Address(data);
76
74
  });
77
75
  }
76
+ archive(customerId, addressId) {
77
+ return __awaiter(this, void 0, void 0, function* () {
78
+ return yield this.update(customerId, addressId, { status: 'archived' });
79
+ });
80
+ }
78
81
  }
79
82
  exports.AddressesResource = AddressesResource;
@@ -3,6 +3,6 @@ import { BaseResource } from '../../internal/base';
3
3
  import { type CreateAdjustmentRequestBody, type ListAdjustmentQueryParameters } from './operations';
4
4
  export * from './operations';
5
5
  export declare class AdjustmentsResource extends BaseResource {
6
- list(queryParams?: ListAdjustmentQueryParameters): Promise<AdjustmentCollection>;
6
+ list(queryParams?: ListAdjustmentQueryParameters): AdjustmentCollection;
7
7
  create(createAdjustmentParameters: CreateAdjustmentRequestBody): Promise<Adjustment>;
8
8
  }
@@ -33,10 +33,8 @@ const AdjustmentPaths = {
33
33
  __exportStar(require("./operations"), exports);
34
34
  class AdjustmentsResource extends base_1.BaseResource {
35
35
  list(queryParams) {
36
- return __awaiter(this, void 0, void 0, function* () {
37
- const queryParameters = new base_1.QueryParameters(queryParams);
38
- return new entities_1.AdjustmentCollection(this.client, AdjustmentPaths.list + queryParameters.toQueryString());
39
- });
36
+ const queryParameters = new base_1.QueryParameters(queryParams);
37
+ return new entities_1.AdjustmentCollection(this.client, AdjustmentPaths.list + queryParameters.toQueryString());
40
38
  }
41
39
  create(createAdjustmentParameters) {
42
40
  return __awaiter(this, void 0, void 0, function* () {
@@ -3,8 +3,9 @@ import { BaseResource } from '../../internal/base';
3
3
  import { type CreateBusinessRequestBody, type ListBusinessQueryParameters, type UpdateBusinessRequestBody } from './operations';
4
4
  export * from './operations';
5
5
  export declare class BusinessesResource extends BaseResource {
6
- list(customerId: string, queryParams?: ListBusinessQueryParameters): Promise<BusinessCollection>;
6
+ list(customerId: string, queryParams?: ListBusinessQueryParameters): BusinessCollection;
7
7
  create(customerId: string, createBusinessParameters: CreateBusinessRequestBody): Promise<Business>;
8
8
  get(customerId: string, businessId: string): Promise<Business>;
9
9
  update(customerId: string, businessId: string, updateBusiness: UpdateBusinessRequestBody): Promise<Business>;
10
+ archive(customerId: string, addressId: string): Promise<Business>;
10
11
  }
@@ -35,13 +35,11 @@ const BusinessPaths = {
35
35
  __exportStar(require("./operations"), exports);
36
36
  class BusinessesResource extends base_1.BaseResource {
37
37
  list(customerId, queryParams) {
38
- return __awaiter(this, void 0, void 0, function* () {
39
- const queryParameters = new base_1.QueryParameters(queryParams);
40
- const urlWithPathParams = new base_1.PathParameters(BusinessPaths.list, {
41
- customer_id: customerId,
42
- }).deriveUrl();
43
- return new entities_1.BusinessCollection(this.client, urlWithPathParams + queryParameters.toQueryString());
44
- });
38
+ const queryParameters = new base_1.QueryParameters(queryParams);
39
+ const urlWithPathParams = new base_1.PathParameters(BusinessPaths.list, {
40
+ customer_id: customerId,
41
+ }).deriveUrl();
42
+ return new entities_1.BusinessCollection(this.client, urlWithPathParams + queryParameters.toQueryString());
45
43
  }
46
44
  create(customerId, createBusinessParameters) {
47
45
  return __awaiter(this, void 0, void 0, function* () {
@@ -75,5 +73,10 @@ class BusinessesResource extends base_1.BaseResource {
75
73
  return new entities_1.Business(data);
76
74
  });
77
75
  }
76
+ archive(customerId, addressId) {
77
+ return __awaiter(this, void 0, void 0, function* () {
78
+ return yield this.update(customerId, addressId, { status: 'archived' });
79
+ });
80
+ }
78
81
  }
79
82
  exports.BusinessesResource = BusinessesResource;
@@ -3,9 +3,10 @@ import { BaseResource } from '../../internal/base';
3
3
  import { type CreateCustomerRequestBody, type GetCreditBalanceQueryParameters, type ListCustomerQueryParameters, type UpdateCustomerRequestBody } from './operations';
4
4
  export * from './operations';
5
5
  export declare class CustomersResource extends BaseResource {
6
- list(queryParams?: ListCustomerQueryParameters): Promise<CustomerCollection>;
6
+ list(queryParams?: ListCustomerQueryParameters): CustomerCollection;
7
7
  create(createCustomerParameters: CreateCustomerRequestBody): Promise<Customer>;
8
8
  get(customerId: string): Promise<Customer>;
9
9
  update(customerId: string, updateCustomer: UpdateCustomerRequestBody): Promise<Customer>;
10
10
  getCreditBalance(customerId: string, queryParams?: GetCreditBalanceQueryParameters): Promise<CreditBalance[]>;
11
+ archive(customerId: string): Promise<Customer>;
11
12
  }
@@ -36,10 +36,8 @@ const CustomerPaths = {
36
36
  __exportStar(require("./operations"), exports);
37
37
  class CustomersResource extends base_1.BaseResource {
38
38
  list(queryParams) {
39
- return __awaiter(this, void 0, void 0, function* () {
40
- const queryParameters = new base_1.QueryParameters(queryParams);
41
- return new entities_1.CustomerCollection(this.client, CustomerPaths.list + queryParameters.toQueryString());
42
- });
39
+ const queryParameters = new base_1.QueryParameters(queryParams);
40
+ return new entities_1.CustomerCollection(this.client, CustomerPaths.list + queryParameters.toQueryString());
43
41
  }
44
42
  create(createCustomerParameters) {
45
43
  return __awaiter(this, void 0, void 0, function* () {
@@ -79,5 +77,10 @@ class CustomersResource extends base_1.BaseResource {
79
77
  return data.map((balance) => new entities_1.CreditBalance(balance));
80
78
  });
81
79
  }
80
+ archive(customerId) {
81
+ return __awaiter(this, void 0, void 0, function* () {
82
+ return yield this.update(customerId, { status: 'archived' });
83
+ });
84
+ }
82
85
  }
83
86
  exports.CustomersResource = CustomersResource;
@@ -3,8 +3,9 @@ import { BaseResource } from '../../internal/base';
3
3
  import { type CreateDiscountRequestBody, type ListDiscountQueryParameters, type UpdateDiscountRequestBody } from './operations';
4
4
  export * from './operations';
5
5
  export declare class DiscountsResource extends BaseResource {
6
- list(queryParams?: ListDiscountQueryParameters): Promise<DiscountCollection>;
6
+ list(queryParams?: ListDiscountQueryParameters): DiscountCollection;
7
7
  create(createDiscountParameters: CreateDiscountRequestBody): Promise<Discount>;
8
8
  get(discountId: string): Promise<Discount>;
9
9
  update(discountId: string, updateDiscount: UpdateDiscountRequestBody): Promise<Discount>;
10
+ archive(discountId: string): Promise<Discount>;
10
11
  }
@@ -35,10 +35,8 @@ const DiscountPaths = {
35
35
  __exportStar(require("./operations"), exports);
36
36
  class DiscountsResource extends base_1.BaseResource {
37
37
  list(queryParams) {
38
- return __awaiter(this, void 0, void 0, function* () {
39
- const queryParameters = new base_1.QueryParameters(queryParams);
40
- return new entities_1.DiscountCollection(this.client, DiscountPaths.list + queryParameters.toQueryString());
41
- });
38
+ const queryParameters = new base_1.QueryParameters(queryParams);
39
+ return new entities_1.DiscountCollection(this.client, DiscountPaths.list + queryParameters.toQueryString());
42
40
  }
43
41
  create(createDiscountParameters) {
44
42
  return __awaiter(this, void 0, void 0, function* () {
@@ -67,5 +65,10 @@ class DiscountsResource extends base_1.BaseResource {
67
65
  return new entities_1.Discount(data);
68
66
  });
69
67
  }
68
+ archive(discountId) {
69
+ return __awaiter(this, void 0, void 0, function* () {
70
+ return yield this.update(discountId, { status: 'archived' });
71
+ });
72
+ }
70
73
  }
71
74
  exports.DiscountsResource = DiscountsResource;
@@ -7,3 +7,4 @@ export * from './prices';
7
7
  export * from './products';
8
8
  export * from './subscriptions';
9
9
  export * from './transactions';
10
+ export * from './pricing-preview';
@@ -23,3 +23,4 @@ __exportStar(require("./prices"), exports);
23
23
  __exportStar(require("./products"), exports);
24
24
  __exportStar(require("./subscriptions"), exports);
25
25
  __exportStar(require("./transactions"), exports);
26
+ __exportStar(require("./pricing-preview"), exports);
@@ -3,8 +3,9 @@ import { BaseResource } from '../../internal/base';
3
3
  import { type CreatePriceRequestBody, type GetPriceQueryParameters, type ListPriceQueryParameters, type UpdatePriceRequestBody } from './operations';
4
4
  export * from './operations';
5
5
  export declare class PricesResource extends BaseResource {
6
- list(queryParams?: ListPriceQueryParameters): Promise<PriceCollection>;
6
+ list(queryParams?: ListPriceQueryParameters): PriceCollection;
7
7
  create(createPriceParameters: CreatePriceRequestBody): Promise<Price>;
8
8
  get(priceId: string, queryParams?: GetPriceQueryParameters): Promise<PriceWithIncludes>;
9
9
  update(priceId: string, updatePrice: UpdatePriceRequestBody): Promise<Price>;
10
+ archive(priceId: string): Promise<Price>;
10
11
  }
@@ -35,10 +35,8 @@ const PricePaths = {
35
35
  __exportStar(require("./operations"), exports);
36
36
  class PricesResource extends base_1.BaseResource {
37
37
  list(queryParams) {
38
- return __awaiter(this, void 0, void 0, function* () {
39
- const queryParameters = new base_1.QueryParameters(queryParams);
40
- return new entities_1.PriceCollection(this.client, PricePaths.list + queryParameters.toQueryString());
41
- });
38
+ const queryParameters = new base_1.QueryParameters(queryParams);
39
+ return new entities_1.PriceCollection(this.client, PricePaths.list + queryParameters.toQueryString());
42
40
  }
43
41
  create(createPriceParameters) {
44
42
  return __awaiter(this, void 0, void 0, function* () {
@@ -68,5 +66,10 @@ class PricesResource extends base_1.BaseResource {
68
66
  return new entities_1.Price(data);
69
67
  });
70
68
  }
69
+ archive(priceId) {
70
+ return __awaiter(this, void 0, void 0, function* () {
71
+ return yield this.update(priceId, { status: 'archived' });
72
+ });
73
+ }
71
74
  }
72
75
  exports.PricesResource = PricesResource;
@@ -0,0 +1,7 @@
1
+ import { BaseResource } from '../../internal/base';
2
+ import { type PricingPreviewRequestBody } from './operations';
3
+ import { PricingPreview } from '../../entities/pricing-preview';
4
+ export * from './operations';
5
+ export declare class PricingPreviewResource extends BaseResource {
6
+ preview(pricePreviewParameter: PricingPreviewRequestBody): Promise<PricingPreview>;
7
+ }
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
17
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
18
+ return new (P || (P = Promise))(function (resolve, reject) {
19
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
23
+ });
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.PricingPreviewResource = void 0;
27
+ const base_1 = require("../../internal/base");
28
+ const pricing_preview_1 = require("../../entities/pricing-preview");
29
+ const PricingPreviewPaths = {
30
+ preview: '/pricing-preview',
31
+ };
32
+ __exportStar(require("./operations"), exports);
33
+ class PricingPreviewResource extends base_1.BaseResource {
34
+ preview(pricePreviewParameter) {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ const response = yield this.client.post(PricingPreviewPaths.preview, pricePreviewParameter);
37
+ const data = this.handleResponse(response);
38
+ return new pricing_preview_1.PricingPreview(data);
39
+ });
40
+ }
41
+ }
42
+ exports.PricingPreviewResource = PricingPreviewResource;
@@ -0,0 +1 @@
1
+ export * from './pricing-preview-request-body';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./pricing-preview-request-body"), exports);
@@ -0,0 +1,17 @@
1
+ import { type CurrencyCode } from '../../../enums';
2
+ import { type IAddressPreview } from '../../transactions';
3
+ interface IPricePreviewItem {
4
+ priceId: string;
5
+ quantity: number;
6
+ }
7
+ export interface PricingPreviewRequestBody {
8
+ items: IPricePreviewItem[];
9
+ customerId?: string | null;
10
+ addressId?: string | null;
11
+ businessId?: string | null;
12
+ currencyCode?: CurrencyCode;
13
+ discountId?: string | null;
14
+ address?: IAddressPreview | null;
15
+ customerIpAddress?: string | null;
16
+ }
17
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -3,8 +3,9 @@ import { BaseResource } from '../../internal/base';
3
3
  import { type CreateProductRequestBody, type GetProductQueryParameters, type ListProductQueryParameters, type UpdateProductRequestBody } from './operations';
4
4
  export * from './operations';
5
5
  export declare class ProductsResource extends BaseResource {
6
- list(queryParams?: ListProductQueryParameters): Promise<ProductCollection>;
6
+ list(queryParams?: ListProductQueryParameters): ProductCollection;
7
7
  create(createProductParameters: CreateProductRequestBody): Promise<Product>;
8
8
  get(productId: string, queryParams?: GetProductQueryParameters): Promise<ProductWithIncludes>;
9
9
  update(productId: string, updateProduct: UpdateProductRequestBody): Promise<Product>;
10
+ archive(productId: string): Promise<Product>;
10
11
  }
@@ -35,10 +35,8 @@ const ProductPaths = {
35
35
  __exportStar(require("./operations"), exports);
36
36
  class ProductsResource extends base_1.BaseResource {
37
37
  list(queryParams) {
38
- return __awaiter(this, void 0, void 0, function* () {
39
- const queryParameters = new base_1.QueryParameters(queryParams);
40
- return new entities_1.ProductCollection(this.client, ProductPaths.list + queryParameters.toQueryString());
41
- });
38
+ const queryParameters = new base_1.QueryParameters(queryParams);
39
+ return new entities_1.ProductCollection(this.client, ProductPaths.list + queryParameters.toQueryString());
42
40
  }
43
41
  create(createProductParameters) {
44
42
  return __awaiter(this, void 0, void 0, function* () {
@@ -68,5 +66,10 @@ class ProductsResource extends base_1.BaseResource {
68
66
  return new entities_1.Product(data);
69
67
  });
70
68
  }
69
+ archive(productId) {
70
+ return __awaiter(this, void 0, void 0, function* () {
71
+ return yield this.update(productId, { status: 'archived' });
72
+ });
73
+ }
71
74
  }
72
75
  exports.ProductsResource = ProductsResource;
@@ -5,7 +5,7 @@ export * from './operations';
5
5
  export declare class SubscriptionsResource extends BaseResource {
6
6
  previewUpdate(subscriptionId: string, updateSubscription: UpdateSubscriptionRequestBody): Promise<SubscriptionPreview>;
7
7
  update(subscriptionId: string, updateSubscription: UpdateSubscriptionRequestBody): Promise<Subscription>;
8
- list(queryParams?: ListSubscriptionQueryParameters): Promise<SubscriptionCollection>;
8
+ list(queryParams?: ListSubscriptionQueryParameters): SubscriptionCollection;
9
9
  get(subscriptionId: string, queryParams?: GetSubscriptionQueryParameters): Promise<SubscriptionIncludes>;
10
10
  activate(subscriptionId: string): Promise<Subscription>;
11
11
  pause(subscriptionId: string, requestBody: PauseSubscription): Promise<Subscription>;
@@ -62,10 +62,8 @@ class SubscriptionsResource extends base_1.BaseResource {
62
62
  });
63
63
  }
64
64
  list(queryParams) {
65
- return __awaiter(this, void 0, void 0, function* () {
66
- const queryParameters = new base_1.QueryParameters(queryParams);
67
- return new entities_1.SubscriptionCollection(this.client, SubscriptionPaths.list + queryParameters.toQueryString());
68
- });
65
+ const queryParameters = new base_1.QueryParameters(queryParams);
66
+ return new entities_1.SubscriptionCollection(this.client, SubscriptionPaths.list + queryParameters.toQueryString());
69
67
  }
70
68
  get(subscriptionId, queryParams) {
71
69
  return __awaiter(this, void 0, void 0, function* () {
@@ -3,7 +3,7 @@ import { BaseResource } from '../../internal/base';
3
3
  import { type CreateTransactionQueryParameters, type CreateTransactionRequestBody, type GetTransactionQueryParameters, type ListTransactionQueryParameters, type UpdateTransactionRequestBody, type TransactionPreviewRequestBody } from './operations';
4
4
  export * from './operations';
5
5
  export declare class TransactionsResource extends BaseResource {
6
- list(queryParams?: ListTransactionQueryParameters): Promise<TransactionCollection>;
6
+ list(queryParams?: ListTransactionQueryParameters): TransactionCollection;
7
7
  create(createTransactionParameters: CreateTransactionRequestBody, queryParams?: CreateTransactionQueryParameters): Promise<TransactionIncludes>;
8
8
  update(transactionId: string, updateTransaction: UpdateTransactionRequestBody): Promise<Transaction>;
9
9
  get(transactionId: string, queryParams?: GetTransactionQueryParameters): Promise<TransactionIncludes>;
@@ -37,10 +37,8 @@ const TransactionPaths = {
37
37
  __exportStar(require("./operations"), exports);
38
38
  class TransactionsResource extends base_1.BaseResource {
39
39
  list(queryParams) {
40
- return __awaiter(this, void 0, void 0, function* () {
41
- const queryParameters = new base_1.QueryParameters(queryParams);
42
- return new entities_1.TransactionCollection(this.client, TransactionPaths.list + queryParameters.toQueryString());
43
- });
40
+ const queryParameters = new base_1.QueryParameters(queryParams);
41
+ return new entities_1.TransactionCollection(this.client, TransactionPaths.list + queryParameters.toQueryString());
44
42
  }
45
43
  create(createTransactionParameters, queryParams) {
46
44
  return __awaiter(this, void 0, void 0, function* () {
@@ -8,3 +8,4 @@ export * from './business';
8
8
  export * from './subscription';
9
9
  export * from './address';
10
10
  export * from './discount';
11
+ export * from './pricing-preview';
@@ -24,3 +24,4 @@ __exportStar(require("./business"), exports);
24
24
  __exportStar(require("./subscription"), exports);
25
25
  __exportStar(require("./address"), exports);
26
26
  __exportStar(require("./discount"), exports);
27
+ __exportStar(require("./pricing-preview"), exports);
@@ -0,0 +1,5 @@
1
+ export * from './pricing-preview-response';
2
+ export * from './pricing-preview-details-response';
3
+ export * from './pricing-preview-discounts-response';
4
+ export * from './pricing-preview-item-response';
5
+ export * from './pricing-preview-line-item-response';
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./pricing-preview-response"), exports);
18
+ __exportStar(require("./pricing-preview-details-response"), exports);
19
+ __exportStar(require("./pricing-preview-discounts-response"), exports);
20
+ __exportStar(require("./pricing-preview-item-response"), exports);
21
+ __exportStar(require("./pricing-preview-line-item-response"), exports);
@@ -0,0 +1,4 @@
1
+ import { type IPricingPreviewLineItemResponse } from './pricing-preview-line-item-response';
2
+ export interface IPricingPreviewDetailsResponse {
3
+ line_items: IPricingPreviewLineItemResponse[];
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ import { type IDiscountResponse } from '../discount';
2
+ export interface IPricingPreviewDiscountsResponse {
3
+ discount: IDiscountResponse;
4
+ total: string;
5
+ formatted_total: string;
6
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,4 @@
1
+ export interface IPricingPreviewItemResponse {
2
+ price_id?: string | null;
3
+ quantity: number;
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,15 @@
1
+ import { type IPriceResponse } from '../price';
2
+ import { type ITotals, type IUnitTotals } from '../shared';
3
+ import { type IProductResponse } from '../product';
4
+ import { type IPricingPreviewDiscountsResponse } from './pricing-preview-discounts-response';
5
+ export interface IPricingPreviewLineItemResponse {
6
+ price: IPriceResponse;
7
+ quantity: number;
8
+ tax_rate: string;
9
+ unit_totals: IUnitTotals;
10
+ formatted_unit_totals: IUnitTotals;
11
+ totals: ITotals;
12
+ formatted_totals: ITotals;
13
+ product: IProductResponse;
14
+ discounts: IPricingPreviewDiscountsResponse[];
15
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,15 @@
1
+ import { type CurrencyCode } from '../../enums';
2
+ import { type IAddressPreviewResponse } from '../../resources';
3
+ import { type IPricingPreviewItemResponse } from './pricing-preview-item-response';
4
+ import { type IPricingPreviewDetailsResponse } from './pricing-preview-details-response';
5
+ export interface IPricingPreviewResponse {
6
+ customer_id?: string | null;
7
+ address_id?: string | null;
8
+ business_id?: string | null;
9
+ currency_code?: CurrencyCode | null;
10
+ discount_id?: string | null;
11
+ address?: IAddressPreviewResponse | null;
12
+ customer_ip_address?: string | null;
13
+ items: IPricingPreviewItemResponse[];
14
+ details?: IPricingPreviewDetailsResponse | null;
15
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.2.0";
1
+ export declare const SDK_VERSION = "0.2.1";
package/dist/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = '0.2.0';
4
+ exports.SDK_VERSION = '0.2.1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paddle/paddle-node-sdk",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "A NodeJS SDK for Paddle Billing API",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",