Skip to content

Commit c752933

Browse files
committed
Generate signature with required params first
1 parent e02795a commit c752933

File tree

3 files changed

+73
-33
lines changed

3 files changed

+73
-33
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/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
}

src/services/transfers/transfersApi.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export class TransfersApi extends Service {
4747
const endpoint = `${this.baseUrl}/transfers/approve`;
4848
const resource = new Resource(this, endpoint);
4949

50-
const request: ApproveTransfersRequest = ObjectSerializer.serialize(approveTransfersRequest, "ApproveTransfersRequest", "");
50+
const request: ApproveTransfersRequest = ObjectSerializer.serialize(approveTransfersRequest, "ApproveTransfersRequest");
5151
await getJsonResponse<ApproveTransfersRequest, void>(
5252
resource,
5353
request,
@@ -65,7 +65,7 @@ export class TransfersApi extends Service {
6565
const endpoint = `${this.baseUrl}/transfers/cancel`;
6666
const resource = new Resource(this, endpoint);
6767

68-
const request: CancelTransfersRequest = ObjectSerializer.serialize(cancelTransfersRequest, "CancelTransfersRequest", "");
68+
const request: CancelTransfersRequest = ObjectSerializer.serialize(cancelTransfersRequest, "CancelTransfersRequest");
6969
await getJsonResponse<CancelTransfersRequest, void>(
7070
resource,
7171
request,
@@ -76,19 +76,19 @@ export class TransfersApi extends Service {
7676
/**
7777
* @summary Get all transfers
7878
* @param requestOptions {@link IRequest.Options }
79-
* @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;.
80-
* @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;.
81-
* @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;.
82-
* @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.
83-
* @param reference {@link string } The reference you provided in the POST [/transfers](https://docs.adyen.com/api-explorer/transfers/latest/post/transfers) request
84-
* @param category {@link &#39;bank&#39; | &#39;card&#39; | &#39;grants&#39; | &#39;internal&#39; | &#39;issuedCard&#39; | &#39;migration&#39; | &#39;platformPayment&#39; | &#39;topUp&#39; | &#39;upgrade&#39; } The type of transfer. Possible values: - **bank**: Transfer to a [transfer instrument](https://docs.adyen.com/api-explorer/#/legalentity/latest/post/transferInstruments__resParam_id) or a bank account. - **internal**: Transfer to another [balance account](https://docs.adyen.com/api-explorer/#/balanceplatform/latest/post/balanceAccounts__resParam_id) within your platform. - **issuedCard**: Transfer initiated by a Adyen-issued card. - **platformPayment**: Fund movements related to payments that are acquired for your users.
85-
* @param createdSince {@link Date } Only include transfers that have been created on or after this point in time. The value must be in ISO 8601 format and not earlier than 6 months before the &#x60;createdUntil&#x60; date. For example, **2021-05-30T15:07:40Z**.
86-
* @param createdUntil {@link Date } Only include transfers that have been created on or before this point in time. The value must be in ISO 8601 format and not later than 6 months after the &#x60;createdSince&#x60; date. For example, **2021-05-30T15:07:40Z**.
87-
* @param cursor {@link string } The &#x60;cursor&#x60; returned in the links of the previous response.
88-
* @param limit {@link number } The number of items returned per page, maximum of 100 items. By default, the response returns 10 items per page.
79+
* @param createdSince {@link Date } (Required) Only include transfers that have been created on or after this point in time. The value must be in ISO 8601 format and not earlier than 6 months before the &#x60;createdUntil&#x60; date. For example, **2021-05-30T15:07:40Z**.
80+
* @param createdUntil {@link Date } (Required) Only include transfers that have been created on or before this point in time. The value must be in ISO 8601 format and not later than 6 months after the &#x60;createdSince&#x60; date. For example, **2021-05-30T15:07:40Z**.
81+
* @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;.
82+
* @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;.
83+
* @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;.
84+
* @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.
85+
* @param reference {@link string } The reference you provided in the POST [/transfers](https://docs.adyen.com/api-explorer/transfers/latest/post/transfers) request
86+
* @param category {@link &#39;bank&#39; | &#39;card&#39; | &#39;grants&#39; | &#39;interest&#39; | &#39;internal&#39; | &#39;issuedCard&#39; | &#39;migration&#39; | &#39;platformPayment&#39; | &#39;topUp&#39; | &#39;upgrade&#39; } The type of transfer. Possible values: - **bank**: Transfer to a [transfer instrument](https://docs.adyen.com/api-explorer/#/legalentity/latest/post/transferInstruments__resParam_id) or a bank account. - **internal**: Transfer to another [balance account](https://docs.adyen.com/api-explorer/#/balanceplatform/latest/post/balanceAccounts__resParam_id) within your platform. - **issuedCard**: Transfer initiated by a Adyen-issued card. - **platformPayment**: Fund movements related to payments that are acquired for your users.
87+
* @param cursor {@link string } The &#x60;cursor&#x60; returned in the links of the previous response.
88+
* @param limit {@link number } The number of items returned per page, maximum of 100 items. By default, the response returns 10 items per page.
8989
* @return {@link FindTransfersResponse }
9090
*/
91-
public async getAllTransfers(balancePlatform?: string, accountHolderId?: string, balanceAccountId?: string, paymentInstrumentId?: string, reference?: string, category?: "bank" | "card" | "grants" | "internal" | "issuedCard" | "migration" | "platformPayment" | "topUp" | "upgrade", createdSince?: Date, createdUntil?: Date, cursor?: string, limit?: number, requestOptions?: IRequest.Options): Promise<FindTransfersResponse> {
91+
public async getAllTransfers(createdSince: Date, createdUntil: Date, balancePlatform?: string, accountHolderId?: string, balanceAccountId?: string, paymentInstrumentId?: string, reference?: string, category?: "bank" | "card" | "grants" | "interest" | "internal" | "issuedCard" | "migration" | "platformPayment" | "topUp" | "upgrade", cursor?: string, limit?: number, requestOptions?: IRequest.Options): Promise<FindTransfersResponse> {
9292
const endpoint = `${this.baseUrl}/transfers`;
9393
const resource = new Resource(this, endpoint);
9494

@@ -113,7 +113,7 @@ export class TransfersApi extends Service {
113113
{ ...requestOptions, method: "GET" }
114114
);
115115

116-
return ObjectSerializer.deserialize(response, "FindTransfersResponse", "");
116+
return ObjectSerializer.deserialize(response, "FindTransfersResponse");
117117
}
118118

119119
/**
@@ -133,7 +133,7 @@ export class TransfersApi extends Service {
133133
{ ...requestOptions, method: "GET" }
134134
);
135135

136-
return ObjectSerializer.deserialize(response, "TransferData", "");
136+
return ObjectSerializer.deserialize(response, "TransferData");
137137
}
138138

139139
/**
@@ -148,14 +148,14 @@ export class TransfersApi extends Service {
148148
.replace("{" + "transferId" + "}", encodeURIComponent(String(transferId)));
149149
const resource = new Resource(this, endpoint);
150150

151-
const request: ReturnTransferRequest = ObjectSerializer.serialize(returnTransferRequest, "ReturnTransferRequest", "");
151+
const request: ReturnTransferRequest = ObjectSerializer.serialize(returnTransferRequest, "ReturnTransferRequest");
152152
const response = await getJsonResponse<ReturnTransferRequest, ReturnTransferResponse>(
153153
resource,
154154
request,
155155
{ ...requestOptions, method: "POST" }
156156
);
157157

158-
return ObjectSerializer.deserialize(response, "ReturnTransferResponse", "");
158+
return ObjectSerializer.deserialize(response, "ReturnTransferResponse");
159159
}
160160

161161
/**
@@ -168,14 +168,14 @@ export class TransfersApi extends Service {
168168
const endpoint = `${this.baseUrl}/transfers`;
169169
const resource = new Resource(this, endpoint);
170170

171-
const request: TransferInfo = ObjectSerializer.serialize(transferInfo, "TransferInfo", "");
171+
const request: TransferInfo = ObjectSerializer.serialize(transferInfo, "TransferInfo");
172172
const response = await getJsonResponse<TransferInfo, Transfer>(
173173
resource,
174174
request,
175175
{ ...requestOptions, method: "POST" }
176176
);
177177

178-
return ObjectSerializer.deserialize(response, "Transfer", "");
178+
return ObjectSerializer.deserialize(response, "Transfer");
179179
}
180180

181181
}

0 commit comments

Comments
 (0)