@paddle/paddle-node-sdk 0.2.1 → 0.2.2

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 (153) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +43 -4
  3. package/dist/entities/discount/discount.d.ts +1 -1
  4. package/dist/entities/discount/discount.js +2 -1
  5. package/dist/entities/events/event-collection.d.ts +6 -0
  6. package/dist/entities/events/event-collection.js +11 -0
  7. package/dist/entities/events/event.d.ts +9 -0
  8. package/dist/entities/events/event.js +14 -0
  9. package/dist/entities/events/index.d.ts +1 -0
  10. package/dist/entities/events/index.js +17 -0
  11. package/dist/entities/index.d.ts +2 -0
  12. package/dist/entities/index.js +2 -0
  13. package/dist/entities/payout/index.d.ts +1 -0
  14. package/dist/entities/payout/index.js +17 -0
  15. package/dist/entities/payout/payout.d.ts +9 -0
  16. package/dist/entities/payout/payout.js +12 -0
  17. package/dist/entities/subscription/index.d.ts +1 -0
  18. package/dist/entities/subscription/index.js +1 -0
  19. package/dist/entities/subscription/subscription-notification.d.ts +28 -0
  20. package/dist/entities/subscription/subscription-notification.js +35 -0
  21. package/dist/enums/index.d.ts +1 -0
  22. package/dist/enums/index.js +1 -0
  23. package/dist/enums/payout/index.d.ts +1 -0
  24. package/dist/enums/payout/index.js +17 -0
  25. package/dist/enums/payout/payout-status.d.ts +1 -0
  26. package/dist/enums/payout/payout-status.js +2 -0
  27. package/dist/notifications/events/address/address-created-event.d.ts +9 -0
  28. package/dist/notifications/events/address/address-created-event.js +14 -0
  29. package/dist/notifications/events/address/address-updated-event.d.ts +9 -0
  30. package/dist/notifications/events/address/address-updated-event.js +14 -0
  31. package/dist/notifications/events/address/index.d.ts +2 -0
  32. package/dist/notifications/events/address/index.js +18 -0
  33. package/dist/notifications/events/adjustment/adjustment-created-event.d.ts +9 -0
  34. package/dist/notifications/events/adjustment/adjustment-created-event.js +14 -0
  35. package/dist/notifications/events/adjustment/adjustment-updated-event.d.ts +9 -0
  36. package/dist/notifications/events/adjustment/adjustment-updated-event.js +14 -0
  37. package/dist/notifications/events/adjustment/index.d.ts +2 -0
  38. package/dist/notifications/events/adjustment/index.js +18 -0
  39. package/dist/notifications/events/business/business-created-event.d.ts +9 -0
  40. package/dist/notifications/events/business/business-created-event.js +14 -0
  41. package/dist/notifications/events/business/business-updated-event.d.ts +9 -0
  42. package/dist/notifications/events/business/business-updated-event.js +14 -0
  43. package/dist/notifications/events/business/index.d.ts +2 -0
  44. package/dist/notifications/events/business/index.js +18 -0
  45. package/dist/notifications/events/customer/customer-created-event.d.ts +9 -0
  46. package/dist/notifications/events/customer/customer-created-event.js +14 -0
  47. package/dist/notifications/events/customer/customer-updated-event.d.ts +9 -0
  48. package/dist/notifications/events/customer/customer-updated-event.js +14 -0
  49. package/dist/notifications/events/customer/index.d.ts +2 -0
  50. package/dist/notifications/events/customer/index.js +18 -0
  51. package/dist/notifications/events/discount/discount-created-event.d.ts +9 -0
  52. package/dist/notifications/events/discount/discount-created-event.js +14 -0
  53. package/dist/notifications/events/discount/discount-imported-event.d.ts +9 -0
  54. package/dist/notifications/events/discount/discount-imported-event.js +14 -0
  55. package/dist/notifications/events/discount/discount-updated-event.d.ts +9 -0
  56. package/dist/notifications/events/discount/discount-updated-event.js +14 -0
  57. package/dist/notifications/events/discount/index.d.ts +3 -0
  58. package/dist/notifications/events/discount/index.js +19 -0
  59. package/dist/notifications/events/index.d.ts +10 -0
  60. package/dist/notifications/events/index.js +26 -0
  61. package/dist/notifications/events/payout/index.d.ts +2 -0
  62. package/dist/notifications/events/payout/index.js +18 -0
  63. package/dist/notifications/events/payout/payout-created-event.d.ts +9 -0
  64. package/dist/notifications/events/payout/payout-created-event.js +14 -0
  65. package/dist/notifications/events/payout/payout-paid-event.d.ts +9 -0
  66. package/dist/notifications/events/payout/payout-paid-event.js +14 -0
  67. package/dist/notifications/events/price/index.d.ts +2 -0
  68. package/dist/notifications/events/price/index.js +18 -0
  69. package/dist/notifications/events/price/price-created-event.d.ts +9 -0
  70. package/dist/notifications/events/price/price-created-event.js +14 -0
  71. package/dist/notifications/events/price/price-updated-event.d.ts +9 -0
  72. package/dist/notifications/events/price/price-updated-event.js +14 -0
  73. package/dist/notifications/events/product/index.d.ts +2 -0
  74. package/dist/notifications/events/product/index.js +18 -0
  75. package/dist/notifications/events/product/product-created-event.d.ts +9 -0
  76. package/dist/notifications/events/product/product-created-event.js +14 -0
  77. package/dist/notifications/events/product/product-updated-event.d.ts +9 -0
  78. package/dist/notifications/events/product/product-updated-event.js +14 -0
  79. package/dist/notifications/events/subscription/index.d.ts +9 -0
  80. package/dist/notifications/events/subscription/index.js +25 -0
  81. package/dist/notifications/events/subscription/subscription-activated-event.d.ts +9 -0
  82. package/dist/notifications/events/subscription/subscription-activated-event.js +14 -0
  83. package/dist/notifications/events/subscription/subscription-canceled-event.d.ts +9 -0
  84. package/dist/notifications/events/subscription/subscription-canceled-event.js +14 -0
  85. package/dist/notifications/events/subscription/subscription-created-event.d.ts +9 -0
  86. package/dist/notifications/events/subscription/subscription-created-event.js +14 -0
  87. package/dist/notifications/events/subscription/subscription-imported-event.d.ts +9 -0
  88. package/dist/notifications/events/subscription/subscription-imported-event.js +14 -0
  89. package/dist/notifications/events/subscription/subscription-past-due-event.d.ts +9 -0
  90. package/dist/notifications/events/subscription/subscription-past-due-event.js +14 -0
  91. package/dist/notifications/events/subscription/subscription-paused-event.d.ts +9 -0
  92. package/dist/notifications/events/subscription/subscription-paused-event.js +14 -0
  93. package/dist/notifications/events/subscription/subscription-resumed-event.d.ts +9 -0
  94. package/dist/notifications/events/subscription/subscription-resumed-event.js +14 -0
  95. package/dist/notifications/events/subscription/subscription-trialing-event.d.ts +9 -0
  96. package/dist/notifications/events/subscription/subscription-trialing-event.js +14 -0
  97. package/dist/notifications/events/subscription/subscription-updated-event.d.ts +9 -0
  98. package/dist/notifications/events/subscription/subscription-updated-event.js +14 -0
  99. package/dist/notifications/events/transaction/index.d.ts +9 -0
  100. package/dist/notifications/events/transaction/index.js +25 -0
  101. package/dist/notifications/events/transaction/transaction-billed-event.d.ts +9 -0
  102. package/dist/notifications/events/transaction/transaction-billed-event.js +14 -0
  103. package/dist/notifications/events/transaction/transaction-canceled-event.d.ts +9 -0
  104. package/dist/notifications/events/transaction/transaction-canceled-event.js +14 -0
  105. package/dist/notifications/events/transaction/transaction-completed-event.d.ts +9 -0
  106. package/dist/notifications/events/transaction/transaction-completed-event.js +14 -0
  107. package/dist/notifications/events/transaction/transaction-created-event.d.ts +9 -0
  108. package/dist/notifications/events/transaction/transaction-created-event.js +14 -0
  109. package/dist/notifications/events/transaction/transaction-paid-event.d.ts +9 -0
  110. package/dist/notifications/events/transaction/transaction-paid-event.js +14 -0
  111. package/dist/notifications/events/transaction/transaction-past-due-event.d.ts +9 -0
  112. package/dist/notifications/events/transaction/transaction-past-due-event.js +14 -0
  113. package/dist/notifications/events/transaction/transaction-payment-failed-event.d.ts +9 -0
  114. package/dist/notifications/events/transaction/transaction-payment-failed-event.js +14 -0
  115. package/dist/notifications/events/transaction/transaction-ready-event.d.ts +9 -0
  116. package/dist/notifications/events/transaction/transaction-ready-event.js +14 -0
  117. package/dist/notifications/events/transaction/transaction-updated-event.d.ts +9 -0
  118. package/dist/notifications/events/transaction/transaction-updated-event.js +14 -0
  119. package/dist/notifications/helpers/index.d.ts +3 -0
  120. package/dist/notifications/helpers/index.js +19 -0
  121. package/dist/notifications/helpers/types.d.ts +40 -0
  122. package/dist/notifications/helpers/types.js +41 -0
  123. package/dist/notifications/{validator/notifications-validator.d.ts → helpers/webhooks-validator.d.ts} +1 -1
  124. package/dist/notifications/{validator/notifications-validator.js → helpers/webhooks-validator.js} +6 -6
  125. package/dist/notifications/helpers/webhooks.d.ts +7 -0
  126. package/dist/notifications/helpers/webhooks.js +98 -0
  127. package/dist/notifications/index.d.ts +2 -1
  128. package/dist/notifications/index.js +2 -1
  129. package/dist/paddle.d.ts +5 -1
  130. package/dist/paddle.js +5 -1
  131. package/dist/resources/events/index.d.ts +7 -0
  132. package/dist/resources/events/index.js +30 -0
  133. package/dist/resources/events/operations/index.d.ts +1 -0
  134. package/dist/resources/events/operations/index.js +17 -0
  135. package/dist/resources/events/operations/list-events-query-parameters.d.ts +5 -0
  136. package/dist/resources/events/operations/list-events-query-parameters.js +2 -0
  137. package/dist/types/events/events-response.d.ts +125 -0
  138. package/dist/types/events/events-response.js +2 -0
  139. package/dist/types/events/index.d.ts +1 -0
  140. package/dist/types/events/index.js +17 -0
  141. package/dist/types/index.d.ts +2 -0
  142. package/dist/types/index.js +2 -0
  143. package/dist/types/payout/index.d.ts +1 -0
  144. package/dist/types/payout/index.js +17 -0
  145. package/dist/types/payout/payout-response.d.ts +7 -0
  146. package/dist/types/payout/payout-response.js +2 -0
  147. package/dist/types/subscription/index.d.ts +1 -0
  148. package/dist/types/subscription/index.js +1 -0
  149. package/dist/types/subscription/subscription-notification-response.d.ts +28 -0
  150. package/dist/types/subscription/subscription-notification-response.js +2 -0
  151. package/dist/version.d.ts +1 -1
  152. package/dist/version.js +1 -1
  153. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -8,6 +8,15 @@ 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.2 - 2023-12-01
12
+
13
+ ### Added
14
+
15
+ - Added `events.list()` to [list all events](https://developer.paddle.com/api-reference/events/list-events?utm_source=dx&utm_medium=paddle-node-sdk)
16
+ - Added helper function `paddle.webhooks.unmarshal` to [validate](https://developer.paddle.com/webhooks/signature-verification?utm_source=dx&utm_medium=paddle-node-sdk) and parse webhook events
17
+
18
+ ---
19
+
11
20
  ## 0.2.1 - 2023-11-29
12
21
 
13
22
  ### Added
@@ -19,6 +28,8 @@ Check our main [developer changelog](https://developer.paddle.com/?utm_source=dx
19
28
 
20
29
  - **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
30
 
31
+ ---
32
+
22
33
  ## 0.2.0 - 2023-11-28
23
34
 
24
35
  > **Breaking changes:** This version includes major improvements that introduce breaking changes. These are called out below.
package/README.md CHANGED
@@ -222,10 +222,49 @@ console.log('Product', product)
222
222
  The SDK includes a helper function to verify webhook signatures sent by Notifications from Paddle.
223
223
 
224
224
  ```typescript
225
- import { NotificationsValidator } from '@paddle/paddle-node-sdk'
225
+ import { Paddle, EventName } from '@paddle/paddle-node-sdk'
226
+ import express, { Request, Response } from 'express'
226
227
 
228
+ const paddle = new Paddle('API_KEY')
229
+ const app = express()
230
+
231
+ // Create a `POST` endpoint to accept webhooks sent by Paddle.
232
+ // We need `raw` request body to validate the integrity. Use express raw middleware to ensure express doesn't convert the request body to JSON.
233
+ app.post('/webhooks', express.raw({ type: 'application/json' }), (req: Request, res: Response) => {
234
+ const signature = (req.headers['paddle-signature'] as string) || '';
235
+ // req.body should be of type `buffer`, convert to string before passing it to `unmarshal`.
236
+ // If express returned a JSON, remove any other middleware that might have processed raw request to object
237
+ const rawRequestBody = req.body.toString();
238
+ // Replace with `PRIVATE_KEY` from vendor dashboard
239
+ const privateKey = process.env['PRIVATE_KEY'] || '';
240
+
241
+ try {
242
+ if (signature && rawRequestBody) {
243
+ // The `unmarshal` function will validate the integrity of the webhook and return an entity
244
+ const eventData = paddle.webhooks.unmarshal(rawRequestBody, privateKey, signature);
245
+ switch (eventData.eventType) {
246
+ case EventName.ProductUpdated:
247
+ console.log(`Product ${eventData.data.id} was updated`);
248
+ break;
249
+ case EventName.SubscriptionUpdated:
250
+ console.log(`Subscription ${eventData.data.id} was updated`);
251
+ break;
252
+ default:
253
+ console.log(eventData.eventType);
254
+ }
255
+ } else {
256
+ console.log('Signature missing in header');
257
+ }
258
+ } catch (e) {
259
+ // Handle signature mismatch or other runtime errors
260
+ console.log(e);
261
+ }
262
+ // Return a response to acknowledge
263
+ res.send('Processed webhook event');
264
+ });
265
+
266
+ app.listen(3000)
227
267
 
228
- const isValid = new NotificationsValidator().isValidSignature('RAW_UNFORMATTED_REQUEST_BODY', 'PRIVATE_KEY_FROM_DASHBOARD', 'SIGNATURE_FROM_RESPONSE_HEADER')
229
268
  ```
230
269
 
231
270
  ## Feature parity
@@ -293,8 +332,8 @@ This table shows which operations are available as of the latest release.
293
332
  | Preview prices | ✅ |
294
333
  | **Event types** | **None** |
295
334
  | List event types | ❌ |
296
- | **Events** | **None** |
297
- | List events | ❌ |
335
+ | **Events** | **Full** |
336
+ | List events | ✅ |
298
337
  | **Notification settings** | **None** |
299
338
  | List notification settings | ❌ |
300
339
  | Create a notification setting | ❌ |
@@ -16,7 +16,7 @@ export declare class Discount {
16
16
  readonly restrictTo: string[] | null;
17
17
  readonly expiresAt: string | null;
18
18
  readonly customData: CustomData | null;
19
- readonly timesUsed: number;
19
+ readonly timesUsed: number | null;
20
20
  readonly createdAt: string;
21
21
  readonly updatedAt: string;
22
22
  constructor(discount: IDiscountResponse);
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Discount = void 0;
4
4
  class Discount {
5
5
  constructor(discount) {
6
+ var _a;
6
7
  this.id = discount.id;
7
8
  this.status = discount.status;
8
9
  this.description = discount.description;
@@ -17,7 +18,7 @@ class Discount {
17
18
  this.restrictTo = discount.restrict_to ? discount.restrict_to : null;
18
19
  this.expiresAt = discount.expires_at ? discount.expires_at : null;
19
20
  this.customData = discount.custom_data ? discount.custom_data : null;
20
- this.timesUsed = discount.times_used;
21
+ this.timesUsed = (_a = discount.times_used) !== null && _a !== void 0 ? _a : null;
21
22
  this.createdAt = discount.created_at;
22
23
  this.updatedAt = discount.updated_at;
23
24
  }
@@ -0,0 +1,6 @@
1
+ import { Collection } from '../../internal/base';
2
+ import { type IEvents, type IEventsResponse } from '../../types';
3
+ import { type EventEntity } from '../../notifications';
4
+ export declare class EventCollection extends Collection<IEventsResponse, EventEntity> {
5
+ fromJson(data: IEvents): EventEntity;
6
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EventCollection = void 0;
4
+ const base_1 = require("../../internal/base");
5
+ const notifications_1 = require("../../notifications");
6
+ class EventCollection extends base_1.Collection {
7
+ fromJson(data) {
8
+ return notifications_1.Webhooks.fromJson(data);
9
+ }
10
+ }
11
+ exports.EventCollection = EventCollection;
@@ -0,0 +1,9 @@
1
+ import { type IEventsResponse } from '../../types';
2
+ export declare class Event {
3
+ eventId: string;
4
+ notificationId: string | null;
5
+ eventType: string;
6
+ occurredAt: string;
7
+ data: object;
8
+ constructor(eventData: IEventsResponse);
9
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Event = void 0;
4
+ class Event {
5
+ constructor(eventData) {
6
+ var _a;
7
+ this.eventId = eventData.event_id;
8
+ this.notificationId = (_a = eventData.notification_id) !== null && _a !== void 0 ? _a : null;
9
+ this.eventType = eventData.event_type;
10
+ this.occurredAt = eventData.occurred_at;
11
+ this.data = eventData.data;
12
+ }
13
+ }
14
+ exports.Event = Event;
@@ -0,0 +1 @@
1
+ export * from './event-collection';
@@ -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("./event-collection"), exports);
@@ -8,4 +8,6 @@ export * from './business';
8
8
  export * from './subscription';
9
9
  export * from './address';
10
10
  export * from './discount';
11
+ export * from './events';
12
+ export * from './payout';
11
13
  export type CustomData = object;
@@ -24,3 +24,5 @@ __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("./events"), exports);
28
+ __exportStar(require("./payout"), exports);
@@ -0,0 +1 @@
1
+ export * from './payout';
@@ -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("./payout"), exports);
@@ -0,0 +1,9 @@
1
+ import { type IPayoutResponse } from '../../types';
2
+ import { type CurrencyCode, type PayoutStatus } from '../../enums';
3
+ export declare class Payout {
4
+ readonly id: string;
5
+ readonly status: PayoutStatus;
6
+ readonly amount: string;
7
+ readonly currencyCode: CurrencyCode;
8
+ constructor(payout: IPayoutResponse);
9
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Payout = void 0;
4
+ class Payout {
5
+ constructor(payout) {
6
+ this.id = payout.id;
7
+ this.status = payout.status;
8
+ this.amount = payout.amount;
9
+ this.currencyCode = payout.currency_code;
10
+ }
11
+ }
12
+ exports.Payout = Payout;
@@ -15,3 +15,4 @@ export * from './subscription-preview-update-summary';
15
15
  export * from './subscription-preview-summary-result';
16
16
  export * from './next-transaction-adjustment-preview';
17
17
  export * from './next-transaction-adjustment-item';
18
+ export * from './subscription-notification';
@@ -31,3 +31,4 @@ __exportStar(require("./subscription-preview-update-summary"), exports);
31
31
  __exportStar(require("./subscription-preview-summary-result"), exports);
32
32
  __exportStar(require("./next-transaction-adjustment-preview"), exports);
33
33
  __exportStar(require("./next-transaction-adjustment-item"), exports);
34
+ __exportStar(require("./subscription-notification"), exports);
@@ -0,0 +1,28 @@
1
+ import { BillingDetails, type CustomData, SubscriptionDiscount, SubscriptionItem, SubscriptionScheduledChange, SubscriptionTimePeriod, TimePeriod } from '../index';
2
+ import { type CollectionMode, type CurrencyCode, type SubscriptionStatus } from '../../enums';
3
+ import { type ISubscriptionNotificationResponse } from '../../types';
4
+ export declare class SubscriptionNotification {
5
+ readonly id: string;
6
+ readonly status: SubscriptionStatus;
7
+ readonly transactionId: string | null;
8
+ readonly customerId: string;
9
+ readonly addressId: string;
10
+ readonly businessId: string | null;
11
+ readonly currencyCode: CurrencyCode;
12
+ readonly createdAt: string;
13
+ readonly updatedAt: string;
14
+ readonly startedAt: string | null;
15
+ readonly firstBilledAt: string | null;
16
+ readonly nextBilledAt: string | null;
17
+ readonly pausedAt: string | null;
18
+ readonly canceledAt: string | null;
19
+ readonly discount: SubscriptionDiscount | null;
20
+ readonly collectionMode: CollectionMode;
21
+ readonly billingDetails: BillingDetails | null;
22
+ readonly currentBillingPeriod: SubscriptionTimePeriod | null;
23
+ readonly billingCycle: TimePeriod;
24
+ readonly scheduledChange: SubscriptionScheduledChange | null;
25
+ readonly items: SubscriptionItem[];
26
+ readonly customData: CustomData | null;
27
+ constructor(subscription: ISubscriptionNotificationResponse);
28
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SubscriptionNotification = void 0;
4
+ const index_1 = require("../index");
5
+ class SubscriptionNotification {
6
+ constructor(subscription) {
7
+ this.id = subscription.id;
8
+ this.status = subscription.status;
9
+ this.transactionId = subscription.transaction_id ? subscription.transaction_id : null;
10
+ this.customerId = subscription.customer_id;
11
+ this.addressId = subscription.address_id;
12
+ this.businessId = subscription.business_id ? subscription.business_id : null;
13
+ this.currencyCode = subscription.currency_code;
14
+ this.createdAt = subscription.created_at;
15
+ this.updatedAt = subscription.updated_at;
16
+ this.startedAt = subscription.started_at ? subscription.started_at : null;
17
+ this.firstBilledAt = subscription.first_billed_at ? subscription.first_billed_at : null;
18
+ this.nextBilledAt = subscription.next_billed_at ? subscription.next_billed_at : null;
19
+ this.pausedAt = subscription.paused_at ? subscription.paused_at : null;
20
+ this.canceledAt = subscription.canceled_at ? subscription.canceled_at : null;
21
+ this.discount = subscription.discount ? new index_1.SubscriptionDiscount(subscription.discount) : null;
22
+ this.collectionMode = subscription.collection_mode;
23
+ this.billingDetails = subscription.billing_details ? new index_1.BillingDetails(subscription.billing_details) : null;
24
+ this.currentBillingPeriod = subscription.current_billing_period
25
+ ? new index_1.SubscriptionTimePeriod(subscription.current_billing_period)
26
+ : null;
27
+ this.billingCycle = new index_1.TimePeriod(subscription.billing_cycle);
28
+ this.scheduledChange = subscription.scheduled_change
29
+ ? new index_1.SubscriptionScheduledChange(subscription.scheduled_change)
30
+ : null;
31
+ this.items = subscription.items.map((item) => new index_1.SubscriptionItem(item));
32
+ this.customData = subscription.custom_data ? subscription.custom_data : null;
33
+ }
34
+ }
35
+ exports.SubscriptionNotification = SubscriptionNotification;
@@ -3,3 +3,4 @@ export * from './subscription';
3
3
  export * from './discount';
4
4
  export * from './adjustment';
5
5
  export * from './transaction';
6
+ export * from './payout';
@@ -19,3 +19,4 @@ __exportStar(require("./subscription"), exports);
19
19
  __exportStar(require("./discount"), exports);
20
20
  __exportStar(require("./adjustment"), exports);
21
21
  __exportStar(require("./transaction"), exports);
22
+ __exportStar(require("./payout"), exports);
@@ -0,0 +1 @@
1
+ export * from './payout-status';
@@ -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("./payout-status"), exports);
@@ -0,0 +1 @@
1
+ export type PayoutStatus = 'paid' | 'unpaid';
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,9 @@
1
+ import { Address } from '../../../entities';
2
+ import { type IAddressResponse, type IEventsResponse } from '../../../types';
3
+ import { EventName } from '../../helpers';
4
+ import { Event } from '../../../entities/events/event';
5
+ export declare class AddressCreatedEvent extends Event {
6
+ readonly eventType = EventName.AddressCreated;
7
+ readonly data: Address;
8
+ constructor(response: IEventsResponse<IAddressResponse>);
9
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AddressCreatedEvent = void 0;
4
+ const entities_1 = require("../../../entities");
5
+ const helpers_1 = require("../../helpers");
6
+ const event_1 = require("../../../entities/events/event");
7
+ class AddressCreatedEvent extends event_1.Event {
8
+ constructor(response) {
9
+ super(response);
10
+ this.eventType = helpers_1.EventName.AddressCreated;
11
+ this.data = new entities_1.Address(response.data);
12
+ }
13
+ }
14
+ exports.AddressCreatedEvent = AddressCreatedEvent;
@@ -0,0 +1,9 @@
1
+ import { Event } from '../../../entities/events/event';
2
+ import { Address } from '../../../entities';
3
+ import { type IAddressResponse, type IEventsResponse } from '../../../types';
4
+ import { EventName } from '../../helpers';
5
+ export declare class AddressUpdatedEvent extends Event {
6
+ readonly eventType = EventName.AddressUpdated;
7
+ readonly data: Address;
8
+ constructor(response: IEventsResponse<IAddressResponse>);
9
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AddressUpdatedEvent = void 0;
4
+ const event_1 = require("../../../entities/events/event");
5
+ const entities_1 = require("../../../entities");
6
+ const helpers_1 = require("../../helpers");
7
+ class AddressUpdatedEvent extends event_1.Event {
8
+ constructor(response) {
9
+ super(response);
10
+ this.eventType = helpers_1.EventName.AddressUpdated;
11
+ this.data = new entities_1.Address(response.data);
12
+ }
13
+ }
14
+ exports.AddressUpdatedEvent = AddressUpdatedEvent;
@@ -0,0 +1,2 @@
1
+ export * from './address-created-event';
2
+ export * from './address-updated-event';
@@ -0,0 +1,18 @@
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("./address-created-event"), exports);
18
+ __exportStar(require("./address-updated-event"), exports);
@@ -0,0 +1,9 @@
1
+ import { Event } from '../../../entities/events/event';
2
+ import { Adjustment } from '../../../entities';
3
+ import { type IAdjustmentResponse, type IEventsResponse } from '../../../types';
4
+ import { EventName } from '../../helpers';
5
+ export declare class AdjustmentCreatedEvent extends Event {
6
+ readonly eventType = EventName.AdjustmentCreated;
7
+ readonly data: Adjustment;
8
+ constructor(response: IEventsResponse<IAdjustmentResponse>);
9
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AdjustmentCreatedEvent = void 0;
4
+ const event_1 = require("../../../entities/events/event");
5
+ const entities_1 = require("../../../entities");
6
+ const helpers_1 = require("../../helpers");
7
+ class AdjustmentCreatedEvent extends event_1.Event {
8
+ constructor(response) {
9
+ super(response);
10
+ this.eventType = helpers_1.EventName.AdjustmentCreated;
11
+ this.data = new entities_1.Adjustment(response.data);
12
+ }
13
+ }
14
+ exports.AdjustmentCreatedEvent = AdjustmentCreatedEvent;
@@ -0,0 +1,9 @@
1
+ import { Event } from '../../../entities/events/event';
2
+ import { Adjustment } from '../../../entities';
3
+ import { type IAdjustmentResponse, type IEventsResponse } from '../../../types';
4
+ import { EventName } from '../../helpers';
5
+ export declare class AdjustmentUpdatedEvent extends Event {
6
+ readonly eventType = EventName.AdjustmentUpdated;
7
+ readonly data: Adjustment;
8
+ constructor(response: IEventsResponse<IAdjustmentResponse>);
9
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AdjustmentUpdatedEvent = void 0;
4
+ const event_1 = require("../../../entities/events/event");
5
+ const entities_1 = require("../../../entities");
6
+ const helpers_1 = require("../../helpers");
7
+ class AdjustmentUpdatedEvent extends event_1.Event {
8
+ constructor(response) {
9
+ super(response);
10
+ this.eventType = helpers_1.EventName.AdjustmentUpdated;
11
+ this.data = new entities_1.Adjustment(response.data);
12
+ }
13
+ }
14
+ exports.AdjustmentUpdatedEvent = AdjustmentUpdatedEvent;
@@ -0,0 +1,2 @@
1
+ export * from './adjustment-created-event';
2
+ export * from './adjustment-updated-event';
@@ -0,0 +1,18 @@
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("./adjustment-created-event"), exports);
18
+ __exportStar(require("./adjustment-updated-event"), exports);
@@ -0,0 +1,9 @@
1
+ import { Event } from '../../../entities/events/event';
2
+ import { Business } from '../../../entities';
3
+ import { type IBusinessResponse, type IEventsResponse } from '../../../types';
4
+ import { EventName } from '../../helpers';
5
+ export declare class BusinessCreatedEvent extends Event {
6
+ readonly eventType = EventName.BusinessCreated;
7
+ readonly data: Business;
8
+ constructor(response: IEventsResponse<IBusinessResponse>);
9
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BusinessCreatedEvent = void 0;
4
+ const event_1 = require("../../../entities/events/event");
5
+ const entities_1 = require("../../../entities");
6
+ const helpers_1 = require("../../helpers");
7
+ class BusinessCreatedEvent extends event_1.Event {
8
+ constructor(response) {
9
+ super(response);
10
+ this.eventType = helpers_1.EventName.BusinessCreated;
11
+ this.data = new entities_1.Business(response.data);
12
+ }
13
+ }
14
+ exports.BusinessCreatedEvent = BusinessCreatedEvent;
@@ -0,0 +1,9 @@
1
+ import { Event } from '../../../entities/events/event';
2
+ import { Business } from '../../../entities';
3
+ import { type IBusinessResponse, type IEventsResponse } from '../../../types';
4
+ import { EventName } from '../../helpers';
5
+ export declare class BusinessUpdatedEvent extends Event {
6
+ readonly eventType = EventName.BusinessUpdated;
7
+ readonly data: Business;
8
+ constructor(response: IEventsResponse<IBusinessResponse>);
9
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BusinessUpdatedEvent = void 0;
4
+ const event_1 = require("../../../entities/events/event");
5
+ const entities_1 = require("../../../entities");
6
+ const helpers_1 = require("../../helpers");
7
+ class BusinessUpdatedEvent extends event_1.Event {
8
+ constructor(response) {
9
+ super(response);
10
+ this.eventType = helpers_1.EventName.BusinessUpdated;
11
+ this.data = new entities_1.Business(response.data);
12
+ }
13
+ }
14
+ exports.BusinessUpdatedEvent = BusinessUpdatedEvent;
@@ -0,0 +1,2 @@
1
+ export * from './business-created-event';
2
+ export * from './business-updated-event';
@@ -0,0 +1,18 @@
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("./business-created-event"), exports);
18
+ __exportStar(require("./business-updated-event"), exports);
@@ -0,0 +1,9 @@
1
+ import { Event } from '../../../entities/events/event';
2
+ import { Customer } from '../../../entities';
3
+ import { type ICustomerResponse, type IEventsResponse } from '../../../types';
4
+ import { EventName } from '../../helpers';
5
+ export declare class CustomerCreatedEvent extends Event {
6
+ readonly eventType = EventName.CustomerCreated;
7
+ readonly data: Customer;
8
+ constructor(response: IEventsResponse<ICustomerResponse>);
9
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CustomerCreatedEvent = void 0;
4
+ const event_1 = require("../../../entities/events/event");
5
+ const entities_1 = require("../../../entities");
6
+ const helpers_1 = require("../../helpers");
7
+ class CustomerCreatedEvent extends event_1.Event {
8
+ constructor(response) {
9
+ super(response);
10
+ this.eventType = helpers_1.EventName.CustomerCreated;
11
+ this.data = new entities_1.Customer(response.data);
12
+ }
13
+ }
14
+ exports.CustomerCreatedEvent = CustomerCreatedEvent;