• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Adyen / adyen-node-api-library / 6610509535

23 Oct 2023 08:14AM UTC coverage: 75.066%. First build
6610509535

Pull #1235

github

web-flow
Merge 52fdd2561 into 3e8e1629d
Pull Request #1235: update makefile, readme and tests to upgrade Transfers and Management API

104 of 156 branches covered (0.0%)

Branch coverage included in aggregate %.

50 of 50 new or added lines in 33 files covered. (100.0%)

1898 of 2511 relevant lines covered (75.59%)

28.56 hits per line

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

56.0
/src/notification/managementWebhookHandler.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
import {managementWebhooks} from "../typings";
2✔
8

9
class ManagementWebhookHandler {
10
    private readonly payload: string;
11

12
    public constructor(jsonPayload: string) {
13
        this.payload = JSON.parse(jsonPayload)
4✔
14
    }
15

16
    // Return generic webhook type
17
    public getGenericWebhook(): managementWebhooks.MerchantUpdatedNotificationRequest
18
        | managementWebhooks.MerchantCreatedNotificationRequest
19
        | managementWebhooks.PaymentMethodCreatedNotificationRequest
20
        | managementWebhooks.PaymentMethodRequestRemovedNotificationRequest
21
        | managementWebhooks.PaymentMethodScheduledForRemovalNotificationRequest {
22
        const type = this.payload['type'];
4✔
23
        if(Object.values(managementWebhooks.MerchantCreatedNotificationRequest.TypeEnum).includes(type)){
4!
24
            return this.getMerchantCreatedNotificationRequest();
×
25
        }
26

27
        if(Object.values(managementWebhooks.MerchantUpdatedNotificationRequest.TypeEnum).includes(type)){
4!
28
            return this.getMerchantUpdatedNotificationRequest();
×
29
        }
30

31
        if(Object.values(managementWebhooks.PaymentMethodCreatedNotificationRequest.TypeEnum).includes(type)){
4✔
32
            return this.getPaymentMethodCreatedNotificationRequest();
2✔
33
        }
34

35
        if(Object.values(managementWebhooks.PaymentMethodRequestRemovedNotificationRequest.TypeEnum).includes(type)){
2✔
36
            return this.getPaymentMethodRequestRemovedNotificationRequest();
2✔
37
        }
38

39
        if(Object.values(managementWebhooks.PaymentMethodScheduledForRemovalNotificationRequest.TypeEnum).includes(type)){
×
40
            return this.getPaymentMethodScheduledForRemovalNotificationRequest();
×
41
        }
42

43
        throw new Error("Could not parse the json payload: " + this.payload)
×
44
    }
45

46
    public getMerchantCreatedNotificationRequest(): managementWebhooks.MerchantCreatedNotificationRequest {
47
        return managementWebhooks.ObjectSerializer.deserialize(this.payload, "MerchantCreatedNotificationRequest");
×
48
    }
49

50
    public getMerchantUpdatedNotificationRequest(): managementWebhooks.MerchantUpdatedNotificationRequest {
51
        return managementWebhooks.ObjectSerializer.deserialize(this.payload, "MerchantUpdatedNotificationRequest");
×
52
    }
53

54
    public getPaymentMethodCreatedNotificationRequest(): managementWebhooks.PaymentMethodCreatedNotificationRequest {
55
        return managementWebhooks.ObjectSerializer.deserialize(this.payload, "PaymentMethodCreatedNotificationRequest");
4✔
56
    }
57

58
    public getPaymentMethodRequestRemovedNotificationRequest(): managementWebhooks.PaymentMethodRequestRemovedNotificationRequest {
59
        return managementWebhooks.ObjectSerializer.deserialize(this.payload, "PaymentMethodRequestRemovedNotificationRequest");
4✔
60
    }
61

62
    public getPaymentMethodScheduledForRemovalNotificationRequest(): managementWebhooks.PaymentMethodScheduledForRemovalNotificationRequest {
63
        return managementWebhooks.ObjectSerializer.deserialize(this.payload, "PaymentMethodScheduledForRemovalNotificationRequest");
×
64
    }
65

66
}
67

68
export default ManagementWebhookHandler;
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

© 2026 Coveralls, Inc