• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In
Build has been canceled!

Adyen / adyen-node-api-library / 13117287171

03 Feb 2025 03:45PM UTC coverage: 59.727%. First build
13117287171

Pull #1459

github

web-flow
Merge bdd05c279 into 47f7b83c6
Pull Request #1459: Add negativeBalanceWarningWebhook to bankingWebhookHandler

261 of 806 branches covered (32.38%)

Branch coverage included in aggregate %.

3 of 4 new or added lines in 1 file covered. (75.0%)

2017 of 3008 relevant lines covered (67.05%)

24.73 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

55.56
/src/notification/bankingWebhookHandler.ts
1
/*
2
 * Adyen NodeJS API Library
3
 * Copyright (c) 2023 Adyen B.V.
4
 * This file is open source and available under the MIT license.
5
 * See the LICENSE file for more info.
6
 */
7

8
import {configurationWebhooks, acsWebhooks, reportWebhooks, transferWebhooks, transactionWebhooks, negativeBalanceWarningWebhooks} from "../typings";
2✔
9

10
class BankingWebhookHandler {
11
    private readonly payload: string;
12

13
    public constructor(jsonPayload: string) {
14
        this.payload = JSON.parse(jsonPayload);
8✔
15
    }
16

17
    // Return generic webhook type
18
    public getGenericWebhook(): acsWebhooks.AuthenticationNotificationRequest
19
        | configurationWebhooks.AccountHolderNotificationRequest
20
        | configurationWebhooks.BalanceAccountNotificationRequest
21
        | configurationWebhooks.PaymentNotificationRequest
22
        | configurationWebhooks.SweepConfigurationNotificationRequest
23
        | configurationWebhooks.CardOrderNotificationRequest
24
        | negativeBalanceWarningWebhooks.NegativeBalanceCompensationWarningNotificationRequest
25
        | reportWebhooks.ReportNotificationRequest
26
        | transferWebhooks.TransferNotificationRequest
27
        | transactionWebhooks.TransactionNotificationRequestV4 {
28
        const type = this.payload["type"];
6✔
29

30
        if(Object.values(acsWebhooks.AuthenticationNotificationRequest.TypeEnum).includes(type)){
6✔
31
            return this.getAuthenticationNotificationRequest();
2✔
32
        }
33

34
        if(Object.values(configurationWebhooks.AccountHolderNotificationRequest.TypeEnum).includes(type)){
4✔
35
            return this.getAccountHolderNotificationRequest();
2✔
36
        }
37

38
        if(Object.values(configurationWebhooks.BalanceAccountNotificationRequest.TypeEnum).includes(type)){
2!
39
            return this.getBalanceAccountNotificationRequest();
×
40
        }
41

42
        if(Object.values(configurationWebhooks.CardOrderNotificationRequest.TypeEnum).includes(type)){
2!
43
            return this.getCardOrderNotificationRequest();
×
44
        }
45

46
        if(Object.values(configurationWebhooks.PaymentNotificationRequest.TypeEnum).includes(type)){
2!
47
            return this.getPaymentNotificationRequest();
×
48
        }
49

50
        if(Object.values(configurationWebhooks.SweepConfigurationNotificationRequest.TypeEnum).includes(type)){
2!
51
            return this.getSweepConfigurationNotificationRequest();
×
52
        }
53

54
        if(Object.values(negativeBalanceWarningWebhooks.NegativeBalanceCompensationWarningNotificationRequest.TypeEnum).includes(type)){
2!
NEW
55
            return this.getNegativeBalanceCompensationWarningNotificationRequest();
×
56
        }
57

58
        if(Object.values(reportWebhooks.ReportNotificationRequest.TypeEnum).includes(type)){
2!
59
            return this.getReportNotificationRequest();
×
60
        }
61

62
        if(Object.values(transferWebhooks.TransferNotificationRequest.TypeEnum).includes(type)){
2!
63
            return this.getTransferNotificationRequest();
×
64
        }
65

66
        if(Object.values(transactionWebhooks.TransactionNotificationRequestV4.TypeEnum).includes(type)){
2✔
67
            return this.getTransactionNotificationRequest();
2✔
68
        }
69

70
        throw new Error("Could not parse the json payload: " + this.payload);
×
71
    }
72

73
    public getAuthenticationNotificationRequest(): acsWebhooks.AuthenticationNotificationRequest {
74
        return acsWebhooks.ObjectSerializer.deserialize(this.payload, "AuthenticationNotificationRequest");
2✔
75
    }
76

77
    public getAccountHolderNotificationRequest(): configurationWebhooks.AccountHolderNotificationRequest {
78
        return configurationWebhooks.ObjectSerializer.deserialize(this.payload, "AccountHolderNotificationRequest");
4✔
79
    }
80

81
    public getBalanceAccountNotificationRequest(): configurationWebhooks.BalanceAccountNotificationRequest {
82
        return configurationWebhooks.ObjectSerializer.deserialize(this.payload, "BalanceAccountNotificationRequest");
×
83
    }
84

85
    public getCardOrderNotificationRequest(): configurationWebhooks.CardOrderNotificationRequest {
86
        return configurationWebhooks.ObjectSerializer.deserialize(this.payload, "CardOrderNotificationRequest");
×
87
    }
88

89
    public getPaymentNotificationRequest(): configurationWebhooks.PaymentNotificationRequest {
90
        return configurationWebhooks.ObjectSerializer.deserialize(this.payload, "PaymentNotificationRequest");
×
91
    }
92

93
    public getSweepConfigurationNotificationRequest(): configurationWebhooks.SweepConfigurationNotificationRequest {
94
        return configurationWebhooks.ObjectSerializer.deserialize(this.payload, "SweepConfigurationNotificationRequest");
×
95
    }
96
    
97
    public getNegativeBalanceCompensationWarningNotificationRequest(): negativeBalanceWarningWebhooks.NegativeBalanceCompensationWarningNotificationRequest {
98
        return negativeBalanceWarningWebhooks.ObjectSerializer.deserialize(this.payload, "NegativeBalanceCompensationWarningNotificationRequest");
2✔
99
    }
100

101
    public getReportNotificationRequest(): reportWebhooks.ReportNotificationRequest {
102
        return reportWebhooks.ObjectSerializer.deserialize(this.payload, "ReportNotificationRequest");
×
103
    }
104

105
    public getTransferNotificationRequest(): transferWebhooks.TransferNotificationRequest {
106
        return transferWebhooks.ObjectSerializer.deserialize(this.payload, "TransferNotificationRequest");
2✔
107
    }
108

109
    public getTransactionNotificationRequest(): transactionWebhooks.TransactionNotificationRequestV4 {
110
        return transactionWebhooks.ObjectSerializer.deserialize(this.payload, "TransactionNotificationRequestV4");
4✔
111
    }
112
}
113

114
export default BankingWebhookHandler;
2✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc