Skip to content

Commit c9106af

Browse files
committed
Generate BalanceWebhooks
1 parent 034925b commit c9106af

File tree

7 files changed

+497
-197
lines changed

7 files changed

+497
-197
lines changed

src/typings/balanceWebhooks/balanceAccountBalanceNotificationRequest.ts

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,50 +7,60 @@
77
* Do not edit this class manually.
88
*/
99

10-
import { BalanceNotificationData } from './balanceNotificationData';
10+
import { BalanceNotificationData } from "./balanceNotificationData";
11+
1112

1213
export class BalanceAccountBalanceNotificationRequest {
13-
'data': BalanceNotificationData;
14+
"data": BalanceNotificationData;
1415
/**
1516
* The environment from which the webhook originated. Possible values: **test**, **live**.
1617
*/
17-
'environment': string;
18+
"environment": string;
1819
/**
1920
* When the event was queued.
2021
*/
21-
'timestamp'?: Date;
22+
"timestamp"?: Date;
2223
/**
2324
* Type of webhook.
2425
*/
25-
'type': BalanceAccountBalanceNotificationRequest.TypeEnum;
26+
"type": BalanceAccountBalanceNotificationRequest.TypeEnum;
27+
28+
static readonly discriminator: string | undefined = undefined;
2629

27-
static discriminator: string | undefined = undefined;
30+
static readonly mapping: {[index: string]: string} | undefined = undefined;
2831

29-
static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
32+
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
3033
{
3134
"name": "data",
3235
"baseName": "data",
33-
"type": "BalanceNotificationData"
36+
"type": "BalanceNotificationData",
37+
"format": ""
3438
},
3539
{
3640
"name": "environment",
3741
"baseName": "environment",
38-
"type": "string"
42+
"type": "string",
43+
"format": ""
3944
},
4045
{
4146
"name": "timestamp",
4247
"baseName": "timestamp",
43-
"type": "Date"
48+
"type": "Date",
49+
"format": "date-time"
4450
},
4551
{
4652
"name": "type",
4753
"baseName": "type",
48-
"type": "BalanceAccountBalanceNotificationRequest.TypeEnum"
54+
"type": "BalanceAccountBalanceNotificationRequest.TypeEnum",
55+
"format": ""
4956
} ];
5057

5158
static getAttributeTypeMap() {
5259
return BalanceAccountBalanceNotificationRequest.attributeTypeMap;
5360
}
61+
62+
public constructor() {
63+
}
5464
}
5565

5666
export namespace BalanceAccountBalanceNotificationRequest {

src/typings/balanceWebhooks/balanceNotificationData.ts

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,76 +7,89 @@
77
* Do not edit this class manually.
88
*/
99

10-
import { Balances } from './balances';
10+
import { Balances } from "./balances";
11+
1112

1213
export class BalanceNotificationData {
1314
/**
1415
* The unique identifier of the balance account.
1516
*/
16-
'balanceAccountId': string;
17+
"balanceAccountId": string;
1718
/**
1819
* The unique identifier of the balance platform.
1920
*/
20-
'balancePlatform'?: string;
21-
'balances': Balances;
21+
"balancePlatform"?: string;
22+
"balances": Balances;
2223
/**
2324
* The date and time when the event was triggered, in ISO 8601 extended format. For example, **2020-12-18T10:15:30+01:00**.
2425
*/
25-
'creationDate'?: Date;
26+
"creationDate"?: Date;
2627
/**
2728
* TThe three-character [ISO currency code](https://docs.adyen.com/development-resources/currency-codes).
2829
*/
29-
'currency': string;
30+
"currency": string;
3031
/**
3132
* The ID of the resource.
3233
*/
33-
'id'?: string;
34+
"id"?: string;
3435
/**
3536
* The unique identifier of the balance webhook setting.
3637
*/
37-
'settingIds': Array<string>;
38+
"settingIds": Array<string>;
39+
40+
static readonly discriminator: string | undefined = undefined;
3841

39-
static discriminator: string | undefined = undefined;
42+
static readonly mapping: {[index: string]: string} | undefined = undefined;
4043

41-
static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
44+
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
4245
{
4346
"name": "balanceAccountId",
4447
"baseName": "balanceAccountId",
45-
"type": "string"
48+
"type": "string",
49+
"format": ""
4650
},
4751
{
4852
"name": "balancePlatform",
4953
"baseName": "balancePlatform",
50-
"type": "string"
54+
"type": "string",
55+
"format": ""
5156
},
5257
{
5358
"name": "balances",
5459
"baseName": "balances",
55-
"type": "Balances"
60+
"type": "Balances",
61+
"format": ""
5662
},
5763
{
5864
"name": "creationDate",
5965
"baseName": "creationDate",
60-
"type": "Date"
66+
"type": "Date",
67+
"format": "date-time"
6168
},
6269
{
6370
"name": "currency",
6471
"baseName": "currency",
65-
"type": "string"
72+
"type": "string",
73+
"format": ""
6674
},
6775
{
6876
"name": "id",
6977
"baseName": "id",
70-
"type": "string"
78+
"type": "string",
79+
"format": ""
7180
},
7281
{
7382
"name": "settingIds",
7483
"baseName": "settingIds",
75-
"type": "Array<string>"
84+
"type": "Array<string>",
85+
"format": ""
7686
} ];
7787

7888
static getAttributeTypeMap() {
7989
return BalanceNotificationData.attributeTypeMap;
8090
}
91+
92+
public constructor() {
93+
}
8194
}
8295

src/typings/balanceWebhooks/balancePlatformNotificationResponse.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,25 @@ export class BalancePlatformNotificationResponse {
1212
/**
1313
* Respond with any **2xx** HTTP status code to [accept the webhook](https://docs.adyen.com/development-resources/webhooks#accept-notifications).
1414
*/
15-
'notificationResponse'?: string;
15+
"notificationResponse"?: string;
1616

17-
static discriminator: string | undefined = undefined;
17+
static readonly discriminator: string | undefined = undefined;
1818

19-
static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
19+
static readonly mapping: {[index: string]: string} | undefined = undefined;
20+
21+
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
2022
{
2123
"name": "notificationResponse",
2224
"baseName": "notificationResponse",
23-
"type": "string"
25+
"type": "string",
26+
"format": ""
2427
} ];
2528

2629
static getAttributeTypeMap() {
2730
return BalancePlatformNotificationResponse.attributeTypeMap;
2831
}
32+
33+
public constructor() {
34+
}
2935
}
3036

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* The version of the OpenAPI document: v1
3+
*
4+
*
5+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
6+
* https://openapi-generator.tech
7+
* Do not edit this class manually.
8+
*/
9+
10+
import { balanceWebhooks } from "..";
11+
12+
/**
13+
* Union type for all supported webhook requests.
14+
* Allows generic handling of configuration-related webhook events.
15+
*/
16+
export type GenericWebhook =
17+
| balanceWebhooks.BalanceAccountBalanceNotificationRequest;
18+
19+
/**
20+
* Handler for processing BalanceWebhooks.
21+
*
22+
* This class provides functionality to deserialize the payload of BalanceWebhooks events.
23+
*/
24+
export class BalanceWebhooksHandler {
25+
26+
private readonly payload: Record<string, any>;
27+
28+
public constructor(jsonPayload: string) {
29+
this.payload = JSON.parse(jsonPayload);
30+
}
31+
32+
/**
33+
* This method checks the type of the webhook payload and returns the appropriate deserialized object.
34+
*
35+
* @returns A deserialized object of type GenericWebhook.
36+
* @throws Error if the type is not recognized.
37+
*/
38+
public getGenericWebhook(): GenericWebhook {
39+
40+
const type = this.payload["type"];
41+
42+
if(Object.values(balanceWebhooks.BalanceAccountBalanceNotificationRequest.TypeEnum).includes(type)) {
43+
return this.getBalanceAccountBalanceNotificationRequest();
44+
}
45+
46+
throw new Error("Could not parse the json payload: " + this.payload);
47+
48+
}
49+
50+
/**
51+
* Deserialize the webhook payload into a BalanceAccountBalanceNotificationRequest
52+
*
53+
* @returns Deserialized BalanceAccountBalanceNotificationRequest object.
54+
*/
55+
public getBalanceAccountBalanceNotificationRequest(): balanceWebhooks.BalanceAccountBalanceNotificationRequest {
56+
return balanceWebhooks.ObjectSerializer.deserialize(this.payload, "BalanceAccountBalanceNotificationRequest");
57+
}
58+
59+
}

src/typings/balanceWebhooks/balances.ts

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,46 +12,55 @@ export class Balances {
1212
/**
1313
* The balance that is available for use.
1414
*/
15-
'available'?: number;
15+
"available"?: number;
1616
/**
1717
* The sum of transactions that have already been settled.
1818
*/
19-
'balance'?: number;
19+
"balance"?: number;
2020
/**
2121
* The sum of transactions that will be settled in the future.
2222
*/
23-
'pending'?: number;
23+
"pending"?: number;
2424
/**
2525
* The balance currently held in reserve.
2626
*/
27-
'reserved'?: number;
27+
"reserved"?: number;
2828

29-
static discriminator: string | undefined = undefined;
29+
static readonly discriminator: string | undefined = undefined;
3030

31-
static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
31+
static readonly mapping: {[index: string]: string} | undefined = undefined;
32+
33+
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
3234
{
3335
"name": "available",
3436
"baseName": "available",
35-
"type": "number"
37+
"type": "number",
38+
"format": "int64"
3639
},
3740
{
3841
"name": "balance",
3942
"baseName": "balance",
40-
"type": "number"
43+
"type": "number",
44+
"format": "int64"
4145
},
4246
{
4347
"name": "pending",
4448
"baseName": "pending",
45-
"type": "number"
49+
"type": "number",
50+
"format": "int64"
4651
},
4752
{
4853
"name": "reserved",
4954
"baseName": "reserved",
50-
"type": "number"
55+
"type": "number",
56+
"format": "int64"
5157
} ];
5258

5359
static getAttributeTypeMap() {
5460
return Balances.attributeTypeMap;
5561
}
62+
63+
public constructor() {
64+
}
5665
}
5766

0 commit comments

Comments
 (0)