Skip to content

Commit f120890

Browse files
authored
Merge branch 'main' into cloud-devices-api
2 parents eb9d7f6 + b5c36ce commit f120890

Some content is hidden

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

43 files changed

+1363
-46
lines changed

src/__tests__/balancePlatform.spec.ts

Lines changed: 296 additions & 33 deletions
Large diffs are not rendered by default.

src/__tests__/httpURLConnectionClient.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ describe("HttpURLConnectionClient", () => {
1313
"https://sub.adyen.com",
1414
"http://another.adyen.com/a/b/c?q=1",
1515
"https://checkout-test.adyen.com",
16+
"https://custom-url.adyenpayments.com",
1617
])("should return true for valid adyen.com domain: %s", (location) => {
1718
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
1819
// @ts-ignore - testing a private method

src/httpClient/httpURLConnectionClient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,8 @@ class HttpURLConnectionClient implements ClientInterface {
279279
private verifyLocation(location: string): boolean {
280280
try {
281281
const url = new URL(location);
282-
// allow-list of trusted domains (*.adyen.com)
283-
const allowedHostnameRegex = /\.adyen\.com$/i;
282+
// allow-list of trusted domains (*.adyen.com, *.adyenpayments.com)
283+
const allowedHostnameRegex = /(\.adyen\.com|\.adyenpayments\.com)$/i;
284284
return allowedHostnameRegex.test(url.hostname);
285285
} catch (e) {
286286
return false;

src/services/balancePlatform/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import { PaymentInstrumentGroupsApi } from "./paymentInstrumentGroupsApi";
2222
import { PaymentInstrumentsApi } from "./paymentInstrumentsApi";
2323
import { PlatformApi } from "./platformApi";
2424
import { TransactionRulesApi } from "./transactionRulesApi";
25+
import { TransferLimitsBalanceAccountLevelApi } from "./transferLimitsBalanceAccountLevelApi";
26+
import { TransferLimitsBalancePlatformLevelApi } from "./transferLimitsBalancePlatformLevelApi";
2527
import { TransferRoutesApi } from "./transferRoutesApi";
2628

2729
import Service from "../../service";
@@ -93,6 +95,14 @@ export default class BalancePlatformAPI extends Service {
9395
return new TransactionRulesApi(this.client);
9496
}
9597

98+
public get TransferLimitsBalanceAccountLevelApi() {
99+
return new TransferLimitsBalanceAccountLevelApi(this.client);
100+
}
101+
102+
public get TransferLimitsBalancePlatformLevelApi() {
103+
return new TransferLimitsBalancePlatformLevelApi(this.client);
104+
}
105+
96106
public get TransferRoutesApi() {
97107
return new TransferRoutesApi(this.client);
98108
}
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
/*
2+
* The version of the OpenAPI document: v2
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+
11+
import getJsonResponse from "../../helpers/getJsonResponse";
12+
import Service from "../../service";
13+
import Client from "../../client";
14+
import { IRequest } from "../../typings/requestOptions";
15+
import Resource from "../resource";
16+
17+
import { ObjectSerializer } from "../../typings/balancePlatform/objectSerializer";
18+
import { ApproveTransferLimitRequest } from "../../typings/balancePlatform/models";
19+
import { CreateTransferLimitRequest } from "../../typings/balancePlatform/models";
20+
import { LimitStatus } from "../../typings/balancePlatform/models";
21+
import { Scope } from "../../typings/balancePlatform/models";
22+
import { TransferLimit } from "../../typings/balancePlatform/models";
23+
import { TransferLimitListResponse } from "../../typings/balancePlatform/models";
24+
import { TransferType } from "../../typings/balancePlatform/models";
25+
26+
/**
27+
* API handler for TransferLimitsBalanceAccountLevelApi
28+
*/
29+
export class TransferLimitsBalanceAccountLevelApi extends Service {
30+
31+
private readonly API_BASEPATH: string = "https://balanceplatform-api-test.adyen.com/bcl/v2";
32+
private baseUrl: string;
33+
34+
public constructor(client: Client){
35+
super(client);
36+
this.baseUrl = this.createBaseUrl(this.API_BASEPATH);
37+
}
38+
39+
/**
40+
* @summary Approve pending transfer limits
41+
* @param id {@link string } The unique identifier of the balance account.
42+
* @param approveTransferLimitRequest {@link ApproveTransferLimitRequest }
43+
* @param requestOptions {@link IRequest.Options }
44+
* @return {@link void }
45+
*/
46+
public async approvePendingTransferLimits(id: string, approveTransferLimitRequest: ApproveTransferLimitRequest, requestOptions?: IRequest.Options): Promise<void> {
47+
const endpoint = `${this.baseUrl}/balanceAccounts/{id}/transferLimits/approve`
48+
.replace("{" + "id" + "}", encodeURIComponent(String(id)));
49+
const resource = new Resource(this, endpoint);
50+
51+
const request: ApproveTransferLimitRequest = ObjectSerializer.serialize(approveTransferLimitRequest, "ApproveTransferLimitRequest");
52+
await getJsonResponse<ApproveTransferLimitRequest, void>(
53+
resource,
54+
request,
55+
{ ...requestOptions, method: "POST" }
56+
);
57+
}
58+
59+
/**
60+
* @summary Create a transfer limit
61+
* @param id {@link string } The unique identifier of the balance account.
62+
* @param createTransferLimitRequest {@link CreateTransferLimitRequest }
63+
* @param requestOptions {@link IRequest.Options }
64+
* @return {@link TransferLimit }
65+
*/
66+
public async createTransferLimit(id: string, createTransferLimitRequest: CreateTransferLimitRequest, requestOptions?: IRequest.Options): Promise<TransferLimit> {
67+
const endpoint = `${this.baseUrl}/balanceAccounts/{id}/transferLimits`
68+
.replace("{" + "id" + "}", encodeURIComponent(String(id)));
69+
const resource = new Resource(this, endpoint);
70+
71+
const request: CreateTransferLimitRequest = ObjectSerializer.serialize(createTransferLimitRequest, "CreateTransferLimitRequest");
72+
const response = await getJsonResponse<CreateTransferLimitRequest, TransferLimit>(
73+
resource,
74+
request,
75+
{ ...requestOptions, method: "POST" }
76+
);
77+
78+
return ObjectSerializer.deserialize(response, "TransferLimit");
79+
}
80+
81+
/**
82+
* @summary Delete a scheduled or pending transfer limit
83+
* @param transferLimitId {@link string } The unique identifier of the transfer limit.
84+
* @param id {@link string } The unique identifier of the balance account.
85+
* @param requestOptions {@link IRequest.Options }
86+
* @return {@link void }
87+
*/
88+
public async deletePendingTransferLimit(transferLimitId: string, id: string, requestOptions?: IRequest.Options): Promise<void> {
89+
const endpoint = `${this.baseUrl}/balanceAccounts/{id}/transferLimits/{transferLimitId}`
90+
.replace("{" + "transferLimitId" + "}", encodeURIComponent(String(transferLimitId)))
91+
.replace("{" + "id" + "}", encodeURIComponent(String(id)));
92+
const resource = new Resource(this, endpoint);
93+
94+
await getJsonResponse<string, void>(
95+
resource,
96+
"",
97+
{ ...requestOptions, method: "DELETE" }
98+
);
99+
}
100+
101+
/**
102+
* @summary Get all current transfer limits
103+
* @param id {@link string } The unique identifier of the balance account.
104+
* @param requestOptions {@link IRequest.Options }
105+
* @param scope {@link Scope } The scope to which the transfer limit applies. Possible values: * **perTransaction**: you set a maximum amount for each transfer made from the balance account or balance platform. * **perDay**: you set a maximum total amount for all transfers made from the balance account or balance platform in a day.
106+
* @param transferType {@link TransferType } The type of transfer to which the limit applies. Possible values: * **instant**: the limit applies to transfers with an **instant** priority. * **all**: the limit applies to all transfers, regardless of priority.
107+
* @return {@link TransferLimitListResponse }
108+
*/
109+
public async getCurrentTransferLimits(id: string, scope?: Scope, transferType?: TransferType, requestOptions?: IRequest.Options): Promise<TransferLimitListResponse> {
110+
const endpoint = `${this.baseUrl}/balanceAccounts/{id}/transferLimits/current`
111+
.replace("{" + "id" + "}", encodeURIComponent(String(id)));
112+
const resource = new Resource(this, endpoint);
113+
114+
const hasDefinedQueryParams = scope ?? transferType;
115+
if(hasDefinedQueryParams) {
116+
if(!requestOptions) requestOptions = {};
117+
if(!requestOptions.params) requestOptions.params = {};
118+
if(scope) requestOptions.params["scope"] = scope;
119+
if(transferType) requestOptions.params["transferType"] = transferType;
120+
}
121+
const response = await getJsonResponse<string, TransferLimitListResponse>(
122+
resource,
123+
"",
124+
{ ...requestOptions, method: "GET" }
125+
);
126+
127+
return ObjectSerializer.deserialize(response, "TransferLimitListResponse");
128+
}
129+
130+
/**
131+
* @summary Get the details of a transfer limit
132+
* @param transferLimitId {@link string } The unique identifier of the transfer limit.
133+
* @param id {@link string } The unique identifier of the balance account.
134+
* @param requestOptions {@link IRequest.Options }
135+
* @return {@link TransferLimit }
136+
*/
137+
public async getSpecificTransferLimit(transferLimitId: string, id: string, requestOptions?: IRequest.Options): Promise<TransferLimit> {
138+
const endpoint = `${this.baseUrl}/balanceAccounts/{id}/transferLimits/{transferLimitId}`
139+
.replace("{" + "transferLimitId" + "}", encodeURIComponent(String(transferLimitId)))
140+
.replace("{" + "id" + "}", encodeURIComponent(String(id)));
141+
const resource = new Resource(this, endpoint);
142+
143+
const response = await getJsonResponse<string, TransferLimit>(
144+
resource,
145+
"",
146+
{ ...requestOptions, method: "GET" }
147+
);
148+
149+
return ObjectSerializer.deserialize(response, "TransferLimit");
150+
}
151+
152+
/**
153+
* @summary Filter and view the transfer limits
154+
* @param id {@link string } The unique identifier of the balance account.
155+
* @param requestOptions {@link IRequest.Options }
156+
* @param scope {@link Scope } The scope to which the transfer limit applies. Possible values: * **perTransaction**: you set a maximum amount for each transfer made from the balance account or balance platform. * **perDay**: you set a maximum total amount for all transfers made from the balance account or balance platform in a day.
157+
* @param transferType {@link TransferType } The type of transfer to which the limit applies. Possible values: * **instant**: the limit applies to transfers with an **instant** priority. * **all**: the limit applies to all transfers, regardless of priority.
158+
* @param status {@link LimitStatus } The status of the transfer limit. Possible values: * **active**: the limit is currently active. * **inactive**: the limit is currently inactive. * **pendingSCA**: the limit is pending until your user performs SCA. * **scheduled**: the limit is scheduled to become active at a future date.
159+
* @return {@link TransferLimitListResponse }
160+
*/
161+
public async getTransferLimits(id: string, scope?: Scope, transferType?: TransferType, status?: LimitStatus, requestOptions?: IRequest.Options): Promise<TransferLimitListResponse> {
162+
const endpoint = `${this.baseUrl}/balanceAccounts/{id}/transferLimits`
163+
.replace("{" + "id" + "}", encodeURIComponent(String(id)));
164+
const resource = new Resource(this, endpoint);
165+
166+
const hasDefinedQueryParams = scope ?? transferType ?? status;
167+
if(hasDefinedQueryParams) {
168+
if(!requestOptions) requestOptions = {};
169+
if(!requestOptions.params) requestOptions.params = {};
170+
if(scope) requestOptions.params["scope"] = scope;
171+
if(transferType) requestOptions.params["transferType"] = transferType;
172+
if(status) requestOptions.params["status"] = status;
173+
}
174+
const response = await getJsonResponse<string, TransferLimitListResponse>(
175+
resource,
176+
"",
177+
{ ...requestOptions, method: "GET" }
178+
);
179+
180+
return ObjectSerializer.deserialize(response, "TransferLimitListResponse");
181+
}
182+
183+
}
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
/*
2+
* The version of the OpenAPI document: v2
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+
11+
import getJsonResponse from "../../helpers/getJsonResponse";
12+
import Service from "../../service";
13+
import Client from "../../client";
14+
import { IRequest } from "../../typings/requestOptions";
15+
import Resource from "../resource";
16+
17+
import { ObjectSerializer } from "../../typings/balancePlatform/objectSerializer";
18+
import { CreateTransferLimitRequest } from "../../typings/balancePlatform/models";
19+
import { LimitStatus } from "../../typings/balancePlatform/models";
20+
import { Scope } from "../../typings/balancePlatform/models";
21+
import { TransferLimit } from "../../typings/balancePlatform/models";
22+
import { TransferLimitListResponse } from "../../typings/balancePlatform/models";
23+
import { TransferType } from "../../typings/balancePlatform/models";
24+
25+
/**
26+
* API handler for TransferLimitsBalancePlatformLevelApi
27+
*/
28+
export class TransferLimitsBalancePlatformLevelApi extends Service {
29+
30+
private readonly API_BASEPATH: string = "https://balanceplatform-api-test.adyen.com/bcl/v2";
31+
private baseUrl: string;
32+
33+
public constructor(client: Client){
34+
super(client);
35+
this.baseUrl = this.createBaseUrl(this.API_BASEPATH);
36+
}
37+
38+
/**
39+
* @summary Create a transfer limit
40+
* @param id {@link string } The unique identifier of the balance platform.
41+
* @param createTransferLimitRequest {@link CreateTransferLimitRequest }
42+
* @param requestOptions {@link IRequest.Options }
43+
* @return {@link TransferLimit }
44+
*/
45+
public async createTransferLimit(id: string, createTransferLimitRequest: CreateTransferLimitRequest, requestOptions?: IRequest.Options): Promise<TransferLimit> {
46+
const endpoint = `${this.baseUrl}/balancePlatforms/{id}/transferLimits`
47+
.replace("{" + "id" + "}", encodeURIComponent(String(id)));
48+
const resource = new Resource(this, endpoint);
49+
50+
const request: CreateTransferLimitRequest = ObjectSerializer.serialize(createTransferLimitRequest, "CreateTransferLimitRequest");
51+
const response = await getJsonResponse<CreateTransferLimitRequest, TransferLimit>(
52+
resource,
53+
request,
54+
{ ...requestOptions, method: "POST" }
55+
);
56+
57+
return ObjectSerializer.deserialize(response, "TransferLimit");
58+
}
59+
60+
/**
61+
* @summary Delete a scheduled or pending transfer limit
62+
* @param transferLimitId {@link string } The unique identifier of the transfer limit.
63+
* @param id {@link string } The unique identifier of the balance platform.
64+
* @param requestOptions {@link IRequest.Options }
65+
* @return {@link void }
66+
*/
67+
public async deletePendingTransferLimit(transferLimitId: string, id: string, requestOptions?: IRequest.Options): Promise<void> {
68+
const endpoint = `${this.baseUrl}/balancePlatforms/{id}/transferLimits/{transferLimitId}`
69+
.replace("{" + "transferLimitId" + "}", encodeURIComponent(String(transferLimitId)))
70+
.replace("{" + "id" + "}", encodeURIComponent(String(id)));
71+
const resource = new Resource(this, endpoint);
72+
73+
await getJsonResponse<string, void>(
74+
resource,
75+
"",
76+
{ ...requestOptions, method: "DELETE" }
77+
);
78+
}
79+
80+
/**
81+
* @summary Get the details of a transfer limit
82+
* @param transferLimitId {@link string } The unique identifier of the transfer limit.
83+
* @param id {@link string } The unique identifier of the balance platform.
84+
* @param requestOptions {@link IRequest.Options }
85+
* @return {@link TransferLimit }
86+
*/
87+
public async getSpecificTransferLimit(transferLimitId: string, id: string, requestOptions?: IRequest.Options): Promise<TransferLimit> {
88+
const endpoint = `${this.baseUrl}/balancePlatforms/{id}/transferLimits/{transferLimitId}`
89+
.replace("{" + "transferLimitId" + "}", encodeURIComponent(String(transferLimitId)))
90+
.replace("{" + "id" + "}", encodeURIComponent(String(id)));
91+
const resource = new Resource(this, endpoint);
92+
93+
const response = await getJsonResponse<string, TransferLimit>(
94+
resource,
95+
"",
96+
{ ...requestOptions, method: "GET" }
97+
);
98+
99+
return ObjectSerializer.deserialize(response, "TransferLimit");
100+
}
101+
102+
/**
103+
* @summary Filter and view the transfer limits
104+
* @param id {@link string } The unique identifier of the balance platform.
105+
* @param requestOptions {@link IRequest.Options }
106+
* @param scope {@link Scope } The scope to which the transfer limit applies. Possible values: * **perTransaction**: you set a maximum amount for each transfer made from the balance account or balance platform. * **perDay**: you set a maximum total amount for all transfers made from the balance account or balance platform in a day.
107+
* @param transferType {@link TransferType } The type of transfer to which the limit applies. Possible values: * **instant**: the limit applies to transfers with an **instant** priority. * **all**: the limit applies to all transfers, regardless of priority.
108+
* @param status {@link LimitStatus } The status of the transfer limit. Possible values: * **active**: the limit is currently active. * **inactive**: the limit is currently inactive. * **pendingSCA**: the limit is pending until your user performs SCA. * **scheduled**: the limit is scheduled to become active at a future date.
109+
* @return {@link TransferLimitListResponse }
110+
*/
111+
public async getTransferLimits(id: string, scope?: Scope, transferType?: TransferType, status?: LimitStatus, requestOptions?: IRequest.Options): Promise<TransferLimitListResponse> {
112+
const endpoint = `${this.baseUrl}/balancePlatforms/{id}/transferLimits`
113+
.replace("{" + "id" + "}", encodeURIComponent(String(id)));
114+
const resource = new Resource(this, endpoint);
115+
116+
const hasDefinedQueryParams = scope ?? transferType ?? status;
117+
if(hasDefinedQueryParams) {
118+
if(!requestOptions) requestOptions = {};
119+
if(!requestOptions.params) requestOptions.params = {};
120+
if(scope) requestOptions.params["scope"] = scope;
121+
if(transferType) requestOptions.params["transferType"] = transferType;
122+
if(status) requestOptions.params["status"] = status;
123+
}
124+
const response = await getJsonResponse<string, TransferLimitListResponse>(
125+
resource,
126+
"",
127+
{ ...requestOptions, method: "GET" }
128+
);
129+
130+
return ObjectSerializer.deserialize(response, "TransferLimitListResponse");
131+
}
132+
133+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* The version of the OpenAPI document: v2
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+
11+
export class ApproveTransferLimitRequest {
12+
/**
13+
* A list that includes the `transferLimitId` of all the pending transfer limits you want to approve.
14+
*/
15+
"transferLimitIds": Array<string>;
16+
17+
static readonly discriminator: string | undefined = undefined;
18+
19+
static readonly mapping: {[index: string]: string} | undefined = undefined;
20+
21+
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
22+
{
23+
"name": "transferLimitIds",
24+
"baseName": "transferLimitIds",
25+
"type": "Array<string>",
26+
"format": ""
27+
} ];
28+
29+
static getAttributeTypeMap() {
30+
return ApproveTransferLimitRequest.attributeTypeMap;
31+
}
32+
33+
public constructor() {
34+
}
35+
}
36+

0 commit comments

Comments
 (0)