@paddle/paddle-node-sdk 0.2.0 → 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 (201) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +90 -11
  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/pricing-preview/index.d.ts +4 -0
  18. package/dist/entities/pricing-preview/index.js +20 -0
  19. package/dist/entities/pricing-preview/pricing-preview-details.d.ts +6 -0
  20. package/dist/entities/pricing-preview/pricing-preview-details.js +10 -0
  21. package/dist/entities/pricing-preview/pricing-preview-discounts.d.ts +8 -0
  22. package/dist/entities/pricing-preview/pricing-preview-discounts.js +12 -0
  23. package/dist/entities/pricing-preview/pricing-preview-line-item.d.ts +17 -0
  24. package/dist/entities/pricing-preview/pricing-preview-line-item.js +21 -0
  25. package/dist/entities/pricing-preview/pricing-preview.d.ts +15 -0
  26. package/dist/entities/pricing-preview/pricing-preview.js +19 -0
  27. package/dist/entities/subscription/index.d.ts +1 -0
  28. package/dist/entities/subscription/index.js +1 -0
  29. package/dist/entities/subscription/subscription-notification.d.ts +28 -0
  30. package/dist/entities/subscription/subscription-notification.js +35 -0
  31. package/dist/enums/index.d.ts +1 -0
  32. package/dist/enums/index.js +1 -0
  33. package/dist/enums/payout/index.d.ts +1 -0
  34. package/dist/enums/payout/index.js +17 -0
  35. package/dist/enums/payout/payout-status.d.ts +1 -0
  36. package/dist/enums/payout/payout-status.js +2 -0
  37. package/dist/notifications/events/address/address-created-event.d.ts +9 -0
  38. package/dist/notifications/events/address/address-created-event.js +14 -0
  39. package/dist/notifications/events/address/address-updated-event.d.ts +9 -0
  40. package/dist/notifications/events/address/address-updated-event.js +14 -0
  41. package/dist/notifications/events/address/index.d.ts +2 -0
  42. package/dist/notifications/events/address/index.js +18 -0
  43. package/dist/notifications/events/adjustment/adjustment-created-event.d.ts +9 -0
  44. package/dist/notifications/events/adjustment/adjustment-created-event.js +14 -0
  45. package/dist/notifications/events/adjustment/adjustment-updated-event.d.ts +9 -0
  46. package/dist/notifications/events/adjustment/adjustment-updated-event.js +14 -0
  47. package/dist/notifications/events/adjustment/index.d.ts +2 -0
  48. package/dist/notifications/events/adjustment/index.js +18 -0
  49. package/dist/notifications/events/business/business-created-event.d.ts +9 -0
  50. package/dist/notifications/events/business/business-created-event.js +14 -0
  51. package/dist/notifications/events/business/business-updated-event.d.ts +9 -0
  52. package/dist/notifications/events/business/business-updated-event.js +14 -0
  53. package/dist/notifications/events/business/index.d.ts +2 -0
  54. package/dist/notifications/events/business/index.js +18 -0
  55. package/dist/notifications/events/customer/customer-created-event.d.ts +9 -0
  56. package/dist/notifications/events/customer/customer-created-event.js +14 -0
  57. package/dist/notifications/events/customer/customer-updated-event.d.ts +9 -0
  58. package/dist/notifications/events/customer/customer-updated-event.js +14 -0
  59. package/dist/notifications/events/customer/index.d.ts +2 -0
  60. package/dist/notifications/events/customer/index.js +18 -0
  61. package/dist/notifications/events/discount/discount-created-event.d.ts +9 -0
  62. package/dist/notifications/events/discount/discount-created-event.js +14 -0
  63. package/dist/notifications/events/discount/discount-imported-event.d.ts +9 -0
  64. package/dist/notifications/events/discount/discount-imported-event.js +14 -0
  65. package/dist/notifications/events/discount/discount-updated-event.d.ts +9 -0
  66. package/dist/notifications/events/discount/discount-updated-event.js +14 -0
  67. package/dist/notifications/events/discount/index.d.ts +3 -0
  68. package/dist/notifications/events/discount/index.js +19 -0
  69. package/dist/notifications/events/index.d.ts +10 -0
  70. package/dist/notifications/events/index.js +26 -0
  71. package/dist/notifications/events/payout/index.d.ts +2 -0
  72. package/dist/notifications/events/payout/index.js +18 -0
  73. package/dist/notifications/events/payout/payout-created-event.d.ts +9 -0
  74. package/dist/notifications/events/payout/payout-created-event.js +14 -0
  75. package/dist/notifications/events/payout/payout-paid-event.d.ts +9 -0
  76. package/dist/notifications/events/payout/payout-paid-event.js +14 -0
  77. package/dist/notifications/events/price/index.d.ts +2 -0
  78. package/dist/notifications/events/price/index.js +18 -0
  79. package/dist/notifications/events/price/price-created-event.d.ts +9 -0
  80. package/dist/notifications/events/price/price-created-event.js +14 -0
  81. package/dist/notifications/events/price/price-updated-event.d.ts +9 -0
  82. package/dist/notifications/events/price/price-updated-event.js +14 -0
  83. package/dist/notifications/events/product/index.d.ts +2 -0
  84. package/dist/notifications/events/product/index.js +18 -0
  85. package/dist/notifications/events/product/product-created-event.d.ts +9 -0
  86. package/dist/notifications/events/product/product-created-event.js +14 -0
  87. package/dist/notifications/events/product/product-updated-event.d.ts +9 -0
  88. package/dist/notifications/events/product/product-updated-event.js +14 -0
  89. package/dist/notifications/events/subscription/index.d.ts +9 -0
  90. package/dist/notifications/events/subscription/index.js +25 -0
  91. package/dist/notifications/events/subscription/subscription-activated-event.d.ts +9 -0
  92. package/dist/notifications/events/subscription/subscription-activated-event.js +14 -0
  93. package/dist/notifications/events/subscription/subscription-canceled-event.d.ts +9 -0
  94. package/dist/notifications/events/subscription/subscription-canceled-event.js +14 -0
  95. package/dist/notifications/events/subscription/subscription-created-event.d.ts +9 -0
  96. package/dist/notifications/events/subscription/subscription-created-event.js +14 -0
  97. package/dist/notifications/events/subscription/subscription-imported-event.d.ts +9 -0
  98. package/dist/notifications/events/subscription/subscription-imported-event.js +14 -0
  99. package/dist/notifications/events/subscription/subscription-past-due-event.d.ts +9 -0
  100. package/dist/notifications/events/subscription/subscription-past-due-event.js +14 -0
  101. package/dist/notifications/events/subscription/subscription-paused-event.d.ts +9 -0
  102. package/dist/notifications/events/subscription/subscription-paused-event.js +14 -0
  103. package/dist/notifications/events/subscription/subscription-resumed-event.d.ts +9 -0
  104. package/dist/notifications/events/subscription/subscription-resumed-event.js +14 -0
  105. package/dist/notifications/events/subscription/subscription-trialing-event.d.ts +9 -0
  106. package/dist/notifications/events/subscription/subscription-trialing-event.js +14 -0
  107. package/dist/notifications/events/subscription/subscription-updated-event.d.ts +9 -0
  108. package/dist/notifications/events/subscription/subscription-updated-event.js +14 -0
  109. package/dist/notifications/events/transaction/index.d.ts +9 -0
  110. package/dist/notifications/events/transaction/index.js +25 -0
  111. package/dist/notifications/events/transaction/transaction-billed-event.d.ts +9 -0
  112. package/dist/notifications/events/transaction/transaction-billed-event.js +14 -0
  113. package/dist/notifications/events/transaction/transaction-canceled-event.d.ts +9 -0
  114. package/dist/notifications/events/transaction/transaction-canceled-event.js +14 -0
  115. package/dist/notifications/events/transaction/transaction-completed-event.d.ts +9 -0
  116. package/dist/notifications/events/transaction/transaction-completed-event.js +14 -0
  117. package/dist/notifications/events/transaction/transaction-created-event.d.ts +9 -0
  118. package/dist/notifications/events/transaction/transaction-created-event.js +14 -0
  119. package/dist/notifications/events/transaction/transaction-paid-event.d.ts +9 -0
  120. package/dist/notifications/events/transaction/transaction-paid-event.js +14 -0
  121. package/dist/notifications/events/transaction/transaction-past-due-event.d.ts +9 -0
  122. package/dist/notifications/events/transaction/transaction-past-due-event.js +14 -0
  123. package/dist/notifications/events/transaction/transaction-payment-failed-event.d.ts +9 -0
  124. package/dist/notifications/events/transaction/transaction-payment-failed-event.js +14 -0
  125. package/dist/notifications/events/transaction/transaction-ready-event.d.ts +9 -0
  126. package/dist/notifications/events/transaction/transaction-ready-event.js +14 -0
  127. package/dist/notifications/events/transaction/transaction-updated-event.d.ts +9 -0
  128. package/dist/notifications/events/transaction/transaction-updated-event.js +14 -0
  129. package/dist/notifications/helpers/index.d.ts +3 -0
  130. package/dist/notifications/helpers/index.js +19 -0
  131. package/dist/notifications/helpers/types.d.ts +40 -0
  132. package/dist/notifications/helpers/types.js +41 -0
  133. package/dist/notifications/{validator/notifications-validator.d.ts → helpers/webhooks-validator.d.ts} +1 -1
  134. package/dist/notifications/{validator/notifications-validator.js → helpers/webhooks-validator.js} +6 -6
  135. package/dist/notifications/helpers/webhooks.d.ts +7 -0
  136. package/dist/notifications/helpers/webhooks.js +98 -0
  137. package/dist/notifications/index.d.ts +2 -1
  138. package/dist/notifications/index.js +2 -1
  139. package/dist/paddle.d.ts +7 -2
  140. package/dist/paddle.js +6 -1
  141. package/dist/resources/addresses/index.d.ts +2 -1
  142. package/dist/resources/addresses/index.js +10 -7
  143. package/dist/resources/adjustments/index.d.ts +1 -1
  144. package/dist/resources/adjustments/index.js +2 -4
  145. package/dist/resources/businesses/index.d.ts +2 -1
  146. package/dist/resources/businesses/index.js +10 -7
  147. package/dist/resources/customers/index.d.ts +2 -1
  148. package/dist/resources/customers/index.js +7 -4
  149. package/dist/resources/discounts/index.d.ts +2 -1
  150. package/dist/resources/discounts/index.js +7 -4
  151. package/dist/resources/events/index.d.ts +7 -0
  152. package/dist/resources/events/index.js +30 -0
  153. package/dist/resources/events/operations/index.d.ts +1 -0
  154. package/dist/resources/events/operations/index.js +17 -0
  155. package/dist/resources/events/operations/list-events-query-parameters.d.ts +5 -0
  156. package/dist/resources/events/operations/list-events-query-parameters.js +2 -0
  157. package/dist/resources/index.d.ts +1 -0
  158. package/dist/resources/index.js +1 -0
  159. package/dist/resources/prices/index.d.ts +2 -1
  160. package/dist/resources/prices/index.js +7 -4
  161. package/dist/resources/pricing-preview/index.d.ts +7 -0
  162. package/dist/resources/pricing-preview/index.js +42 -0
  163. package/dist/resources/pricing-preview/operations/index.d.ts +1 -0
  164. package/dist/resources/pricing-preview/operations/index.js +17 -0
  165. package/dist/resources/pricing-preview/operations/pricing-preview-request-body.d.ts +17 -0
  166. package/dist/resources/pricing-preview/operations/pricing-preview-request-body.js +2 -0
  167. package/dist/resources/products/index.d.ts +2 -1
  168. package/dist/resources/products/index.js +7 -4
  169. package/dist/resources/subscriptions/index.d.ts +1 -1
  170. package/dist/resources/subscriptions/index.js +2 -4
  171. package/dist/resources/transactions/index.d.ts +1 -1
  172. package/dist/resources/transactions/index.js +2 -4
  173. package/dist/types/events/events-response.d.ts +125 -0
  174. package/dist/types/events/events-response.js +2 -0
  175. package/dist/types/events/index.d.ts +1 -0
  176. package/dist/types/events/index.js +17 -0
  177. package/dist/types/index.d.ts +3 -0
  178. package/dist/types/index.js +3 -0
  179. package/dist/types/payout/index.d.ts +1 -0
  180. package/dist/types/payout/index.js +17 -0
  181. package/dist/types/payout/payout-response.d.ts +7 -0
  182. package/dist/types/payout/payout-response.js +2 -0
  183. package/dist/types/pricing-preview/index.d.ts +5 -0
  184. package/dist/types/pricing-preview/index.js +21 -0
  185. package/dist/types/pricing-preview/pricing-preview-details-response.d.ts +4 -0
  186. package/dist/types/pricing-preview/pricing-preview-details-response.js +2 -0
  187. package/dist/types/pricing-preview/pricing-preview-discounts-response.d.ts +6 -0
  188. package/dist/types/pricing-preview/pricing-preview-discounts-response.js +2 -0
  189. package/dist/types/pricing-preview/pricing-preview-item-response.d.ts +4 -0
  190. package/dist/types/pricing-preview/pricing-preview-item-response.js +2 -0
  191. package/dist/types/pricing-preview/pricing-preview-line-item-response.d.ts +15 -0
  192. package/dist/types/pricing-preview/pricing-preview-line-item-response.js +2 -0
  193. package/dist/types/pricing-preview/pricing-preview-response.d.ts +15 -0
  194. package/dist/types/pricing-preview/pricing-preview-response.js +2 -0
  195. package/dist/types/subscription/index.d.ts +1 -0
  196. package/dist/types/subscription/index.js +1 -0
  197. package/dist/types/subscription/subscription-notification-response.d.ts +28 -0
  198. package/dist/types/subscription/subscription-notification-response.js +2 -0
  199. package/dist/version.d.ts +1 -1
  200. package/dist/version.js +1 -1
  201. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -8,6 +8,28 @@ 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
+
20
+ ## 0.2.1 - 2023-11-29
21
+
22
+ ### Added
23
+
24
+ - Added helper function to archive supported entities
25
+ - 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)
26
+
27
+ ### Changed
28
+
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`.
30
+
31
+ ---
32
+
11
33
  ## 0.2.0 - 2023-11-28
12
34
 
13
35
  > **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
@@ -182,10 +222,49 @@ console.log('Product', product)
182
222
  The SDK includes a helper function to verify webhook signatures sent by Notifications from Paddle.
183
223
 
184
224
  ```typescript
185
- import { NotificationsValidator } from '@paddle/paddle-node-sdk'
225
+ import { Paddle, EventName } from '@paddle/paddle-node-sdk'
226
+ import express, { Request, Response } from 'express'
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
+ });
186
265
 
266
+ app.listen(3000)
187
267
 
188
- const isValid = new NotificationsValidator().isValidSignature('RAW_UNFORMATTED_REQUEST_BODY', 'PRIVATE_KEY_FROM_DASHBOARD', 'SIGNATURE_FROM_RESPONSE_HEADER')
189
268
  ```
190
269
 
191
270
  ## Feature parity
@@ -249,12 +328,12 @@ This table shows which operations are available as of the latest release.
249
328
  | **Adjustments** | **Full** |
250
329
  | List adjustments | ✅ |
251
330
  | Create an adjustment | ✅ |
252
- | **Pricing preview** | **None** |
253
- | Preview prices | ❌ |
331
+ | **Pricing preview** | **Full** |
332
+ | Preview prices | ✅ |
254
333
  | **Event types** | **None** |
255
334
  | List event types | ❌ |
256
- | **Events** | **None** |
257
- | List events | ❌ |
335
+ | **Events** | **Full** |
336
+ | List events | ✅ |
258
337
  | **Notification settings** | **None** |
259
338
  | List notification settings | ❌ |
260
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;
@@ -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;
@@ -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;