-
Notifications
You must be signed in to change notification settings - Fork 104
/
Copy pathwebhook_notification.js
107 lines (90 loc) · 4.42 KB
/
webhook_notification.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
'use strict';
let AttributeSetter = require('./attribute_setter').AttributeSetter;
let MerchantAccount = require('./merchant_account').MerchantAccount;
let Transaction = require('./transaction').Transaction;
let Disbursement = require('./disbursement').Disbursement;
let Dispute = require('./dispute').Dispute;
let ConnectedMerchantStatusTransitioned = require('./connected_merchant_status_transitioned').ConnectedMerchantStatusTransitioned;
let ConnectedMerchantPayPalStatusChanged = require('./connected_merchant_paypal_status_changed').ConnectedMerchantPayPalStatusChanged;
let PartnerMerchant = require('./partner_merchant').PartnerMerchant;
let Subscription = require('./subscription').Subscription;
let AccountUpdaterDailyReport = require('./account_updater_daily_report').AccountUpdaterDailyReport;
let IdealPayment = require('./ideal_payment').IdealPayment;
let ValidationErrorsCollection = require('./validation_errors_collection').ValidationErrorsCollection;
class WebhookNotification extends AttributeSetter {
static initClass() {
this.Kind = {
AccountUpdaterDailyReport: 'account_updater_daily_report',
Check: 'check',
ConnectedMerchantPayPalStatusChanged: 'connected_merchant_paypal_status_changed',
ConnectedMerchantStatusTransitioned: 'connected_merchant_status_transitioned',
Disbursement: 'disbursement',
DisbursementException: 'disbursement_exception',
DisputeOpened: 'dispute_opened',
DisputeLost: 'dispute_lost',
DisputeWon: 'dispute_won',
IdealPaymentComplete: 'ideal_payment_complete',
IdealPaymentFailed: 'ideal_payment_failed',
PartnerMerchantConnected: 'partner_merchant_connected',
PartnerMerchantDisconnected: 'partner_merchant_disconnected',
PartnerMerchantDeclined: 'partner_merchant_declined',
SubscriptionCanceled: 'subscription_canceled',
SubscriptionChargedSuccessfully: 'subscription_charged_successfully',
SubscriptionChargedUnsuccessfully: 'subscription_charged_unsuccessfully',
SubscriptionExpired: 'subscription_expired',
SubscriptionTrialEnded: 'subscription_trial_ended',
SubscriptionWentActive: 'subscription_went_active',
SubscriptionWentPastDue: 'subscription_went_past_due',
SubMerchantAccountApproved: 'sub_merchant_account_approved',
SubMerchantAccountDeclined: 'sub_merchant_account_declined',
TransactionDisbursed: 'transaction_disbursed',
TransactionSettled: 'transaction_settled',
TransactionSettlementDeclined: 'transaction_settlement_declined'
};
}
constructor(attributes) {
super(attributes);
let wrapperNode;
if (attributes.subject.apiErrorResponse != null) {
wrapperNode = attributes.subject.apiErrorResponse;
} else {
wrapperNode = attributes.subject;
}
if (wrapperNode.subscription != null) {
this.subscription = new Subscription(wrapperNode.subscription);
}
if (wrapperNode.merchantAccount != null) {
this.merchantAccount = new MerchantAccount(wrapperNode.merchantAccount);
}
if (wrapperNode.disbursement != null) {
this.disbursement = new Disbursement(wrapperNode.disbursement);
}
if (wrapperNode.transaction != null) {
this.transaction = new Transaction(wrapperNode.transaction);
}
if (wrapperNode.partnerMerchant != null) {
this.partnerMerchant = new PartnerMerchant(wrapperNode.partnerMerchant);
}
if (wrapperNode.connectedMerchantStatusTransitioned != null) {
this.connectedMerchantStatusTransitioned = new ConnectedMerchantStatusTransitioned(wrapperNode.connectedMerchantStatusTransitioned);
}
if (wrapperNode.connectedMerchantPaypalStatusChanged != null) {
this.connectedMerchantPayPalStatusChanged = new ConnectedMerchantPayPalStatusChanged(wrapperNode.connectedMerchantPaypalStatusChanged);
}
if (wrapperNode.dispute != null) {
this.dispute = new Dispute(wrapperNode.dispute);
}
if (wrapperNode.accountUpdaterDailyReport != null) {
this.accountUpdaterDailyReport = new AccountUpdaterDailyReport(wrapperNode.accountUpdaterDailyReport);
}
if (wrapperNode.idealPayment != null) {
this.idealPayment = new IdealPayment(wrapperNode.idealPayment);
}
if (wrapperNode.errors != null) {
this.errors = new ValidationErrorsCollection(wrapperNode.errors);
this.message = wrapperNode.message;
}
}
}
WebhookNotification.initClass();
module.exports = {WebhookNotification: WebhookNotification};