@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.
- package/CHANGELOG.md +22 -0
- package/README.md +90 -11
- package/dist/entities/discount/discount.d.ts +1 -1
- package/dist/entities/discount/discount.js +2 -1
- package/dist/entities/events/event-collection.d.ts +6 -0
- package/dist/entities/events/event-collection.js +11 -0
- package/dist/entities/events/event.d.ts +9 -0
- package/dist/entities/events/event.js +14 -0
- package/dist/entities/events/index.d.ts +1 -0
- package/dist/entities/events/index.js +17 -0
- package/dist/entities/index.d.ts +2 -0
- package/dist/entities/index.js +2 -0
- package/dist/entities/payout/index.d.ts +1 -0
- package/dist/entities/payout/index.js +17 -0
- package/dist/entities/payout/payout.d.ts +9 -0
- package/dist/entities/payout/payout.js +12 -0
- package/dist/entities/pricing-preview/index.d.ts +4 -0
- package/dist/entities/pricing-preview/index.js +20 -0
- package/dist/entities/pricing-preview/pricing-preview-details.d.ts +6 -0
- package/dist/entities/pricing-preview/pricing-preview-details.js +10 -0
- package/dist/entities/pricing-preview/pricing-preview-discounts.d.ts +8 -0
- package/dist/entities/pricing-preview/pricing-preview-discounts.js +12 -0
- package/dist/entities/pricing-preview/pricing-preview-line-item.d.ts +17 -0
- package/dist/entities/pricing-preview/pricing-preview-line-item.js +21 -0
- package/dist/entities/pricing-preview/pricing-preview.d.ts +15 -0
- package/dist/entities/pricing-preview/pricing-preview.js +19 -0
- package/dist/entities/subscription/index.d.ts +1 -0
- package/dist/entities/subscription/index.js +1 -0
- package/dist/entities/subscription/subscription-notification.d.ts +28 -0
- package/dist/entities/subscription/subscription-notification.js +35 -0
- package/dist/enums/index.d.ts +1 -0
- package/dist/enums/index.js +1 -0
- package/dist/enums/payout/index.d.ts +1 -0
- package/dist/enums/payout/index.js +17 -0
- package/dist/enums/payout/payout-status.d.ts +1 -0
- package/dist/enums/payout/payout-status.js +2 -0
- package/dist/notifications/events/address/address-created-event.d.ts +9 -0
- package/dist/notifications/events/address/address-created-event.js +14 -0
- package/dist/notifications/events/address/address-updated-event.d.ts +9 -0
- package/dist/notifications/events/address/address-updated-event.js +14 -0
- package/dist/notifications/events/address/index.d.ts +2 -0
- package/dist/notifications/events/address/index.js +18 -0
- package/dist/notifications/events/adjustment/adjustment-created-event.d.ts +9 -0
- package/dist/notifications/events/adjustment/adjustment-created-event.js +14 -0
- package/dist/notifications/events/adjustment/adjustment-updated-event.d.ts +9 -0
- package/dist/notifications/events/adjustment/adjustment-updated-event.js +14 -0
- package/dist/notifications/events/adjustment/index.d.ts +2 -0
- package/dist/notifications/events/adjustment/index.js +18 -0
- package/dist/notifications/events/business/business-created-event.d.ts +9 -0
- package/dist/notifications/events/business/business-created-event.js +14 -0
- package/dist/notifications/events/business/business-updated-event.d.ts +9 -0
- package/dist/notifications/events/business/business-updated-event.js +14 -0
- package/dist/notifications/events/business/index.d.ts +2 -0
- package/dist/notifications/events/business/index.js +18 -0
- package/dist/notifications/events/customer/customer-created-event.d.ts +9 -0
- package/dist/notifications/events/customer/customer-created-event.js +14 -0
- package/dist/notifications/events/customer/customer-updated-event.d.ts +9 -0
- package/dist/notifications/events/customer/customer-updated-event.js +14 -0
- package/dist/notifications/events/customer/index.d.ts +2 -0
- package/dist/notifications/events/customer/index.js +18 -0
- package/dist/notifications/events/discount/discount-created-event.d.ts +9 -0
- package/dist/notifications/events/discount/discount-created-event.js +14 -0
- package/dist/notifications/events/discount/discount-imported-event.d.ts +9 -0
- package/dist/notifications/events/discount/discount-imported-event.js +14 -0
- package/dist/notifications/events/discount/discount-updated-event.d.ts +9 -0
- package/dist/notifications/events/discount/discount-updated-event.js +14 -0
- package/dist/notifications/events/discount/index.d.ts +3 -0
- package/dist/notifications/events/discount/index.js +19 -0
- package/dist/notifications/events/index.d.ts +10 -0
- package/dist/notifications/events/index.js +26 -0
- package/dist/notifications/events/payout/index.d.ts +2 -0
- package/dist/notifications/events/payout/index.js +18 -0
- package/dist/notifications/events/payout/payout-created-event.d.ts +9 -0
- package/dist/notifications/events/payout/payout-created-event.js +14 -0
- package/dist/notifications/events/payout/payout-paid-event.d.ts +9 -0
- package/dist/notifications/events/payout/payout-paid-event.js +14 -0
- package/dist/notifications/events/price/index.d.ts +2 -0
- package/dist/notifications/events/price/index.js +18 -0
- package/dist/notifications/events/price/price-created-event.d.ts +9 -0
- package/dist/notifications/events/price/price-created-event.js +14 -0
- package/dist/notifications/events/price/price-updated-event.d.ts +9 -0
- package/dist/notifications/events/price/price-updated-event.js +14 -0
- package/dist/notifications/events/product/index.d.ts +2 -0
- package/dist/notifications/events/product/index.js +18 -0
- package/dist/notifications/events/product/product-created-event.d.ts +9 -0
- package/dist/notifications/events/product/product-created-event.js +14 -0
- package/dist/notifications/events/product/product-updated-event.d.ts +9 -0
- package/dist/notifications/events/product/product-updated-event.js +14 -0
- package/dist/notifications/events/subscription/index.d.ts +9 -0
- package/dist/notifications/events/subscription/index.js +25 -0
- package/dist/notifications/events/subscription/subscription-activated-event.d.ts +9 -0
- package/dist/notifications/events/subscription/subscription-activated-event.js +14 -0
- package/dist/notifications/events/subscription/subscription-canceled-event.d.ts +9 -0
- package/dist/notifications/events/subscription/subscription-canceled-event.js +14 -0
- package/dist/notifications/events/subscription/subscription-created-event.d.ts +9 -0
- package/dist/notifications/events/subscription/subscription-created-event.js +14 -0
- package/dist/notifications/events/subscription/subscription-imported-event.d.ts +9 -0
- package/dist/notifications/events/subscription/subscription-imported-event.js +14 -0
- package/dist/notifications/events/subscription/subscription-past-due-event.d.ts +9 -0
- package/dist/notifications/events/subscription/subscription-past-due-event.js +14 -0
- package/dist/notifications/events/subscription/subscription-paused-event.d.ts +9 -0
- package/dist/notifications/events/subscription/subscription-paused-event.js +14 -0
- package/dist/notifications/events/subscription/subscription-resumed-event.d.ts +9 -0
- package/dist/notifications/events/subscription/subscription-resumed-event.js +14 -0
- package/dist/notifications/events/subscription/subscription-trialing-event.d.ts +9 -0
- package/dist/notifications/events/subscription/subscription-trialing-event.js +14 -0
- package/dist/notifications/events/subscription/subscription-updated-event.d.ts +9 -0
- package/dist/notifications/events/subscription/subscription-updated-event.js +14 -0
- package/dist/notifications/events/transaction/index.d.ts +9 -0
- package/dist/notifications/events/transaction/index.js +25 -0
- package/dist/notifications/events/transaction/transaction-billed-event.d.ts +9 -0
- package/dist/notifications/events/transaction/transaction-billed-event.js +14 -0
- package/dist/notifications/events/transaction/transaction-canceled-event.d.ts +9 -0
- package/dist/notifications/events/transaction/transaction-canceled-event.js +14 -0
- package/dist/notifications/events/transaction/transaction-completed-event.d.ts +9 -0
- package/dist/notifications/events/transaction/transaction-completed-event.js +14 -0
- package/dist/notifications/events/transaction/transaction-created-event.d.ts +9 -0
- package/dist/notifications/events/transaction/transaction-created-event.js +14 -0
- package/dist/notifications/events/transaction/transaction-paid-event.d.ts +9 -0
- package/dist/notifications/events/transaction/transaction-paid-event.js +14 -0
- package/dist/notifications/events/transaction/transaction-past-due-event.d.ts +9 -0
- package/dist/notifications/events/transaction/transaction-past-due-event.js +14 -0
- package/dist/notifications/events/transaction/transaction-payment-failed-event.d.ts +9 -0
- package/dist/notifications/events/transaction/transaction-payment-failed-event.js +14 -0
- package/dist/notifications/events/transaction/transaction-ready-event.d.ts +9 -0
- package/dist/notifications/events/transaction/transaction-ready-event.js +14 -0
- package/dist/notifications/events/transaction/transaction-updated-event.d.ts +9 -0
- package/dist/notifications/events/transaction/transaction-updated-event.js +14 -0
- package/dist/notifications/helpers/index.d.ts +3 -0
- package/dist/notifications/helpers/index.js +19 -0
- package/dist/notifications/helpers/types.d.ts +40 -0
- package/dist/notifications/helpers/types.js +41 -0
- package/dist/notifications/{validator/notifications-validator.d.ts → helpers/webhooks-validator.d.ts} +1 -1
- package/dist/notifications/{validator/notifications-validator.js → helpers/webhooks-validator.js} +6 -6
- package/dist/notifications/helpers/webhooks.d.ts +7 -0
- package/dist/notifications/helpers/webhooks.js +98 -0
- package/dist/notifications/index.d.ts +2 -1
- package/dist/notifications/index.js +2 -1
- package/dist/paddle.d.ts +7 -2
- package/dist/paddle.js +6 -1
- package/dist/resources/addresses/index.d.ts +2 -1
- package/dist/resources/addresses/index.js +10 -7
- package/dist/resources/adjustments/index.d.ts +1 -1
- package/dist/resources/adjustments/index.js +2 -4
- package/dist/resources/businesses/index.d.ts +2 -1
- package/dist/resources/businesses/index.js +10 -7
- package/dist/resources/customers/index.d.ts +2 -1
- package/dist/resources/customers/index.js +7 -4
- package/dist/resources/discounts/index.d.ts +2 -1
- package/dist/resources/discounts/index.js +7 -4
- package/dist/resources/events/index.d.ts +7 -0
- package/dist/resources/events/index.js +30 -0
- package/dist/resources/events/operations/index.d.ts +1 -0
- package/dist/resources/events/operations/index.js +17 -0
- package/dist/resources/events/operations/list-events-query-parameters.d.ts +5 -0
- package/dist/resources/events/operations/list-events-query-parameters.js +2 -0
- package/dist/resources/index.d.ts +1 -0
- package/dist/resources/index.js +1 -0
- package/dist/resources/prices/index.d.ts +2 -1
- package/dist/resources/prices/index.js +7 -4
- package/dist/resources/pricing-preview/index.d.ts +7 -0
- package/dist/resources/pricing-preview/index.js +42 -0
- package/dist/resources/pricing-preview/operations/index.d.ts +1 -0
- package/dist/resources/pricing-preview/operations/index.js +17 -0
- package/dist/resources/pricing-preview/operations/pricing-preview-request-body.d.ts +17 -0
- package/dist/resources/pricing-preview/operations/pricing-preview-request-body.js +2 -0
- package/dist/resources/products/index.d.ts +2 -1
- package/dist/resources/products/index.js +7 -4
- package/dist/resources/subscriptions/index.d.ts +1 -1
- package/dist/resources/subscriptions/index.js +2 -4
- package/dist/resources/transactions/index.d.ts +1 -1
- package/dist/resources/transactions/index.js +2 -4
- package/dist/types/events/events-response.d.ts +125 -0
- package/dist/types/events/events-response.js +2 -0
- package/dist/types/events/index.d.ts +1 -0
- package/dist/types/events/index.js +17 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.js +3 -0
- package/dist/types/payout/index.d.ts +1 -0
- package/dist/types/payout/index.js +17 -0
- package/dist/types/payout/payout-response.d.ts +7 -0
- package/dist/types/payout/payout-response.js +2 -0
- package/dist/types/pricing-preview/index.d.ts +5 -0
- package/dist/types/pricing-preview/index.js +21 -0
- package/dist/types/pricing-preview/pricing-preview-details-response.d.ts +4 -0
- package/dist/types/pricing-preview/pricing-preview-details-response.js +2 -0
- package/dist/types/pricing-preview/pricing-preview-discounts-response.d.ts +6 -0
- package/dist/types/pricing-preview/pricing-preview-discounts-response.js +2 -0
- package/dist/types/pricing-preview/pricing-preview-item-response.d.ts +4 -0
- package/dist/types/pricing-preview/pricing-preview-item-response.js +2 -0
- package/dist/types/pricing-preview/pricing-preview-line-item-response.d.ts +15 -0
- package/dist/types/pricing-preview/pricing-preview-line-item-response.js +2 -0
- package/dist/types/pricing-preview/pricing-preview-response.d.ts +15 -0
- package/dist/types/pricing-preview/pricing-preview-response.js +2 -0
- package/dist/types/subscription/index.d.ts +1 -0
- package/dist/types/subscription/index.js +1 -0
- package/dist/types/subscription/subscription-notification-response.d.ts +28 -0
- package/dist/types/subscription/subscription-notification-response.js +2 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type AddressCreatedEvent, type AddressUpdatedEvent, type BusinessCreatedEvent, type AdjustmentCreatedEvent, type AdjustmentUpdatedEvent, type BusinessUpdatedEvent, type CustomerCreatedEvent, type CustomerUpdatedEvent, type DiscountCreatedEvent, type DiscountImportedEvent, type DiscountUpdatedEvent, type PayoutCreatedEvent, type PayoutPaidEvent, type PriceCreatedEvent, type PriceUpdatedEvent, type ProductCreatedEvent, type ProductUpdatedEvent, type SubscriptionCreatedEvent, type SubscriptionActivatedEvent, type SubscriptionCanceledEvent, type SubscriptionImportedEvent, type SubscriptionPausedEvent, type SubscriptionResumedEvent, type SubscriptionTrialingEvent, type SubscriptionUpdatedEvent, type TransactionCanceledEvent, type TransactionBilledEvent, type TransactionCompletedEvent, type TransactionCreatedEvent, type TransactionPaidEvent, type SubscriptionPastDueEvent, type TransactionPastDueEvent, type TransactionPaymentFailedEvent, type TransactionReadyEvent, type TransactionUpdatedEvent } from '../events';
|
|
2
|
+
export type EventEntity = AddressCreatedEvent | AddressUpdatedEvent | AdjustmentUpdatedEvent | AdjustmentCreatedEvent | BusinessCreatedEvent | BusinessUpdatedEvent | CustomerCreatedEvent | CustomerUpdatedEvent | DiscountCreatedEvent | DiscountUpdatedEvent | DiscountImportedEvent | PayoutCreatedEvent | PayoutPaidEvent | PriceCreatedEvent | PriceUpdatedEvent | ProductCreatedEvent | ProductUpdatedEvent | SubscriptionActivatedEvent | SubscriptionCanceledEvent | SubscriptionCreatedEvent | SubscriptionImportedEvent | SubscriptionPastDueEvent | SubscriptionPausedEvent | SubscriptionResumedEvent | SubscriptionTrialingEvent | SubscriptionUpdatedEvent | TransactionBilledEvent | TransactionCanceledEvent | TransactionCompletedEvent | TransactionCreatedEvent | TransactionPaidEvent | TransactionPastDueEvent | TransactionPaymentFailedEvent | TransactionReadyEvent | TransactionUpdatedEvent;
|
|
3
|
+
export declare enum EventName {
|
|
4
|
+
AddressCreated = "address.created",
|
|
5
|
+
AddressUpdated = "address.updated",
|
|
6
|
+
AdjustmentCreated = "adjustment.created",
|
|
7
|
+
AdjustmentUpdated = "adjustment.updated",
|
|
8
|
+
BusinessCreated = "business.created",
|
|
9
|
+
BusinessUpdated = "business.updated",
|
|
10
|
+
CustomerCreated = "customer.created",
|
|
11
|
+
CustomerUpdated = "customer.updated",
|
|
12
|
+
DiscountCreated = "discount.created",
|
|
13
|
+
DiscountUpdated = "discount.updated",
|
|
14
|
+
DiscountImported = "discount.imported",
|
|
15
|
+
PayoutCreated = "payout.created",
|
|
16
|
+
PayoutPaid = "payout.paid",
|
|
17
|
+
PriceCreated = "price.created",
|
|
18
|
+
PriceUpdated = "price.updated",
|
|
19
|
+
ProductCreated = "product.created",
|
|
20
|
+
ProductUpdated = "product.updated",
|
|
21
|
+
SubscriptionActivated = "subscription.activated",
|
|
22
|
+
SubscriptionCanceled = "subscription.canceled",
|
|
23
|
+
SubscriptionImported = "subscription.imported",
|
|
24
|
+
SubscriptionCreated = "subscription.created",
|
|
25
|
+
SubscriptionPastDue = "subscription.past_due",
|
|
26
|
+
SubscriptionPaused = "subscription.paused",
|
|
27
|
+
SubscriptionResumed = "subscription.resumed",
|
|
28
|
+
SubscriptionTrialing = "subscription.trialing",
|
|
29
|
+
SubscriptionUpdated = "subscription.updated",
|
|
30
|
+
TransactionBilled = "transaction.billed",
|
|
31
|
+
TransactionCanceled = "transaction.canceled",
|
|
32
|
+
TransactionCompleted = "transaction.completed",
|
|
33
|
+
TransactionPaid = "transaction.paid",
|
|
34
|
+
TransactionCreated = "transaction.created",
|
|
35
|
+
TransactionPastDue = "transaction.past_due",
|
|
36
|
+
TransactionPaymentFailed = "transaction.payment_failed",
|
|
37
|
+
TransactionReady = "transaction.ready",
|
|
38
|
+
TransactionUpdated = "transaction.updated"
|
|
39
|
+
}
|
|
40
|
+
export type IEventName = 'address.created' | 'address.updated' | 'adjustment.created' | 'adjustment.updated' | 'business.created' | 'business.updated' | 'customer.created' | 'customer.updated' | 'discount.created' | 'discount.updated' | 'discount.imported' | 'payout.updated' | 'payout.paid' | 'price.updated' | 'price.created' | 'product.updated' | 'product.created' | 'subscription.activated' | 'subscription.canceled' | 'subscription.imported' | 'subscription.created' | 'subscription.past_due' | 'subscription.paused' | 'subscription.resumed' | 'subscription.trialing' | 'subscription.updated' | 'transaction.billed' | 'transaction.canceled' | 'transaction.completed' | 'transaction.paid' | 'transaction.created' | 'transaction.past_due' | 'transaction.payment_failed' | 'transaction.ready' | 'transaction.updated';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EventName = void 0;
|
|
4
|
+
var EventName;
|
|
5
|
+
(function (EventName) {
|
|
6
|
+
EventName["AddressCreated"] = "address.created";
|
|
7
|
+
EventName["AddressUpdated"] = "address.updated";
|
|
8
|
+
EventName["AdjustmentCreated"] = "adjustment.created";
|
|
9
|
+
EventName["AdjustmentUpdated"] = "adjustment.updated";
|
|
10
|
+
EventName["BusinessCreated"] = "business.created";
|
|
11
|
+
EventName["BusinessUpdated"] = "business.updated";
|
|
12
|
+
EventName["CustomerCreated"] = "customer.created";
|
|
13
|
+
EventName["CustomerUpdated"] = "customer.updated";
|
|
14
|
+
EventName["DiscountCreated"] = "discount.created";
|
|
15
|
+
EventName["DiscountUpdated"] = "discount.updated";
|
|
16
|
+
EventName["DiscountImported"] = "discount.imported";
|
|
17
|
+
EventName["PayoutCreated"] = "payout.created";
|
|
18
|
+
EventName["PayoutPaid"] = "payout.paid";
|
|
19
|
+
EventName["PriceCreated"] = "price.created";
|
|
20
|
+
EventName["PriceUpdated"] = "price.updated";
|
|
21
|
+
EventName["ProductCreated"] = "product.created";
|
|
22
|
+
EventName["ProductUpdated"] = "product.updated";
|
|
23
|
+
EventName["SubscriptionActivated"] = "subscription.activated";
|
|
24
|
+
EventName["SubscriptionCanceled"] = "subscription.canceled";
|
|
25
|
+
EventName["SubscriptionImported"] = "subscription.imported";
|
|
26
|
+
EventName["SubscriptionCreated"] = "subscription.created";
|
|
27
|
+
EventName["SubscriptionPastDue"] = "subscription.past_due";
|
|
28
|
+
EventName["SubscriptionPaused"] = "subscription.paused";
|
|
29
|
+
EventName["SubscriptionResumed"] = "subscription.resumed";
|
|
30
|
+
EventName["SubscriptionTrialing"] = "subscription.trialing";
|
|
31
|
+
EventName["SubscriptionUpdated"] = "subscription.updated";
|
|
32
|
+
EventName["TransactionBilled"] = "transaction.billed";
|
|
33
|
+
EventName["TransactionCanceled"] = "transaction.canceled";
|
|
34
|
+
EventName["TransactionCompleted"] = "transaction.completed";
|
|
35
|
+
EventName["TransactionPaid"] = "transaction.paid";
|
|
36
|
+
EventName["TransactionCreated"] = "transaction.created";
|
|
37
|
+
EventName["TransactionPastDue"] = "transaction.past_due";
|
|
38
|
+
EventName["TransactionPaymentFailed"] = "transaction.payment_failed";
|
|
39
|
+
EventName["TransactionReady"] = "transaction.ready";
|
|
40
|
+
EventName["TransactionUpdated"] = "transaction.updated";
|
|
41
|
+
})(EventName || (exports.EventName = EventName = {}));
|
package/dist/notifications/{validator/notifications-validator.js → helpers/webhooks-validator.js}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.WebhooksValidator = void 0;
|
|
4
4
|
const crypto_1 = require("crypto");
|
|
5
|
-
class
|
|
5
|
+
class WebhooksValidator {
|
|
6
6
|
extractHeader(header) {
|
|
7
7
|
const parts = header.split(';');
|
|
8
8
|
let ts = '';
|
|
@@ -22,13 +22,13 @@ class NotificationsValidator {
|
|
|
22
22
|
return { ts: parseInt(ts), h1 };
|
|
23
23
|
}
|
|
24
24
|
else {
|
|
25
|
-
throw new Error('Invalid
|
|
25
|
+
throw new Error('[Paddle] Invalid webhook signature');
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
isValidSignature(requestBody, secretKey, signature) {
|
|
29
29
|
const headers = this.extractHeader(signature);
|
|
30
30
|
const payloadWithTime = `${headers.ts}:${requestBody}`;
|
|
31
|
-
if (new Date().getTime() > new Date((headers.ts +
|
|
31
|
+
if (new Date().getTime() > new Date((headers.ts + WebhooksValidator.MAX_VALID_TIME_DIFFERENCE) * 1000).getTime()) {
|
|
32
32
|
return false;
|
|
33
33
|
}
|
|
34
34
|
const hmac = (0, crypto_1.createHmac)('sha256', secretKey);
|
|
@@ -37,5 +37,5 @@ class NotificationsValidator {
|
|
|
37
37
|
return computedHash === headers.h1;
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
exports.
|
|
41
|
-
|
|
40
|
+
exports.WebhooksValidator = WebhooksValidator;
|
|
41
|
+
WebhooksValidator.MAX_VALID_TIME_DIFFERENCE = 5;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type IEvents } from '../../types';
|
|
2
|
+
import { type EventEntity } from './types';
|
|
3
|
+
export declare class Webhooks {
|
|
4
|
+
unmarshal(requestBody: string, secretKey: string, signature: string): EventEntity;
|
|
5
|
+
isSignatureValid(requestBody: string, secretKey: string, signature: string): boolean;
|
|
6
|
+
static fromJson(data: IEvents): EventEntity;
|
|
7
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Webhooks = void 0;
|
|
4
|
+
const events_1 = require("../events");
|
|
5
|
+
const types_1 = require("./types");
|
|
6
|
+
const webhooks_validator_1 = require("./webhooks-validator");
|
|
7
|
+
class Webhooks {
|
|
8
|
+
unmarshal(requestBody, secretKey, signature) {
|
|
9
|
+
const isSignatureValid = new webhooks_validator_1.WebhooksValidator().isValidSignature(requestBody, secretKey, signature);
|
|
10
|
+
if (isSignatureValid) {
|
|
11
|
+
const parsedRequest = JSON.parse(requestBody);
|
|
12
|
+
return Webhooks.fromJson(parsedRequest);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
throw new Error('[Paddle] Webhook signature verification failed');
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
isSignatureValid(requestBody, secretKey, signature) {
|
|
19
|
+
return new webhooks_validator_1.WebhooksValidator().isValidSignature(requestBody, secretKey, signature);
|
|
20
|
+
}
|
|
21
|
+
static fromJson(data) {
|
|
22
|
+
switch (data.event_type) {
|
|
23
|
+
case types_1.EventName.AddressCreated:
|
|
24
|
+
return new events_1.AddressCreatedEvent(data);
|
|
25
|
+
case types_1.EventName.AddressUpdated:
|
|
26
|
+
return new events_1.AddressUpdatedEvent(data);
|
|
27
|
+
case types_1.EventName.AdjustmentCreated:
|
|
28
|
+
return new events_1.AdjustmentCreatedEvent(data);
|
|
29
|
+
case types_1.EventName.AdjustmentUpdated:
|
|
30
|
+
return new events_1.AdjustmentUpdatedEvent(data);
|
|
31
|
+
case types_1.EventName.BusinessCreated:
|
|
32
|
+
return new events_1.BusinessCreatedEvent(data);
|
|
33
|
+
case types_1.EventName.BusinessUpdated:
|
|
34
|
+
return new events_1.BusinessUpdatedEvent(data);
|
|
35
|
+
case types_1.EventName.CustomerCreated:
|
|
36
|
+
return new events_1.CustomerCreatedEvent(data);
|
|
37
|
+
case types_1.EventName.CustomerUpdated:
|
|
38
|
+
return new events_1.CustomerUpdatedEvent(data);
|
|
39
|
+
case types_1.EventName.DiscountCreated:
|
|
40
|
+
return new events_1.DiscountCreatedEvent(data);
|
|
41
|
+
case types_1.EventName.DiscountImported:
|
|
42
|
+
return new events_1.DiscountImportedEvent(data);
|
|
43
|
+
case types_1.EventName.DiscountUpdated:
|
|
44
|
+
return new events_1.DiscountUpdatedEvent(data);
|
|
45
|
+
case types_1.EventName.PayoutCreated:
|
|
46
|
+
return new events_1.PayoutCreatedEvent(data);
|
|
47
|
+
case types_1.EventName.PayoutPaid:
|
|
48
|
+
return new events_1.PayoutPaidEvent(data);
|
|
49
|
+
case types_1.EventName.PriceCreated:
|
|
50
|
+
return new events_1.PriceCreatedEvent(data);
|
|
51
|
+
case types_1.EventName.PriceUpdated:
|
|
52
|
+
return new events_1.PriceUpdatedEvent(data);
|
|
53
|
+
case types_1.EventName.ProductCreated:
|
|
54
|
+
return new events_1.ProductCreatedEvent(data);
|
|
55
|
+
case types_1.EventName.ProductUpdated:
|
|
56
|
+
return new events_1.ProductUpdatedEvent(data);
|
|
57
|
+
case types_1.EventName.SubscriptionActivated:
|
|
58
|
+
return new events_1.SubscriptionActivatedEvent(data);
|
|
59
|
+
case types_1.EventName.SubscriptionCanceled:
|
|
60
|
+
return new events_1.SubscriptionCanceledEvent(data);
|
|
61
|
+
case types_1.EventName.SubscriptionCreated:
|
|
62
|
+
return new events_1.SubscriptionCreatedEvent(data);
|
|
63
|
+
case types_1.EventName.SubscriptionImported:
|
|
64
|
+
return new events_1.SubscriptionImportedEvent(data);
|
|
65
|
+
case types_1.EventName.SubscriptionPastDue:
|
|
66
|
+
return new events_1.SubscriptionPastDueEvent(data);
|
|
67
|
+
case types_1.EventName.SubscriptionPaused:
|
|
68
|
+
return new events_1.SubscriptionPausedEvent(data);
|
|
69
|
+
case types_1.EventName.SubscriptionResumed:
|
|
70
|
+
return new events_1.SubscriptionResumedEvent(data);
|
|
71
|
+
case types_1.EventName.SubscriptionTrialing:
|
|
72
|
+
return new events_1.SubscriptionTrialingEvent(data);
|
|
73
|
+
case types_1.EventName.SubscriptionUpdated:
|
|
74
|
+
return new events_1.SubscriptionUpdatedEvent(data);
|
|
75
|
+
case types_1.EventName.TransactionBilled:
|
|
76
|
+
return new events_1.TransactionBilledEvent(data);
|
|
77
|
+
case types_1.EventName.TransactionCanceled:
|
|
78
|
+
return new events_1.TransactionCanceledEvent(data);
|
|
79
|
+
case types_1.EventName.TransactionCompleted:
|
|
80
|
+
return new events_1.TransactionCompletedEvent(data);
|
|
81
|
+
case types_1.EventName.TransactionCreated:
|
|
82
|
+
return new events_1.TransactionCreatedEvent(data);
|
|
83
|
+
case types_1.EventName.TransactionPaid:
|
|
84
|
+
return new events_1.TransactionPaidEvent(data);
|
|
85
|
+
case types_1.EventName.TransactionPastDue:
|
|
86
|
+
return new events_1.TransactionPastDueEvent(data);
|
|
87
|
+
case types_1.EventName.TransactionPaymentFailed:
|
|
88
|
+
return new events_1.TransactionPaymentFailedEvent(data);
|
|
89
|
+
case types_1.EventName.TransactionReady:
|
|
90
|
+
return new events_1.TransactionReadyEvent(data);
|
|
91
|
+
case types_1.EventName.TransactionUpdated:
|
|
92
|
+
return new events_1.TransactionUpdatedEvent(data);
|
|
93
|
+
default:
|
|
94
|
+
throw new Error('[Paddle] Unknown event_type');
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.Webhooks = Webhooks;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './helpers';
|
|
2
|
+
export * from './events';
|
|
@@ -14,4 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./helpers"), exports);
|
|
18
|
+
__exportStar(require("./events"), exports);
|
package/dist/paddle.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { AddressesResource, AdjustmentsResource, BusinessesResource, CustomersResource, DiscountsResource, PricesResource, ProductsResource, SubscriptionsResource, TransactionsResource } from './resources';
|
|
1
|
+
import { AddressesResource, AdjustmentsResource, BusinessesResource, CustomersResource, DiscountsResource, PricesResource, PricingPreviewResource, ProductsResource, SubscriptionsResource, TransactionsResource } from './resources';
|
|
2
2
|
import { type PaddleOptions } from './internal';
|
|
3
|
+
import { EventsResource } from './resources/events';
|
|
4
|
+
import { Webhooks } from './notifications';
|
|
3
5
|
export declare class Paddle {
|
|
4
6
|
private readonly client;
|
|
5
7
|
private readonly defaultPaddleOptions;
|
|
@@ -12,5 +14,8 @@ export declare class Paddle {
|
|
|
12
14
|
businesses: BusinessesResource;
|
|
13
15
|
discounts: DiscountsResource;
|
|
14
16
|
subscriptions: SubscriptionsResource;
|
|
15
|
-
|
|
17
|
+
pricingPreview: PricingPreviewResource;
|
|
18
|
+
events: EventsResource;
|
|
19
|
+
webhooks: Webhooks;
|
|
20
|
+
constructor(apiKey: string, options?: PaddleOptions);
|
|
16
21
|
}
|
package/dist/paddle.js
CHANGED
|
@@ -4,12 +4,14 @@ exports.Paddle = void 0;
|
|
|
4
4
|
const client_1 = require("./internal/api/client");
|
|
5
5
|
const resources_1 = require("./resources");
|
|
6
6
|
const internal_1 = require("./internal");
|
|
7
|
+
const events_1 = require("./resources/events");
|
|
8
|
+
const notifications_1 = require("./notifications");
|
|
7
9
|
class Paddle {
|
|
8
10
|
constructor(apiKey, options) {
|
|
9
11
|
this.defaultPaddleOptions = {
|
|
10
12
|
environment: internal_1.Environment.production,
|
|
11
13
|
};
|
|
12
|
-
this.client = new client_1.Client(apiKey, Object.assign(Object.assign({}, this.defaultPaddleOptions), options));
|
|
14
|
+
this.client = new client_1.Client(apiKey, options ? Object.assign(Object.assign({}, this.defaultPaddleOptions), options) : Object.assign({}, this.defaultPaddleOptions));
|
|
13
15
|
this.products = new resources_1.ProductsResource(this.client);
|
|
14
16
|
this.prices = new resources_1.PricesResource(this.client);
|
|
15
17
|
this.transactions = new resources_1.TransactionsResource(this.client);
|
|
@@ -19,6 +21,9 @@ class Paddle {
|
|
|
19
21
|
this.businesses = new resources_1.BusinessesResource(this.client);
|
|
20
22
|
this.discounts = new resources_1.DiscountsResource(this.client);
|
|
21
23
|
this.subscriptions = new resources_1.SubscriptionsResource(this.client);
|
|
24
|
+
this.pricingPreview = new resources_1.PricingPreviewResource(this.client);
|
|
25
|
+
this.events = new events_1.EventsResource(this.client);
|
|
26
|
+
this.webhooks = new notifications_1.Webhooks();
|
|
22
27
|
}
|
|
23
28
|
}
|
|
24
29
|
exports.Paddle = Paddle;
|
|
@@ -3,8 +3,9 @@ import { BaseResource } from '../../internal/base';
|
|
|
3
3
|
import { type ListAddressQueryParameters, type CreateAddressRequestBody, type UpdateAddressRequestBody } from './operations';
|
|
4
4
|
export * from './operations';
|
|
5
5
|
export declare class AddressesResource extends BaseResource {
|
|
6
|
-
list(customerId: string, queryParams?: ListAddressQueryParameters):
|
|
6
|
+
list(customerId: string, queryParams?: ListAddressQueryParameters): AddressCollection;
|
|
7
7
|
create(customerId: string, createAddressParameters: CreateAddressRequestBody): Promise<Address>;
|
|
8
8
|
get(customerId: string, addressId: string): Promise<Address>;
|
|
9
9
|
update(customerId: string, addressId: string, updateAddress: UpdateAddressRequestBody): Promise<Address>;
|
|
10
|
+
archive(customerId: string, addressId: string): Promise<Address>;
|
|
10
11
|
}
|
|
@@ -35,13 +35,11 @@ const AddressPaths = {
|
|
|
35
35
|
__exportStar(require("./operations"), exports);
|
|
36
36
|
class AddressesResource extends base_1.BaseResource {
|
|
37
37
|
list(customerId, queryParams) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return new entities_1.AddressCollection(this.client, urlWithPathParams + queryParameters.toQueryString());
|
|
44
|
-
});
|
|
38
|
+
const queryParameters = new base_1.QueryParameters(queryParams);
|
|
39
|
+
const urlWithPathParams = new base_1.PathParameters(AddressPaths.list, {
|
|
40
|
+
customer_id: customerId,
|
|
41
|
+
}).deriveUrl();
|
|
42
|
+
return new entities_1.AddressCollection(this.client, urlWithPathParams + queryParameters.toQueryString());
|
|
45
43
|
}
|
|
46
44
|
create(customerId, createAddressParameters) {
|
|
47
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -75,5 +73,10 @@ class AddressesResource extends base_1.BaseResource {
|
|
|
75
73
|
return new entities_1.Address(data);
|
|
76
74
|
});
|
|
77
75
|
}
|
|
76
|
+
archive(customerId, addressId) {
|
|
77
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
return yield this.update(customerId, addressId, { status: 'archived' });
|
|
79
|
+
});
|
|
80
|
+
}
|
|
78
81
|
}
|
|
79
82
|
exports.AddressesResource = AddressesResource;
|
|
@@ -3,6 +3,6 @@ import { BaseResource } from '../../internal/base';
|
|
|
3
3
|
import { type CreateAdjustmentRequestBody, type ListAdjustmentQueryParameters } from './operations';
|
|
4
4
|
export * from './operations';
|
|
5
5
|
export declare class AdjustmentsResource extends BaseResource {
|
|
6
|
-
list(queryParams?: ListAdjustmentQueryParameters):
|
|
6
|
+
list(queryParams?: ListAdjustmentQueryParameters): AdjustmentCollection;
|
|
7
7
|
create(createAdjustmentParameters: CreateAdjustmentRequestBody): Promise<Adjustment>;
|
|
8
8
|
}
|
|
@@ -33,10 +33,8 @@ const AdjustmentPaths = {
|
|
|
33
33
|
__exportStar(require("./operations"), exports);
|
|
34
34
|
class AdjustmentsResource extends base_1.BaseResource {
|
|
35
35
|
list(queryParams) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return new entities_1.AdjustmentCollection(this.client, AdjustmentPaths.list + queryParameters.toQueryString());
|
|
39
|
-
});
|
|
36
|
+
const queryParameters = new base_1.QueryParameters(queryParams);
|
|
37
|
+
return new entities_1.AdjustmentCollection(this.client, AdjustmentPaths.list + queryParameters.toQueryString());
|
|
40
38
|
}
|
|
41
39
|
create(createAdjustmentParameters) {
|
|
42
40
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -3,8 +3,9 @@ import { BaseResource } from '../../internal/base';
|
|
|
3
3
|
import { type CreateBusinessRequestBody, type ListBusinessQueryParameters, type UpdateBusinessRequestBody } from './operations';
|
|
4
4
|
export * from './operations';
|
|
5
5
|
export declare class BusinessesResource extends BaseResource {
|
|
6
|
-
list(customerId: string, queryParams?: ListBusinessQueryParameters):
|
|
6
|
+
list(customerId: string, queryParams?: ListBusinessQueryParameters): BusinessCollection;
|
|
7
7
|
create(customerId: string, createBusinessParameters: CreateBusinessRequestBody): Promise<Business>;
|
|
8
8
|
get(customerId: string, businessId: string): Promise<Business>;
|
|
9
9
|
update(customerId: string, businessId: string, updateBusiness: UpdateBusinessRequestBody): Promise<Business>;
|
|
10
|
+
archive(customerId: string, addressId: string): Promise<Business>;
|
|
10
11
|
}
|
|
@@ -35,13 +35,11 @@ const BusinessPaths = {
|
|
|
35
35
|
__exportStar(require("./operations"), exports);
|
|
36
36
|
class BusinessesResource extends base_1.BaseResource {
|
|
37
37
|
list(customerId, queryParams) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return new entities_1.BusinessCollection(this.client, urlWithPathParams + queryParameters.toQueryString());
|
|
44
|
-
});
|
|
38
|
+
const queryParameters = new base_1.QueryParameters(queryParams);
|
|
39
|
+
const urlWithPathParams = new base_1.PathParameters(BusinessPaths.list, {
|
|
40
|
+
customer_id: customerId,
|
|
41
|
+
}).deriveUrl();
|
|
42
|
+
return new entities_1.BusinessCollection(this.client, urlWithPathParams + queryParameters.toQueryString());
|
|
45
43
|
}
|
|
46
44
|
create(customerId, createBusinessParameters) {
|
|
47
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -75,5 +73,10 @@ class BusinessesResource extends base_1.BaseResource {
|
|
|
75
73
|
return new entities_1.Business(data);
|
|
76
74
|
});
|
|
77
75
|
}
|
|
76
|
+
archive(customerId, addressId) {
|
|
77
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
return yield this.update(customerId, addressId, { status: 'archived' });
|
|
79
|
+
});
|
|
80
|
+
}
|
|
78
81
|
}
|
|
79
82
|
exports.BusinessesResource = BusinessesResource;
|
|
@@ -3,9 +3,10 @@ import { BaseResource } from '../../internal/base';
|
|
|
3
3
|
import { type CreateCustomerRequestBody, type GetCreditBalanceQueryParameters, type ListCustomerQueryParameters, type UpdateCustomerRequestBody } from './operations';
|
|
4
4
|
export * from './operations';
|
|
5
5
|
export declare class CustomersResource extends BaseResource {
|
|
6
|
-
list(queryParams?: ListCustomerQueryParameters):
|
|
6
|
+
list(queryParams?: ListCustomerQueryParameters): CustomerCollection;
|
|
7
7
|
create(createCustomerParameters: CreateCustomerRequestBody): Promise<Customer>;
|
|
8
8
|
get(customerId: string): Promise<Customer>;
|
|
9
9
|
update(customerId: string, updateCustomer: UpdateCustomerRequestBody): Promise<Customer>;
|
|
10
10
|
getCreditBalance(customerId: string, queryParams?: GetCreditBalanceQueryParameters): Promise<CreditBalance[]>;
|
|
11
|
+
archive(customerId: string): Promise<Customer>;
|
|
11
12
|
}
|
|
@@ -36,10 +36,8 @@ const CustomerPaths = {
|
|
|
36
36
|
__exportStar(require("./operations"), exports);
|
|
37
37
|
class CustomersResource extends base_1.BaseResource {
|
|
38
38
|
list(queryParams) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return new entities_1.CustomerCollection(this.client, CustomerPaths.list + queryParameters.toQueryString());
|
|
42
|
-
});
|
|
39
|
+
const queryParameters = new base_1.QueryParameters(queryParams);
|
|
40
|
+
return new entities_1.CustomerCollection(this.client, CustomerPaths.list + queryParameters.toQueryString());
|
|
43
41
|
}
|
|
44
42
|
create(createCustomerParameters) {
|
|
45
43
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -79,5 +77,10 @@ class CustomersResource extends base_1.BaseResource {
|
|
|
79
77
|
return data.map((balance) => new entities_1.CreditBalance(balance));
|
|
80
78
|
});
|
|
81
79
|
}
|
|
80
|
+
archive(customerId) {
|
|
81
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
return yield this.update(customerId, { status: 'archived' });
|
|
83
|
+
});
|
|
84
|
+
}
|
|
82
85
|
}
|
|
83
86
|
exports.CustomersResource = CustomersResource;
|
|
@@ -3,8 +3,9 @@ import { BaseResource } from '../../internal/base';
|
|
|
3
3
|
import { type CreateDiscountRequestBody, type ListDiscountQueryParameters, type UpdateDiscountRequestBody } from './operations';
|
|
4
4
|
export * from './operations';
|
|
5
5
|
export declare class DiscountsResource extends BaseResource {
|
|
6
|
-
list(queryParams?: ListDiscountQueryParameters):
|
|
6
|
+
list(queryParams?: ListDiscountQueryParameters): DiscountCollection;
|
|
7
7
|
create(createDiscountParameters: CreateDiscountRequestBody): Promise<Discount>;
|
|
8
8
|
get(discountId: string): Promise<Discount>;
|
|
9
9
|
update(discountId: string, updateDiscount: UpdateDiscountRequestBody): Promise<Discount>;
|
|
10
|
+
archive(discountId: string): Promise<Discount>;
|
|
10
11
|
}
|
|
@@ -35,10 +35,8 @@ const DiscountPaths = {
|
|
|
35
35
|
__exportStar(require("./operations"), exports);
|
|
36
36
|
class DiscountsResource extends base_1.BaseResource {
|
|
37
37
|
list(queryParams) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return new entities_1.DiscountCollection(this.client, DiscountPaths.list + queryParameters.toQueryString());
|
|
41
|
-
});
|
|
38
|
+
const queryParameters = new base_1.QueryParameters(queryParams);
|
|
39
|
+
return new entities_1.DiscountCollection(this.client, DiscountPaths.list + queryParameters.toQueryString());
|
|
42
40
|
}
|
|
43
41
|
create(createDiscountParameters) {
|
|
44
42
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -67,5 +65,10 @@ class DiscountsResource extends base_1.BaseResource {
|
|
|
67
65
|
return new entities_1.Discount(data);
|
|
68
66
|
});
|
|
69
67
|
}
|
|
68
|
+
archive(discountId) {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
return yield this.update(discountId, { status: 'archived' });
|
|
71
|
+
});
|
|
72
|
+
}
|
|
70
73
|
}
|
|
71
74
|
exports.DiscountsResource = DiscountsResource;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BaseResource } from '../../internal/base';
|
|
2
|
+
import { type ListEventsQueryParameters } from './operations';
|
|
3
|
+
import { EventCollection } from '../../entities';
|
|
4
|
+
export * from './operations';
|
|
5
|
+
export declare class EventsResource extends BaseResource {
|
|
6
|
+
list(queryParams?: ListEventsQueryParameters): EventCollection;
|
|
7
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
exports.EventsResource = void 0;
|
|
18
|
+
const base_1 = require("../../internal/base");
|
|
19
|
+
const entities_1 = require("../../entities");
|
|
20
|
+
const EventPaths = {
|
|
21
|
+
list: '/events',
|
|
22
|
+
};
|
|
23
|
+
__exportStar(require("./operations"), exports);
|
|
24
|
+
class EventsResource extends base_1.BaseResource {
|
|
25
|
+
list(queryParams) {
|
|
26
|
+
const queryParameters = new base_1.QueryParameters(queryParams);
|
|
27
|
+
return new entities_1.EventCollection(this.client, EventPaths.list + queryParameters.toQueryString());
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.EventsResource = EventsResource;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './list-events-query-parameters';
|
|
@@ -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("./list-events-query-parameters"), exports);
|
package/dist/resources/index.js
CHANGED
|
@@ -3,8 +3,9 @@ import { BaseResource } from '../../internal/base';
|
|
|
3
3
|
import { type CreatePriceRequestBody, type GetPriceQueryParameters, type ListPriceQueryParameters, type UpdatePriceRequestBody } from './operations';
|
|
4
4
|
export * from './operations';
|
|
5
5
|
export declare class PricesResource extends BaseResource {
|
|
6
|
-
list(queryParams?: ListPriceQueryParameters):
|
|
6
|
+
list(queryParams?: ListPriceQueryParameters): PriceCollection;
|
|
7
7
|
create(createPriceParameters: CreatePriceRequestBody): Promise<Price>;
|
|
8
8
|
get(priceId: string, queryParams?: GetPriceQueryParameters): Promise<PriceWithIncludes>;
|
|
9
9
|
update(priceId: string, updatePrice: UpdatePriceRequestBody): Promise<Price>;
|
|
10
|
+
archive(priceId: string): Promise<Price>;
|
|
10
11
|
}
|
|
@@ -35,10 +35,8 @@ const PricePaths = {
|
|
|
35
35
|
__exportStar(require("./operations"), exports);
|
|
36
36
|
class PricesResource extends base_1.BaseResource {
|
|
37
37
|
list(queryParams) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return new entities_1.PriceCollection(this.client, PricePaths.list + queryParameters.toQueryString());
|
|
41
|
-
});
|
|
38
|
+
const queryParameters = new base_1.QueryParameters(queryParams);
|
|
39
|
+
return new entities_1.PriceCollection(this.client, PricePaths.list + queryParameters.toQueryString());
|
|
42
40
|
}
|
|
43
41
|
create(createPriceParameters) {
|
|
44
42
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -68,5 +66,10 @@ class PricesResource extends base_1.BaseResource {
|
|
|
68
66
|
return new entities_1.Price(data);
|
|
69
67
|
});
|
|
70
68
|
}
|
|
69
|
+
archive(priceId) {
|
|
70
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
return yield this.update(priceId, { status: 'archived' });
|
|
72
|
+
});
|
|
73
|
+
}
|
|
71
74
|
}
|
|
72
75
|
exports.PricesResource = PricesResource;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BaseResource } from '../../internal/base';
|
|
2
|
+
import { type PricingPreviewRequestBody } from './operations';
|
|
3
|
+
import { PricingPreview } from '../../entities/pricing-preview';
|
|
4
|
+
export * from './operations';
|
|
5
|
+
export declare class PricingPreviewResource extends BaseResource {
|
|
6
|
+
preview(pricePreviewParameter: PricingPreviewRequestBody): Promise<PricingPreview>;
|
|
7
|
+
}
|