@paddle/paddle-node-sdk 0.2.1 → 0.2.3

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 (223) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.md +57 -18
  3. package/dist/entities/discount/discount.d.ts +1 -1
  4. package/dist/entities/discount/discount.js +2 -1
  5. package/dist/entities/event-types/event-type.d.ts +9 -0
  6. package/dist/entities/event-types/event-type.js +12 -0
  7. package/dist/entities/event-types/index.d.ts +1 -0
  8. package/dist/entities/event-types/index.js +17 -0
  9. package/dist/entities/events/event-collection.d.ts +6 -0
  10. package/dist/entities/events/event-collection.js +11 -0
  11. package/dist/entities/events/event.d.ts +9 -0
  12. package/dist/entities/events/event.js +14 -0
  13. package/dist/entities/events/index.d.ts +1 -0
  14. package/dist/entities/events/index.js +17 -0
  15. package/dist/entities/index.d.ts +5 -0
  16. package/dist/entities/index.js +5 -0
  17. package/dist/entities/notification-settings/index.d.ts +1 -0
  18. package/dist/entities/notification-settings/index.js +17 -0
  19. package/dist/entities/notification-settings/notification-settings.d.ts +15 -0
  20. package/dist/entities/notification-settings/notification-settings.js +18 -0
  21. package/dist/entities/notifications/index.d.ts +5 -0
  22. package/dist/entities/notifications/index.js +21 -0
  23. package/dist/entities/notifications/notification-collection.d.ts +6 -0
  24. package/dist/entities/notifications/notification-collection.js +11 -0
  25. package/dist/entities/notifications/notification-log-collection.d.ts +6 -0
  26. package/dist/entities/notifications/notification-log-collection.js +11 -0
  27. package/dist/entities/notifications/notification-log.d.ts +8 -0
  28. package/dist/entities/notifications/notification-log.js +14 -0
  29. package/dist/entities/notifications/notification.d.ts +18 -0
  30. package/dist/entities/notifications/notification.js +22 -0
  31. package/dist/entities/notifications/replay-notification.d.ts +5 -0
  32. package/dist/entities/notifications/replay-notification.js +9 -0
  33. package/dist/entities/payout/index.d.ts +1 -0
  34. package/dist/entities/payout/index.js +17 -0
  35. package/dist/entities/payout/payout.d.ts +9 -0
  36. package/dist/entities/payout/payout.js +12 -0
  37. package/dist/entities/subscription/index.d.ts +1 -0
  38. package/dist/entities/subscription/index.js +1 -0
  39. package/dist/entities/subscription/subscription-notification.d.ts +28 -0
  40. package/dist/entities/subscription/subscription-notification.js +35 -0
  41. package/dist/entities/subscription/subscription-scheduled-change.d.ts +2 -2
  42. package/dist/enums/index.d.ts +3 -0
  43. package/dist/enums/index.js +3 -0
  44. package/dist/enums/notification/index.d.ts +2 -0
  45. package/dist/enums/notification/index.js +18 -0
  46. package/dist/enums/notification/notification-status.d.ts +1 -0
  47. package/dist/enums/notification/notification-status.js +2 -0
  48. package/dist/enums/notification/origin.d.ts +1 -0
  49. package/dist/enums/notification/origin.js +2 -0
  50. package/dist/enums/notification-settings/index.d.ts +1 -0
  51. package/dist/enums/notification-settings/index.js +17 -0
  52. package/dist/enums/notification-settings/notification-settings-type.d.ts +1 -0
  53. package/dist/enums/notification-settings/notification-settings-type.js +2 -0
  54. package/dist/enums/payout/index.d.ts +1 -0
  55. package/dist/enums/payout/index.js +17 -0
  56. package/dist/enums/payout/payout-status.d.ts +1 -0
  57. package/dist/enums/payout/payout-status.js +2 -0
  58. package/dist/internal/api/client.d.ts +2 -0
  59. package/dist/internal/api/client.js +14 -0
  60. package/dist/notifications/events/address/address-created-event.d.ts +9 -0
  61. package/dist/notifications/events/address/address-created-event.js +14 -0
  62. package/dist/notifications/events/address/address-updated-event.d.ts +9 -0
  63. package/dist/notifications/events/address/address-updated-event.js +14 -0
  64. package/dist/notifications/events/address/index.d.ts +2 -0
  65. package/dist/notifications/events/address/index.js +18 -0
  66. package/dist/notifications/events/adjustment/adjustment-created-event.d.ts +9 -0
  67. package/dist/notifications/events/adjustment/adjustment-created-event.js +14 -0
  68. package/dist/notifications/events/adjustment/adjustment-updated-event.d.ts +9 -0
  69. package/dist/notifications/events/adjustment/adjustment-updated-event.js +14 -0
  70. package/dist/notifications/events/adjustment/index.d.ts +2 -0
  71. package/dist/notifications/events/adjustment/index.js +18 -0
  72. package/dist/notifications/events/business/business-created-event.d.ts +9 -0
  73. package/dist/notifications/events/business/business-created-event.js +14 -0
  74. package/dist/notifications/events/business/business-updated-event.d.ts +9 -0
  75. package/dist/notifications/events/business/business-updated-event.js +14 -0
  76. package/dist/notifications/events/business/index.d.ts +2 -0
  77. package/dist/notifications/events/business/index.js +18 -0
  78. package/dist/notifications/events/customer/customer-created-event.d.ts +9 -0
  79. package/dist/notifications/events/customer/customer-created-event.js +14 -0
  80. package/dist/notifications/events/customer/customer-updated-event.d.ts +9 -0
  81. package/dist/notifications/events/customer/customer-updated-event.js +14 -0
  82. package/dist/notifications/events/customer/index.d.ts +2 -0
  83. package/dist/notifications/events/customer/index.js +18 -0
  84. package/dist/notifications/events/discount/discount-created-event.d.ts +9 -0
  85. package/dist/notifications/events/discount/discount-created-event.js +14 -0
  86. package/dist/notifications/events/discount/discount-imported-event.d.ts +9 -0
  87. package/dist/notifications/events/discount/discount-imported-event.js +14 -0
  88. package/dist/notifications/events/discount/discount-updated-event.d.ts +9 -0
  89. package/dist/notifications/events/discount/discount-updated-event.js +14 -0
  90. package/dist/notifications/events/discount/index.d.ts +3 -0
  91. package/dist/notifications/events/discount/index.js +19 -0
  92. package/dist/notifications/events/index.d.ts +10 -0
  93. package/dist/notifications/events/index.js +26 -0
  94. package/dist/notifications/events/payout/index.d.ts +2 -0
  95. package/dist/notifications/events/payout/index.js +18 -0
  96. package/dist/notifications/events/payout/payout-created-event.d.ts +9 -0
  97. package/dist/notifications/events/payout/payout-created-event.js +14 -0
  98. package/dist/notifications/events/payout/payout-paid-event.d.ts +9 -0
  99. package/dist/notifications/events/payout/payout-paid-event.js +14 -0
  100. package/dist/notifications/events/price/index.d.ts +2 -0
  101. package/dist/notifications/events/price/index.js +18 -0
  102. package/dist/notifications/events/price/price-created-event.d.ts +9 -0
  103. package/dist/notifications/events/price/price-created-event.js +14 -0
  104. package/dist/notifications/events/price/price-updated-event.d.ts +9 -0
  105. package/dist/notifications/events/price/price-updated-event.js +14 -0
  106. package/dist/notifications/events/product/index.d.ts +2 -0
  107. package/dist/notifications/events/product/index.js +18 -0
  108. package/dist/notifications/events/product/product-created-event.d.ts +9 -0
  109. package/dist/notifications/events/product/product-created-event.js +14 -0
  110. package/dist/notifications/events/product/product-updated-event.d.ts +9 -0
  111. package/dist/notifications/events/product/product-updated-event.js +14 -0
  112. package/dist/notifications/events/subscription/index.d.ts +9 -0
  113. package/dist/notifications/events/subscription/index.js +25 -0
  114. package/dist/notifications/events/subscription/subscription-activated-event.d.ts +9 -0
  115. package/dist/notifications/events/subscription/subscription-activated-event.js +14 -0
  116. package/dist/notifications/events/subscription/subscription-canceled-event.d.ts +9 -0
  117. package/dist/notifications/events/subscription/subscription-canceled-event.js +14 -0
  118. package/dist/notifications/events/subscription/subscription-created-event.d.ts +9 -0
  119. package/dist/notifications/events/subscription/subscription-created-event.js +14 -0
  120. package/dist/notifications/events/subscription/subscription-imported-event.d.ts +9 -0
  121. package/dist/notifications/events/subscription/subscription-imported-event.js +14 -0
  122. package/dist/notifications/events/subscription/subscription-past-due-event.d.ts +9 -0
  123. package/dist/notifications/events/subscription/subscription-past-due-event.js +14 -0
  124. package/dist/notifications/events/subscription/subscription-paused-event.d.ts +9 -0
  125. package/dist/notifications/events/subscription/subscription-paused-event.js +14 -0
  126. package/dist/notifications/events/subscription/subscription-resumed-event.d.ts +9 -0
  127. package/dist/notifications/events/subscription/subscription-resumed-event.js +14 -0
  128. package/dist/notifications/events/subscription/subscription-trialing-event.d.ts +9 -0
  129. package/dist/notifications/events/subscription/subscription-trialing-event.js +14 -0
  130. package/dist/notifications/events/subscription/subscription-updated-event.d.ts +9 -0
  131. package/dist/notifications/events/subscription/subscription-updated-event.js +14 -0
  132. package/dist/notifications/events/transaction/index.d.ts +9 -0
  133. package/dist/notifications/events/transaction/index.js +25 -0
  134. package/dist/notifications/events/transaction/transaction-billed-event.d.ts +9 -0
  135. package/dist/notifications/events/transaction/transaction-billed-event.js +14 -0
  136. package/dist/notifications/events/transaction/transaction-canceled-event.d.ts +9 -0
  137. package/dist/notifications/events/transaction/transaction-canceled-event.js +14 -0
  138. package/dist/notifications/events/transaction/transaction-completed-event.d.ts +9 -0
  139. package/dist/notifications/events/transaction/transaction-completed-event.js +14 -0
  140. package/dist/notifications/events/transaction/transaction-created-event.d.ts +9 -0
  141. package/dist/notifications/events/transaction/transaction-created-event.js +14 -0
  142. package/dist/notifications/events/transaction/transaction-paid-event.d.ts +9 -0
  143. package/dist/notifications/events/transaction/transaction-paid-event.js +14 -0
  144. package/dist/notifications/events/transaction/transaction-past-due-event.d.ts +9 -0
  145. package/dist/notifications/events/transaction/transaction-past-due-event.js +14 -0
  146. package/dist/notifications/events/transaction/transaction-payment-failed-event.d.ts +9 -0
  147. package/dist/notifications/events/transaction/transaction-payment-failed-event.js +14 -0
  148. package/dist/notifications/events/transaction/transaction-ready-event.d.ts +9 -0
  149. package/dist/notifications/events/transaction/transaction-ready-event.js +14 -0
  150. package/dist/notifications/events/transaction/transaction-updated-event.d.ts +9 -0
  151. package/dist/notifications/events/transaction/transaction-updated-event.js +14 -0
  152. package/dist/notifications/helpers/index.d.ts +3 -0
  153. package/dist/notifications/helpers/index.js +19 -0
  154. package/dist/notifications/helpers/types.d.ts +40 -0
  155. package/dist/notifications/helpers/types.js +41 -0
  156. package/dist/notifications/{validator/notifications-validator.d.ts → helpers/webhooks-validator.d.ts} +1 -1
  157. package/dist/notifications/{validator/notifications-validator.js → helpers/webhooks-validator.js} +6 -6
  158. package/dist/notifications/helpers/webhooks.d.ts +7 -0
  159. package/dist/notifications/helpers/webhooks.js +100 -0
  160. package/dist/notifications/index.d.ts +2 -1
  161. package/dist/notifications/index.js +2 -1
  162. package/dist/paddle.d.ts +9 -2
  163. package/dist/paddle.js +8 -1
  164. package/dist/resources/event-types/index.d.ts +5 -0
  165. package/dist/resources/event-types/index.js +27 -0
  166. package/dist/resources/events/index.d.ts +7 -0
  167. package/dist/resources/events/index.js +30 -0
  168. package/dist/resources/events/operations/index.d.ts +1 -0
  169. package/dist/resources/events/operations/index.js +17 -0
  170. package/dist/resources/events/operations/list-events-query-parameters.d.ts +5 -0
  171. package/dist/resources/events/operations/list-events-query-parameters.js +2 -0
  172. package/dist/resources/index.d.ts +3 -0
  173. package/dist/resources/index.js +3 -0
  174. package/dist/resources/notification-settings/index.d.ts +11 -0
  175. package/dist/resources/notification-settings/index.js +84 -0
  176. package/dist/resources/notification-settings/operations/create-notification-settings-request-body.d.ts +10 -0
  177. package/dist/resources/notification-settings/operations/create-notification-settings-request-body.js +2 -0
  178. package/dist/resources/notification-settings/operations/index.d.ts +2 -0
  179. package/dist/resources/notification-settings/operations/index.js +18 -0
  180. package/dist/resources/notification-settings/operations/update-notification-settings-request-body.d.ts +9 -0
  181. package/dist/resources/notification-settings/operations/update-notification-settings-request-body.js +2 -0
  182. package/dist/resources/notifications/index.d.ts +10 -0
  183. package/dist/resources/notifications/index.js +69 -0
  184. package/dist/resources/notifications/operations/index.d.ts +2 -0
  185. package/dist/resources/notifications/operations/index.js +18 -0
  186. package/dist/resources/notifications/operations/list-notification-log-query-parameters.d.ts +4 -0
  187. package/dist/resources/notifications/operations/list-notification-log-query-parameters.js +2 -0
  188. package/dist/resources/notifications/operations/list-notification-query-parameters.d.ts +12 -0
  189. package/dist/resources/notifications/operations/list-notification-query-parameters.js +2 -0
  190. package/dist/types/event-types/event-type-response.d.ts +7 -0
  191. package/dist/types/event-types/event-type-response.js +2 -0
  192. package/dist/types/event-types/index.d.ts +1 -0
  193. package/dist/types/event-types/index.js +17 -0
  194. package/dist/types/events/events-response.d.ts +125 -0
  195. package/dist/types/events/events-response.js +2 -0
  196. package/dist/types/events/index.d.ts +1 -0
  197. package/dist/types/events/index.js +17 -0
  198. package/dist/types/index.d.ts +5 -0
  199. package/dist/types/index.js +5 -0
  200. package/dist/types/notification-settings/index.d.ts +1 -0
  201. package/dist/types/notification-settings/index.js +17 -0
  202. package/dist/types/notification-settings/notification-settings-response.d.ts +13 -0
  203. package/dist/types/notification-settings/notification-settings-response.js +2 -0
  204. package/dist/types/notifications/index.d.ts +3 -0
  205. package/dist/types/notifications/index.js +19 -0
  206. package/dist/types/notifications/notification-log.d.ts +7 -0
  207. package/dist/types/notifications/notification-log.js +2 -0
  208. package/dist/types/notifications/notification.d.ts +17 -0
  209. package/dist/types/notifications/notification.js +2 -0
  210. package/dist/types/notifications/replay-notification.d.ts +3 -0
  211. package/dist/types/notifications/replay-notification.js +2 -0
  212. package/dist/types/payout/index.d.ts +1 -0
  213. package/dist/types/payout/index.js +17 -0
  214. package/dist/types/payout/payout-response.d.ts +7 -0
  215. package/dist/types/payout/payout-response.js +2 -0
  216. package/dist/types/subscription/index.d.ts +1 -0
  217. package/dist/types/subscription/index.js +1 -0
  218. package/dist/types/subscription/subscription-notification-response.d.ts +28 -0
  219. package/dist/types/subscription/subscription-notification-response.js +2 -0
  220. package/dist/types/subscription/subscription-scheduled-change-response.d.ts +2 -2
  221. package/dist/version.d.ts +1 -1
  222. package/dist/version.js +1 -1
  223. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -8,6 +8,37 @@ 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.3 - 2023-12-12
12
+
13
+ ### Added
14
+
15
+ - Added `eventTypes.list()` to [list all event types](https://developer.paddle.com/api-reference/event-types/list-event-types?utm_source=dx&utm_medium=paddle-node-sdk)
16
+ - Added `notificationSettings.list()` to [list all notification settings](https://developer.paddle.com/api-reference/notification-settings/list-notification-settings?utm_source=dx&utm_medium=paddle-node-sdk)
17
+ - Added `notificationSettings.create()` to [create a notification settings](https://developer.paddle.com/api-reference/notification-settings/create-notification-setting?utm_source=dx&utm_medium=paddle-node-sdk)
18
+ - Added `notificationSettings.get()` to [get a notification settings](https://developer.paddle.com/api-reference/notification-settings/get-notification-setting?utm_source=dx&utm_medium=paddle-node-sdk)
19
+ - Added `notificationSettings.update()` to [update a notification settings](https://developer.paddle.com/api-reference/notification-settings/update-notification-setting?utm_source=dx&utm_medium=paddle-node-sdk)
20
+ - Added `notificationSettings.delete()` to [delete a notification settings](https://developer.paddle.com/api-reference/notification-settings/delete-notification-setting?utm_source=dx&utm_medium=paddle-node-sdk)
21
+ - Added `notifications.list()` to [list all notifications](https://developer.paddle.com/api-reference/notifications/list-notifications?utm_source=dx&utm_medium=paddle-node-sdk)
22
+ - Added `notifications.get()` to [get a notification](https://developer.paddle.com/api-reference/notifications/get-notification?utm_source=dx&utm_medium=paddle-node-sdk)
23
+ - Added `notifications.replay()` to [replay a notification](https://developer.paddle.com/api-reference/notifications/replay-notification?utm_source=dx&utm_medium=paddle-node-sdk)
24
+ - Added `notifications.getLogs()` to [get all logs for a notification](https://developer.paddle.com/api-reference/notification-logs/list-notification-logs?utm_source=dx&utm_medium=paddle-node-sdk)
25
+
26
+
27
+ ### Fixed
28
+
29
+ - Fixed incorrect type of `action` in `subscriptions.scheduled_change`
30
+
31
+ ---
32
+
33
+ ## 0.2.2 - 2023-12-01
34
+
35
+ ### Added
36
+
37
+ - Added `events.list()` to [list all events](https://developer.paddle.com/api-reference/events/list-events?utm_source=dx&utm_medium=paddle-node-sdk)
38
+ - 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
39
+
40
+ ---
41
+
11
42
  ## 0.2.1 - 2023-11-29
12
43
 
13
44
  ### Added
@@ -19,6 +50,8 @@ Check our main [developer changelog](https://developer.paddle.com/?utm_source=dx
19
50
 
20
51
  - **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
52
 
53
+ ---
54
+
22
55
  ## 0.2.0 - 2023-11-28
23
56
 
24
57
  > **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
@@ -291,22 +330,22 @@ This table shows which operations are available as of the latest release.
291
330
  | Create an adjustment | ✅ |
292
331
  | **Pricing preview** | **Full** |
293
332
  | Preview prices | ✅ |
294
- | **Event types** | **None** |
295
- | List event types | ❌ |
296
- | **Events** | **None** |
297
- | List events | ❌ |
298
- | **Notification settings** | **None** |
299
- | List notification settings | ❌ |
300
- | Create a notification setting | ❌ |
301
- | Get a notification setting | ❌ |
302
- | Update a notification setting | ❌ |
303
- | Delete a notification setting | ❌ |
304
- | **Notifications** | **None** |
305
- | List notifications | ❌ |
306
- | Get a notification | ❌ |
307
- | Replay a notification | ❌ |
308
- | **Notification logs** | **None** |
309
- | List logs for a notification | ❌ |
333
+ | **Event types** | **Full** |
334
+ | List event types | ✅ |
335
+ | **Events** | **Full** |
336
+ | List events | ✅ |
337
+ | **Notification settings** | **Full** |
338
+ | List notification settings | ✅ |
339
+ | Create a notification setting | ✅ |
340
+ | Get a notification setting | ✅ |
341
+ | Update a notification setting | ✅ |
342
+ | Delete a notification setting | ✅ |
343
+ | **Notifications** | **Full** |
344
+ | List notifications | ✅ |
345
+ | Get a notification | ✅ |
346
+ | Replay a notification | ✅ |
347
+ | **Notification logs** | **Full** |
348
+ | List logs for a notification | ✅ |
310
349
 
311
350
  ## Learn more
312
351
 
@@ -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,9 @@
1
+ import { type IEventTypeResponse } from '../../types';
2
+ import { type IEventName } from '../../notifications';
3
+ export declare class EventType {
4
+ readonly name: IEventName;
5
+ readonly description: string;
6
+ readonly group: string;
7
+ readonly availableVersions: number[];
8
+ constructor(eventType: IEventTypeResponse);
9
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EventType = void 0;
4
+ class EventType {
5
+ constructor(eventType) {
6
+ this.name = eventType.name;
7
+ this.description = eventType.description;
8
+ this.group = eventType.group;
9
+ this.availableVersions = eventType.available_versions;
10
+ }
11
+ }
12
+ exports.EventType = EventType;
@@ -0,0 +1 @@
1
+ export * from './event-type';
@@ -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-type"), exports);
@@ -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 | null> {
5
+ fromJson(data: IEvents): EventEntity | null;
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,9 @@ 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';
13
+ export * from './event-types';
14
+ export * from './notification-settings';
15
+ export * from './notifications';
11
16
  export type CustomData = object;
@@ -24,3 +24,8 @@ __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);
29
+ __exportStar(require("./event-types"), exports);
30
+ __exportStar(require("./notification-settings"), exports);
31
+ __exportStar(require("./notifications"), exports);
@@ -0,0 +1 @@
1
+ export * from './notification-settings';
@@ -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("./notification-settings"), exports);
@@ -0,0 +1,15 @@
1
+ import { type NotificationSettingsType } from '../../enums';
2
+ import { EventType } from '../event-types';
3
+ import { type INotificationSettingsResponse } from '../../types/notification-settings';
4
+ export declare class NotificationSettings {
5
+ readonly id: string;
6
+ readonly description: string;
7
+ readonly type: NotificationSettingsType;
8
+ readonly destination: string;
9
+ readonly active: boolean;
10
+ readonly apiVersion: number;
11
+ readonly includeSensitiveFields: boolean;
12
+ readonly subscribedEvents: EventType[];
13
+ readonly endpointSecretKey: string;
14
+ constructor(notificationSettings: INotificationSettingsResponse);
15
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NotificationSettings = void 0;
4
+ const event_types_1 = require("../event-types");
5
+ class NotificationSettings {
6
+ constructor(notificationSettings) {
7
+ this.id = notificationSettings.id;
8
+ this.description = notificationSettings.description;
9
+ this.type = notificationSettings.type;
10
+ this.destination = notificationSettings.destination;
11
+ this.active = notificationSettings.active;
12
+ this.apiVersion = notificationSettings.api_version;
13
+ this.includeSensitiveFields = notificationSettings.include_sensitive_fields;
14
+ this.subscribedEvents = notificationSettings.subscribed_events.map((subscribed_event) => new event_types_1.EventType(subscribed_event));
15
+ this.endpointSecretKey = notificationSettings.endpoint_secret_key;
16
+ }
17
+ }
18
+ exports.NotificationSettings = NotificationSettings;
@@ -0,0 +1,5 @@
1
+ export * from './notification';
2
+ export * from './notification-log';
3
+ export * from './notification-collection';
4
+ export * from './replay-notification';
5
+ export * from './notification-log-collection';
@@ -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("./notification"), exports);
18
+ __exportStar(require("./notification-log"), exports);
19
+ __exportStar(require("./notification-collection"), exports);
20
+ __exportStar(require("./replay-notification"), exports);
21
+ __exportStar(require("./notification-log-collection"), exports);
@@ -0,0 +1,6 @@
1
+ import { Collection } from '../../internal/base';
2
+ import { Notification } from './notification';
3
+ import { type INotificationResponse } from '../../types/notifications';
4
+ export declare class NotificationCollection extends Collection<INotificationResponse, Notification> {
5
+ fromJson(data: INotificationResponse): Notification;
6
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NotificationCollection = void 0;
4
+ const base_1 = require("../../internal/base");
5
+ const notification_1 = require("./notification");
6
+ class NotificationCollection extends base_1.Collection {
7
+ fromJson(data) {
8
+ return new notification_1.Notification(data);
9
+ }
10
+ }
11
+ exports.NotificationCollection = NotificationCollection;
@@ -0,0 +1,6 @@
1
+ import { Collection } from '../../internal/base';
2
+ import { type INotificationLogResponse } from '../../types';
3
+ import { NotificationLog } from './notification-log';
4
+ export declare class NotificationLogCollection extends Collection<INotificationLogResponse, NotificationLog> {
5
+ fromJson(data: INotificationLogResponse): NotificationLog;
6
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NotificationLogCollection = void 0;
4
+ const base_1 = require("../../internal/base");
5
+ const notification_log_1 = require("./notification-log");
6
+ class NotificationLogCollection extends base_1.Collection {
7
+ fromJson(data) {
8
+ return new notification_log_1.NotificationLog(data);
9
+ }
10
+ }
11
+ exports.NotificationLogCollection = NotificationLogCollection;
@@ -0,0 +1,8 @@
1
+ export declare class NotificationLog {
2
+ readonly id: string;
3
+ readonly responseCode: number;
4
+ readonly responseContentType: string | null;
5
+ readonly responseBody: string;
6
+ readonly attemptedAt: string;
7
+ constructor(notificationLogResponse: any);
8
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NotificationLog = void 0;
4
+ class NotificationLog {
5
+ constructor(notificationLogResponse) {
6
+ var _a;
7
+ this.id = notificationLogResponse.id;
8
+ this.responseCode = notificationLogResponse.response_code;
9
+ this.responseContentType = (_a = notificationLogResponse.response_content_type) !== null && _a !== void 0 ? _a : null;
10
+ this.responseBody = notificationLogResponse.response_body;
11
+ this.attemptedAt = notificationLogResponse.attempted_at;
12
+ }
13
+ }
14
+ exports.NotificationLog = NotificationLog;
@@ -0,0 +1,18 @@
1
+ import { type NotificationStatus, type Origin } from '../../enums';
2
+ import { type EventEntity, type IEventName } from '../../notifications';
3
+ import { type INotificationResponse } from '../../types';
4
+ export declare class Notification {
5
+ readonly id: string;
6
+ readonly type: IEventName;
7
+ readonly status: NotificationStatus;
8
+ readonly payload: EventEntity | null;
9
+ readonly occurredAt: string;
10
+ readonly deliveredAt: null | string;
11
+ readonly replayedAt: null | string;
12
+ readonly origin: Origin;
13
+ readonly lastAttemptAt: null | string;
14
+ readonly retryAt: null | string;
15
+ readonly timesAttempted: number;
16
+ readonly notificationSettingId: string;
17
+ constructor(notificationResponse: INotificationResponse);
18
+ }
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Notification = void 0;
4
+ const notifications_1 = require("../../notifications");
5
+ class Notification {
6
+ constructor(notificationResponse) {
7
+ var _a, _b, _c, _d;
8
+ this.id = notificationResponse.id;
9
+ this.type = notificationResponse.type;
10
+ this.status = notificationResponse.status;
11
+ this.payload = notifications_1.Webhooks.fromJson(notificationResponse.payload);
12
+ this.occurredAt = notificationResponse.occurred_at;
13
+ this.deliveredAt = (_a = notificationResponse.delivered_at) !== null && _a !== void 0 ? _a : null;
14
+ this.replayedAt = (_b = notificationResponse.replayed_at) !== null && _b !== void 0 ? _b : null;
15
+ this.origin = notificationResponse.origin;
16
+ this.lastAttemptAt = (_c = notificationResponse.last_attempt_at) !== null && _c !== void 0 ? _c : null;
17
+ this.retryAt = (_d = notificationResponse.retry_at) !== null && _d !== void 0 ? _d : null;
18
+ this.timesAttempted = notificationResponse.times_attempted;
19
+ this.notificationSettingId = notificationResponse.notification_setting_id;
20
+ }
21
+ }
22
+ exports.Notification = Notification;
@@ -0,0 +1,5 @@
1
+ import { type IReplayNotificationResponse } from '../../types/notifications';
2
+ export declare class ReplayNotification {
3
+ readonly notificationId: string;
4
+ constructor(notificationResponse: IReplayNotificationResponse);
5
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReplayNotification = void 0;
4
+ class ReplayNotification {
5
+ constructor(notificationResponse) {
6
+ this.notificationId = notificationResponse.notification_id;
7
+ }
8
+ }
9
+ exports.ReplayNotification = ReplayNotification;
@@ -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
+ }