Skip to content

Commit 5962542

Browse files
authored
Merge pull request #1511 from Adyen/generate-platform-apis
OpenAPI Generator v7: generate LEM/Configuration/Transfers APIs
2 parents 26349e2 + 1a0f786 commit 5962542

File tree

391 files changed

+11614
-5981
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

391 files changed

+11614
-5981
lines changed

src/__tests__/balancePlatform.spec.ts

Lines changed: 278 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ import { createClient } from "../__mocks__/base";
44
import BalancePlatform from "../services/balancePlatform";
55
import { balancePlatform } from "../typings";
66
import {IRequest} from "../typings/requestOptions";
7+
import { BalanceWebhookSettingInfo } from "../typings/balancePlatform/balanceWebhookSettingInfo";
8+
import { Target } from "../typings/balancePlatform/target";
9+
import { TransferRouteRequest } from "../typings/balancePlatform/transferRouteRequest";
10+
import { IbanAccountIdentification } from "../typings/balancePlatform/ibanAccountIdentification";
11+
import { Condition } from "../typings/balancePlatform/condition";
712

813
let client: Client;
914
let balancePlatformService: BalancePlatform;
@@ -912,4 +917,277 @@ describe("Balance Platform", (): void => {
912917
expect(response.id).toBe(transactionRuleId);
913918
});
914919
});
920+
921+
it("should support POST /validateBankAccountIdentification", async (): Promise<void> => {
922+
923+
scope.post("/validateBankAccountIdentification")
924+
.reply(200);
925+
926+
const request = {
927+
"accountIdentification":
928+
{
929+
"type": IbanAccountIdentification.TypeEnum.Iban,
930+
"iban": "NL91ABNA0417164300"
931+
}
932+
};
933+
934+
await balancePlatformService.BankAccountValidationApi.validateBankAccountIdentification(request);
935+
});
936+
937+
it("should support POST /transferRoutes/calculate with IBAN account identification", async (): Promise<void> => {
938+
const mockResponse = {
939+
"transferRoutes": [
940+
{
941+
"country": "NL",
942+
"currency": "USD",
943+
"priority": "crossBorder",
944+
"requirements": [
945+
{
946+
"description": "Amount of transfer must be at least 100, and no greater than 99999999999",
947+
"max": 99999999999,
948+
"min": 100,
949+
"type": "amountMinMaxRequirement"
950+
},
951+
{
952+
"description": "Country, street and city is required.",
953+
"requiredAddressFields": [
954+
"line1",
955+
"city",
956+
"country"
957+
],
958+
"type": "addressRequirement"
959+
},
960+
{
961+
"description": "Bank account identification type must be iban or numberAndBic",
962+
"bankAccountIdentificationTypes": [
963+
"iban",
964+
"numberAndBic"
965+
],
966+
"type": "bankAccountIdentificationTypeRequirement"
967+
},
968+
{
969+
"issuingCountryCode": "NL",
970+
"paymentInstrumentType": "BankAccount",
971+
"type": "paymentInstrumentRequirement"
972+
}
973+
]
974+
},
975+
{
976+
"country": "NL",
977+
"currency": "USD",
978+
"priority": "wire",
979+
"requirements": [
980+
{
981+
"description": "Amount of transfer must be at least 100, and no greater than 99999999999",
982+
"max": 99999999999,
983+
"min": 100,
984+
"type": "amountMinMaxRequirement"
985+
},
986+
{
987+
"description": "Country, street and city is required.",
988+
"requiredAddressFields": [
989+
"line1",
990+
"city",
991+
"country"
992+
],
993+
"type": "addressRequirement"
994+
},
995+
{
996+
"description": "Bank account identification type must be iban or numberAndBic",
997+
"bankAccountIdentificationTypes": [
998+
"iban",
999+
"numberAndBic"
1000+
],
1001+
"type": "bankAccountIdentificationTypeRequirement"
1002+
},
1003+
{
1004+
"issuingCountryCode": "NL",
1005+
"paymentInstrumentType": "BankAccount",
1006+
"type": "paymentInstrumentRequirement"
1007+
}
1008+
]
1009+
}
1010+
]
1011+
};
1012+
1013+
scope.post("/transferRoutes/calculate")
1014+
.reply(200, mockResponse);
1015+
1016+
const transferRouteRequest = {
1017+
balancePlatform: "123456789",
1018+
currency: "USD",
1019+
category: TransferRouteRequest.CategoryEnum.Bank,
1020+
counterparty: {
1021+
bankAccount: {
1022+
accountIdentification: {
1023+
type: IbanAccountIdentification.TypeEnum.Iban,
1024+
iban: "NL91ABNA0417164300"
1025+
}
1026+
}
1027+
}
1028+
};
1029+
1030+
const response = await balancePlatformService.TransferRoutesApi.calculateTransferRoutes(transferRouteRequest);
1031+
1032+
expect(response).toBeTruthy();
1033+
expect(response.transferRoutes).toBeTruthy();
1034+
expect(response.transferRoutes?.length).toBe(2);
1035+
});
1036+
1037+
it("should support GET /balancePlatforms/{balancePlatformId}/webhooks/{webhookId}/settings", async (): Promise<void> => {
1038+
const balancePlatformId = "123456789";
1039+
const webhookId = "WH00000001";
1040+
1041+
const mockResponse = {
1042+
"webhookSettings": [
1043+
{
1044+
"id": "BWHS00000000000000000000000001",
1045+
"type": "balance",
1046+
"target": {
1047+
"type": "balancePlatform",
1048+
"id": "YOUR_BALANCE_PLATFORM"
1049+
},
1050+
"currency": "USD",
1051+
"status": "active"
1052+
},
1053+
{
1054+
"id": "BWHS00000000000000000000000002",
1055+
"type": "balance",
1056+
"target": {
1057+
"type": "balanceAccount",
1058+
"id": "BA00000000000000000LIABLE"
1059+
},
1060+
"currency": "USD",
1061+
"status": "active"
1062+
}
1063+
]
1064+
};
1065+
1066+
scope.get(`/balancePlatforms/${balancePlatformId}/webhooks/${webhookId}/settings`)
1067+
.reply(200, mockResponse);
1068+
1069+
const response = await balancePlatformService.BalancesApi.getAllWebhookSettings(balancePlatformId, webhookId);
1070+
1071+
expect(response).toBeTruthy();
1072+
expect(response.webhookSettings).toBeTruthy();
1073+
expect(response.webhookSettings?.length).toBe(2);
1074+
// first element
1075+
expect(response.webhookSettings![0].id).toBe("BWHS00000000000000000000000001");
1076+
expect(response.webhookSettings![0].type).toBe("balance");
1077+
// second element
1078+
expect(response.webhookSettings![1].id).toBe("BWHS00000000000000000000000002");
1079+
expect(response.webhookSettings![0].type).toBe("balance");
1080+
});
1081+
1082+
it("should support GET /balancePlatforms/{balancePlatformId}/webhooks/{webhookId}/settings/{settingId}", async (): Promise<void> => {
1083+
const balancePlatformId = "123456789";
1084+
const webhookId = "WH00000001";
1085+
const settingId = "BWHS00000000000000000000000001";
1086+
1087+
const mockResponse = {
1088+
id: "BWHS00000000000000000000000001",
1089+
type: BalanceWebhookSettingInfo.TypeEnum.Balance,
1090+
target: {
1091+
type: Target.TypeEnum.BalanceAccount,
1092+
id: "YOUR_BALANCE_PLATFORM"
1093+
},
1094+
currency: "USD",
1095+
status: BalanceWebhookSettingInfo.StatusEnum.Active
1096+
};
1097+
1098+
scope.get(`/balancePlatforms/${balancePlatformId}/webhooks/${webhookId}/settings/${settingId}`)
1099+
.reply(200, mockResponse);
1100+
1101+
const response = await balancePlatformService.BalancesApi.getWebhookSetting(balancePlatformId, webhookId, settingId);
1102+
1103+
expect(response).toBeTruthy();
1104+
expect(response.id).toBe("BWHS00000000000000000000000001");
1105+
expect(response.currency).toBe("USD");
1106+
});
1107+
1108+
it("should support POST /balancePlatforms/{balancePlatformId}/webhooks/{webhookId}/settings", async (): Promise<void> => {
1109+
const balancePlatformId = "123456789";
1110+
const webhookId = "WH00000001";
1111+
1112+
const mockResponse = {
1113+
id: "BWHS00000000000000000000000001",
1114+
type: BalanceWebhookSettingInfo.TypeEnum.Balance,
1115+
target: {
1116+
type: Target.TypeEnum.BalanceAccount,
1117+
id: "BA00000000000000000LIABLE"
1118+
},
1119+
currency: "USD",
1120+
status: BalanceWebhookSettingInfo.StatusEnum.Active,
1121+
conditions: [
1122+
{
1123+
balanceType: "available",
1124+
conditionType: "lessThan",
1125+
value: 50000
1126+
}
1127+
]
1128+
};
1129+
1130+
scope.post(`/balancePlatforms/${balancePlatformId}/webhooks/${webhookId}/settings`)
1131+
.reply(200, mockResponse);
1132+
1133+
const request = {
1134+
type: BalanceWebhookSettingInfo.TypeEnum.Balance,
1135+
target: {
1136+
type: Target.TypeEnum.BalanceAccount,
1137+
id: "BA00000000000000000LIABLE"
1138+
},
1139+
currency: "USD",
1140+
status: BalanceWebhookSettingInfo.StatusEnum.Active,
1141+
conditions: [
1142+
{
1143+
balanceType: Condition.BalanceTypeEnum.Available,
1144+
conditionType: Condition.ConditionTypeEnum.LessThan,
1145+
value: 50000
1146+
}
1147+
]
1148+
};
1149+
1150+
const response = await balancePlatformService.BalancesApi.createWebhookSetting(balancePlatformId, webhookId, request);
1151+
1152+
expect(response).toBeTruthy();
1153+
expect(response.id).toBe("BWHS00000000000000000000000001");
1154+
expect(response.currency).toBe("USD");
1155+
});
1156+
1157+
it("should support PATCH /balancePlatforms/{balancePlatformId}/webhooks/{webhookId}/settings/{settingId}", async (): Promise<void> => {
1158+
const balancePlatformId = "123456789";
1159+
const webhookId = "WH00000001";
1160+
const settingId = "BWHS00000000000000000000000001";
1161+
1162+
const mockResponse = {
1163+
id: "BWHS00000000000000000000000001",
1164+
type: BalanceWebhookSettingInfo.TypeEnum.Balance,
1165+
target: {
1166+
type: Target.TypeEnum.BalanceAccount,
1167+
id: "BA00000000000000000LIABLE"
1168+
},
1169+
currency: "USD",
1170+
status: BalanceWebhookSettingInfo.StatusEnum.Active
1171+
};
1172+
1173+
scope.patch(`/balancePlatforms/${balancePlatformId}/webhooks/${webhookId}/settings/${settingId}`)
1174+
.reply(200, mockResponse);
1175+
1176+
const request = {
1177+
type: BalanceWebhookSettingInfo.TypeEnum.Balance,
1178+
target: {
1179+
type: Target.TypeEnum.BalanceAccount,
1180+
id: "BA00000000000000000LIABLE"
1181+
},
1182+
currency: "USD",
1183+
status: BalanceWebhookSettingInfo.StatusEnum.Active
1184+
};
1185+
1186+
const response = await balancePlatformService.BalancesApi.updateWebhookSetting(balancePlatformId, webhookId, settingId, request);
1187+
1188+
expect(response).toBeTruthy();
1189+
expect(response.id).toBe("BWHS00000000000000000000000001");
1190+
expect(response.currency).toBe("USD");
1191+
});
1192+
9151193
});

0 commit comments

Comments
 (0)