Skip to content

Commit d89a1c9

Browse files
authored
Merge pull request #1515 from Adyen/mandatory-query-params
Transfers API: method signature with required query parameters
2 parents 5ab70fb + 86f27cf commit d89a1c9

File tree

12 files changed

+159
-47
lines changed

12 files changed

+159
-47
lines changed

src/__tests__/transfers.spec.ts

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,45 @@ describe("Transfers", (): void => {
4747
expect(response.id).toEqual("1W1UG35U8A9J5ZLG");
4848
});
4949

50+
test("should get transfer", async (): Promise<void> => {
51+
scope.get("/transfers/123")
52+
.reply(200, transfersSuccess);
53+
const response: transfers.TransferData = await transfersAPI.TransfersApi.getTransfer("123",);
54+
expect(response.id).toEqual("1W1UG35U8A9J5ZLG");
55+
});
56+
57+
test("should list transfers", async (): Promise<void> => {
58+
const createdSince = new Date(Date.UTC(2023, 11, 12, 0, 0, 0)); // 12-12-2023 December is month 11
59+
const createdUntil = new Date(Date.UTC(2023, 11, 13, 0, 0, 0)); // 13-12-2023 December is month 11
60+
61+
scope
62+
.get("/transfers")
63+
.query({
64+
balancePlatform: "platform",
65+
createdSince: createdSince.toISOString(),
66+
createdUntil: createdUntil.toISOString(),
67+
})
68+
.reply(200, listTransactionsSuccess);
69+
70+
const response: transfers.FindTransfersResponse = await transfersAPI.TransfersApi.getAllTransfers(
71+
createdSince,
72+
createdUntil,
73+
"platform",
74+
undefined,
75+
undefined,
76+
undefined,
77+
undefined
78+
);
79+
80+
expect(response.data?.length).toEqual(3);
81+
if (response.data && response.data.length > 0) {
82+
expect(response.data[0].id).toEqual("1VVF0D5U66PIUIVP");
83+
} else {
84+
fail();
85+
}
86+
});
87+
88+
5089
test("should get transaction", async (): Promise<void> => {
5190
scope.get("/transactions/123")
5291
.reply(200, getTransactionSuccess);
@@ -68,13 +107,13 @@ describe("Transfers", (): void => {
68107
.reply(200, listTransactionsSuccess);
69108

70109
const response: transfers.TransactionSearchResponse = await transfersAPI.TransactionsApi.getAllTransactions(
110+
createdSince,
111+
createdUntil,
71112
"platform",
72113
undefined,
73114
undefined,
74115
undefined,
75-
undefined,
76-
createdSince,
77-
createdUntil
116+
undefined
78117
);
79118

80119
expect(response.data?.length).toEqual(3);
@@ -84,4 +123,5 @@ describe("Transfers", (): void => {
84123
fail();
85124
}
86125
});
126+
87127
});

src/services/transfers/capitalApi.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class CapitalApi extends Service {
3535
/**
3636
* @summary Get a capital account
3737
* @param requestOptions {@link IRequest.Options }
38-
* @param counterpartyAccountHolderId {@link string } The counterparty account holder id.
38+
* @param counterpartyAccountHolderId {@link string } The counterparty account holder id.
3939
* @return {@link CapitalGrants }
4040
*
4141
* @deprecated since Transfers API v4
@@ -57,7 +57,7 @@ export class CapitalApi extends Service {
5757
{ ...requestOptions, method: "GET" }
5858
);
5959

60-
return ObjectSerializer.deserialize(response, "CapitalGrants", "");
60+
return ObjectSerializer.deserialize(response, "CapitalGrants");
6161
}
6262

6363
/**
@@ -80,7 +80,7 @@ export class CapitalApi extends Service {
8080
{ ...requestOptions, method: "GET" }
8181
);
8282

83-
return ObjectSerializer.deserialize(response, "CapitalGrant", "");
83+
return ObjectSerializer.deserialize(response, "CapitalGrant");
8484
}
8585

8686
/**
@@ -96,14 +96,14 @@ export class CapitalApi extends Service {
9696
const endpoint = `${this.baseUrl}/grants`;
9797
const resource = new Resource(this, endpoint);
9898

99-
const request: CapitalGrantInfo = ObjectSerializer.serialize(capitalGrantInfo, "CapitalGrantInfo", "");
99+
const request: CapitalGrantInfo = ObjectSerializer.serialize(capitalGrantInfo, "CapitalGrantInfo");
100100
const response = await getJsonResponse<CapitalGrantInfo, CapitalGrant>(
101101
resource,
102102
request,
103103
{ ...requestOptions, method: "POST" }
104104
);
105105

106-
return ObjectSerializer.deserialize(response, "CapitalGrant", "");
106+
return ObjectSerializer.deserialize(response, "CapitalGrant");
107107
}
108108

109109
}

src/services/transfers/transactionsApi.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,17 @@ export class TransactionsApi extends Service {
3434
/**
3535
* @summary Get all transactions
3636
* @param requestOptions {@link IRequest.Options }
37-
* @param balancePlatform {@link string } The unique identifier of the [balance platform](https://docs.adyen.com/api-explorer/#/balanceplatform/latest/get/balancePlatforms/{id}__queryParam_id). Required if you don\&#39;t provide a &#x60;balanceAccountId&#x60; or &#x60;accountHolderId&#x60;.
38-
* @param paymentInstrumentId {@link string } The unique identifier of the [payment instrument](https://docs.adyen.com/api-explorer/balanceplatform/latest/get/paymentInstruments/_id_). To use this parameter, you must also provide a &#x60;balanceAccountId&#x60;, &#x60;accountHolderId&#x60;, or &#x60;balancePlatform&#x60;. The &#x60;paymentInstrumentId&#x60; must be related to the &#x60;balanceAccountId&#x60; or &#x60;accountHolderId&#x60; that you provide.
39-
* @param accountHolderId {@link string } The unique identifier of the [account holder](https://docs.adyen.com/api-explorer/#/balanceplatform/latest/get/accountHolders/{id}__queryParam_id). Required if you don\&#39;t provide a &#x60;balanceAccountId&#x60; or &#x60;balancePlatform&#x60;. If you provide a &#x60;balanceAccountId&#x60;, the &#x60;accountHolderId&#x60; must be related to the &#x60;balanceAccountId&#x60;.
40-
* @param balanceAccountId {@link string } The unique identifier of the [balance account](https://docs.adyen.com/api-explorer/#/balanceplatform/latest/get/balanceAccounts/{id}__queryParam_id). Required if you don\&#39;t provide an &#x60;accountHolderId&#x60; or &#x60;balancePlatform&#x60;. If you provide an &#x60;accountHolderId&#x60;, the &#x60;balanceAccountId&#x60; must be related to the &#x60;accountHolderId&#x60;.
41-
* @param cursor {@link string } The &#x60;cursor&#x60; returned in the links of the previous response.
42-
* @param createdSince {@link Date } Only include transactions that have been created on or after this point in time. The value must be in ISO 8601 format. For example, **2021-05-30T15:07:40Z**.
43-
* @param createdUntil {@link Date } Only include transactions that have been created on or before this point in time. The value must be in ISO 8601 format. For example, **2021-05-30T15:07:40Z**.
44-
* @param limit {@link number } The number of items returned per page, maximum of 100 items. By default, the response returns 10 items per page.
37+
* @param createdSince {@link Date } (Required) Only include transactions that have been created on or after this point in time. The value must be in ISO 8601 format. For example, **2021-05-30T15:07:40Z**.
38+
* @param createdUntil {@link Date } (Required) Only include transactions that have been created on or before this point in time. The value must be in ISO 8601 format. For example, **2021-05-30T15:07:40Z**.
39+
* @param balancePlatform {@link string } The unique identifier of the [balance platform](https://docs.adyen.com/api-explorer/#/balanceplatform/latest/get/balancePlatforms/{id}__queryParam_id). Required if you don\&#39;t provide a &#x60;balanceAccountId&#x60; or &#x60;accountHolderId&#x60;.
40+
* @param paymentInstrumentId {@link string } The unique identifier of the [payment instrument](https://docs.adyen.com/api-explorer/balanceplatform/latest/get/paymentInstruments/_id_). To use this parameter, you must also provide a &#x60;balanceAccountId&#x60;, &#x60;accountHolderId&#x60;, or &#x60;balancePlatform&#x60;. The &#x60;paymentInstrumentId&#x60; must be related to the &#x60;balanceAccountId&#x60; or &#x60;accountHolderId&#x60; that you provide.
41+
* @param accountHolderId {@link string } The unique identifier of the [account holder](https://docs.adyen.com/api-explorer/#/balanceplatform/latest/get/accountHolders/{id}__queryParam_id). Required if you don\&#39;t provide a &#x60;balanceAccountId&#x60; or &#x60;balancePlatform&#x60;. If you provide a &#x60;balanceAccountId&#x60;, the &#x60;accountHolderId&#x60; must be related to the &#x60;balanceAccountId&#x60;.
42+
* @param balanceAccountId {@link string } The unique identifier of the [balance account](https://docs.adyen.com/api-explorer/#/balanceplatform/latest/get/balanceAccounts/{id}__queryParam_id). Required if you don\&#39;t provide an &#x60;accountHolderId&#x60; or &#x60;balancePlatform&#x60;. If you provide an &#x60;accountHolderId&#x60;, the &#x60;balanceAccountId&#x60; must be related to the &#x60;accountHolderId&#x60;.
43+
* @param cursor {@link string } The &#x60;cursor&#x60; returned in the links of the previous response.
44+
* @param limit {@link number } The number of items returned per page, maximum of 100 items. By default, the response returns 10 items per page.
4545
* @return {@link TransactionSearchResponse }
4646
*/
47-
public async getAllTransactions(balancePlatform?: string, paymentInstrumentId?: string, accountHolderId?: string, balanceAccountId?: string, cursor?: string, createdSince?: Date, createdUntil?: Date, limit?: number, requestOptions?: IRequest.Options): Promise<TransactionSearchResponse> {
47+
public async getAllTransactions(createdSince: Date, createdUntil: Date, balancePlatform?: string, paymentInstrumentId?: string, accountHolderId?: string, balanceAccountId?: string, cursor?: string, limit?: number, requestOptions?: IRequest.Options): Promise<TransactionSearchResponse> {
4848
const endpoint = `${this.baseUrl}/transactions`;
4949
const resource = new Resource(this, endpoint);
5050

@@ -67,7 +67,7 @@ export class TransactionsApi extends Service {
6767
{ ...requestOptions, method: "GET" }
6868
);
6969

70-
return ObjectSerializer.deserialize(response, "TransactionSearchResponse", "");
70+
return ObjectSerializer.deserialize(response, "TransactionSearchResponse");
7171
}
7272

7373
/**
@@ -87,7 +87,7 @@ export class TransactionsApi extends Service {
8787
{ ...requestOptions, method: "GET" }
8888
);
8989

90-
return ObjectSerializer.deserialize(response, "Transaction", "");
90+
return ObjectSerializer.deserialize(response, "Transaction");
9191
}
9292

9393
}

0 commit comments

Comments
 (0)