Skip to content

Commit 89f69ba

Browse files
committed
2 parents 7a722f6 + e24984f commit 89f69ba

File tree

101 files changed

+578
-229
lines changed

Some content is hidden

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

101 files changed

+578
-229
lines changed

README.md

+16-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
<p align="center">
2-
<img src="docs/static/img/nordigen-api-client-logo.png" width="30%">
2+
<img src="https://raw.githubusercontent.com/RobinTTY/NordigenApiClient/main/docs/static/img/nordigen-api-client-logo.png" width="30%">
33
</p>
44

55
# NordigenApiClient
66

7-
This library provides a .NET client for the [GoCardless Bank Account Data API](https://gocardless.com/bank-account-data/) (formerly Nordigen API). The following API endpoints are supported:
7+
This library provides a .NET client for
8+
the [GoCardless Bank Account Data API](https://gocardless.com/bank-account-data/) (formerly Nordigen API). The following
9+
API endpoints are supported:
810

911
- Token
1012
- Institutions
1113
- Agreements
1214
- Requisitions
1315
- Accounts
1416

15-
You can get started with the Quickstart Guide below or take a look at the [full documentation](https://robintty.github.io/NordigenApiClient/). You can find the nuget package [here](https://www.nuget.org/packages/RobinTTY.NordigenApiClient).
17+
You can get started with the Quickstart Guide below or take a look at
18+
the [full documentation](https://robintty.github.io/NordigenApiClient/). You can find the nuget
19+
package [here](https://www.nuget.org/packages/RobinTTY.NordigenApiClient).
1620

1721
## Quickstart Guide
1822

@@ -61,11 +65,13 @@ You can get started with the Quickstart Guide below or take a look at the [full
6165
Console.WriteLine($"Requisition couldn't be created: {requisitionResponse.Error.Summary}");
6266
```
6367

64-
5. You will now need to accept the end user agreement by following the authentication link you got in the last step. The authentication flow will roughly look like this:
68+
5. You will now need to accept the end user agreement by following the authentication link you got in the last step. The
69+
authentication flow will roughly look like this:
6570

6671
![authentication-flow](docs/static/img/authentication_flow.png)
6772

68-
6. Now that you have accepted the agreement we once again need to retrieve the requisition we created in step 4. This time the response will include the accounts you are now able to access.
73+
6. Now that you have accepted the agreement we once again need to retrieve the requisition we created in step 4. This
74+
time the response will include the accounts you are now able to access.
6975

7076
```cs
7177
var requisitionId = "your-requisition-id";
@@ -79,7 +85,8 @@ You can get started with the Quickstart Guide below or take a look at the [full
7985
Console.WriteLine($"Accounts couldn't be retrieved: {accountsResponse.Error.Summary}");
8086
```
8187

82-
7. Now you can retrieve details about your bank account and the balances/transactions using the account ID(s) we just acquired:
88+
7. Now you can retrieve details about your bank account and the balances/transactions using the account ID(s) we just
89+
acquired:
8390

8491
```cs
8592
var accountId = "your-account-id";
@@ -110,4 +117,6 @@ You can get started with the Quickstart Guide below or take a look at the [full
110117
});
111118
```
112119

113-
That's it! You are now able to retrieve the account details, balances and transactions of your bank account. If you wanna learn more about this library please refer to the [full documentation](https://robintty.github.io/NordigenApiClient/).
120+
That's it! You are now able to retrieve the account details, balances and transactions of your bank account. If you
121+
wanna learn more about this library please refer to
122+
the [full documentation](https://robintty.github.io/NordigenApiClient/).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
title: ApiRateLimits
3+
---
4+
5+
The `ApiRateLimits` class represents the rate limits of the GoCardless API.
6+
7+
## Properties
8+
9+
### `RequestLimit` - [int](https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-int32)
10+
11+
Indicates the maximum number of allowed requests within the defined time window. Usually populated in every response.
12+
13+
### `RemainingRequests` - [int](https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-int32)
14+
15+
Indicates the number of remaining requests you can make in the current time window. Usually populated in every response.
16+
17+
### `RemainingSecondsInTimeWindow` - [int](https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-int32)
18+
19+
Indicates the time remaining in the current time window (in seconds). Usually populated in every response.
20+
21+
### `RequestLimitAccountsEndpoint` - [int](https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-int32)
22+
23+
Indicates the maximum number of allowed requests to the [AccountsEndpoint](/docs/api-reference/endpoints/accounts-endpoint) within the defined time window. Only populated in responses from the [AccountsEndpoint](/docs/api-reference/endpoints/accounts-endpoint).
24+
25+
### `RemainingRequestsAccountsEndpoint` - [int](https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-int32)
26+
27+
Indicates the number of remaining requests to the [AccountsEndpoint](/docs/api-reference/endpoints/accounts-endpoint) you can make in the current time window. Only populated in responses from the [AccountsEndpoint](/docs/api-reference/endpoints/accounts-endpoint).
28+
29+
### `RemainingSecondsInTimeWindowAccountsEndpoint` - [int](https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-int32)
30+
31+
Indicates the time remaining in the current time window (in seconds) for requests to the [AccountsEndpoint](/docs/api-reference/endpoints/accounts-endpoint). Only populated in responses from the [AccountsEndpoint](/docs/api-reference/endpoints/accounts-endpoint).
32+
33+
## Constructor
34+
35+
```csharp
36+
public ApiRateLimits(int requestLimit, int remainingRequests, int remainingTimeInTimeWindow,
37+
int maxAccountRequests, int remainingAccountRequests, int remainingTimeInAccountTimeWindow)
38+
```
39+
40+
### Parameters
41+
42+
#### `requestLimit` - [int](https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-int32)?
43+
44+
Indicates the maximum number of allowed requests within the defined time window. Usually populated in every response.
45+
46+
#### `remainingRequests` - [int](https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-int32)?
47+
48+
Indicates the number of remaining requests you can make in the current time window. Usually populated in every response.
49+
50+
#### `remainingSecondsInTimeWindow` - [int](https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-int32)?
51+
52+
Indicates the time remaining in the current time window (in seconds). Usually populated in every response.
53+
54+
#### `requestLimitAccountsEndpoint` - [int](https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-int32)?
55+
56+
Indicates the maximum number of allowed requests to the [AccountsEndpoint](/docs/api-reference/endpoints/accounts-endpoint) within the defined time window. Only populated in responses from the [AccountsEndpoint](/docs/api-reference/endpoints/accounts-endpoint).
57+
58+
#### `remainingRequestsAccountsEndpoint` - [int](https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-int32)?
59+
60+
Indicates the number of remaining requests to the [AccountsEndpoint](/docs/api-reference/endpoints/accounts-endpoint) you can make in the current time window. Only populated in responses from the [AccountsEndpoint](/docs/api-reference/endpoints/accounts-endpoint).
61+
62+
#### `remainingSecondsInTimeWindowAccountsEndpoint` - [int](https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-int32)?
63+
64+
Indicates the time remaining in the current time window (in seconds) for requests to the [AccountsEndpoint](/docs/api-reference/endpoints/accounts-endpoint). Only populated in responses from the [AccountsEndpoint](/docs/api-reference/endpoints/accounts-endpoint).

docs/docs/api-reference/responses/nordigen-api-response.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,15 @@ The result returned by the API. Null if the the HTTP response was not successful
2222

2323
The error returned by the API. Null if the HTTP response was successful.
2424

25+
### `RateLimits` - [ApiRateLimits](/docs/api-reference/responses/api-rate-limits)
26+
27+
The rate limits of the GoCardless API.
28+
2529
## Constructor
2630

2731
```csharp
28-
public NordigenApiResponse(HttpStatusCode statusCode, bool isSuccess, TResult? result, TError? apiError)
32+
public NordigenApiResponse(HttpStatusCode statusCode, bool isSuccess,
33+
TResult? result, TError? apiError, ApiRateLimits rateLimits)
2934
```
3035

3136
### Parameters
@@ -46,6 +51,10 @@ The result returned by the API. Null if the the HTTP response was not successful
4651

4752
The error returned by the API. Null if the HTTP response was successful.
4853

54+
#### `rateLimits` - [ApiRateLimits](/docs/api-reference/responses/api-rate-limits)
55+
56+
The rate limits of the GoCardless API.
57+
4958
## Handling the `NordigenApiResponse` type
5059

5160
To learn more about how to best work with the `NordigenApiResponse` type see the [Handling API responses](/docs/handling-api-responses) guide.

docs/docs/handling-rate-limits.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
title: Handling Rate Limits
3+
---
4+
5+
The GoCardless API has [rate limits](https://bankaccountdata.zendesk.com/hc/en-gb/articles/11529637772188-Bank-Account-Data-API-Rate-Limits) depending on the endpoint you are using. With most endpoints you shouldn't run into problems since these limits are usually high enough for most uses.
6+
7+
The [Accounts endpoint](/docs/api-reference/endpoints/accounts-endpoint) has very tight limitations though. It currently has a limit of 10 requests a day per access scope. That means 10 requests to each of the [details](/docs/api-reference/endpoints/accounts-endpoint#getaccountdetails), [balances](/docs/api-reference/endpoints/accounts-endpoint#getbalances) and [transactions](/docs/api-reference/endpoints/accounts-endpoint#gettransactions) endpoints. In the future this limit will be lowered to 4 per day (no date on this as of now).
8+
9+
Unsuccessful requests to the API will count towards the general rate limits but not the more stringent limits of the [Accounts endpoint](/docs/api-reference/endpoints/accounts-endpoint). Only successful requests will count towards those.
10+
11+
## Checking API rate limits
12+
13+
You can check the rate limits as well as remaining requests with each request you make to the API. The property [`NordigenApiResponse.RateLimits`](/docs/api-reference/responses/nordigen-api-response#ratelimits---apiratelimits) will hold the returned information about the current API limits.
14+
15+
You can check the limits as follows:
16+
17+
```csharp
18+
// Execute the request you want to make:
19+
var bankAccountDetailsResponse = await client.AccountsEndpoint.GetAccountDetails(accountId);
20+
21+
Console.WriteLine(bankAccountDetailsResponse.RateLimits.RequestLimit);
22+
Console.WriteLine(bankAccountDetailsResponse.RateLimits.RemainingRequests);
23+
Console.WriteLine(bankAccountDetailsResponse.RateLimits.RemainingSecondsInTimeWindow);
24+
Console.WriteLine(bankAccountDetailsResponse.RateLimits.RequestLimitAccountsEndpoint);
25+
Console.WriteLine(bankAccountDetailsResponse.RateLimits.RemainingRequestsAccountsEndpoint);
26+
Console.WriteLine(bankAccountDetailsResponse.RateLimits.RemainingSecondsInTimeWindowAccountsEndpoint);
27+
```
28+
29+
It's important to handle these limits so your applications user experience isn't degraded. Refreshing data from bank accounts should be handled consciously, so you don't use up all your requests in a short time frame and aren't able to update for the rest of the day.
30+
31+
If you are a company with a contract with GoCardless you can probably get in contact with their team about increasing these limits.

docs/release-notes/v10_0_0.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ public async Task<NordigenApiResponse<List<Institution>, BasicResponse>> GetInst
3939

4040
The `TokenPairUpdated` event is now raised whenever the `JsonWebTokenPair` property is successfully updated. Not only when it was automatically updated but also when done so by the user.
4141

42-
**Full Changelog**: [v9.0.0...v10.0.0](https://github.com/RobinTTY/NordigenApiClient/compare/v9.0.0...v10.0.0)
43-
4442
## Other improvements
4543

4644
A full documentation of the library is now available at: [https://robintty.github.io/NordigenApiClient/](https://robintty.github.io/NordigenApiClient/)
45+
46+
**Full Changelog**: [v9.0.0...v10.0.0](https://github.com/RobinTTY/NordigenApiClient/compare/v9.0.0...v10.0.0)

docs/release-notes/v10_1_0.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
slug: v10.1.0
3+
title: v10.1.0
4+
date: 2024-08-19T00:00
5+
---
6+
7+
Added the ability to check newly introduced rate limits in the GoCardless API.
8+
9+
Please refer to the [documentation](/docs/handling-rate-limits) for more information. You can also see the [announcement from GoCardless](https://bankaccountdata.zendesk.com/hc/en-gb/articles/11529584398236-Bank-API-Rate-Limits-and-Rate-Limit-Headers).
10+
11+
**Full Changelog**: [v10.0.0...v10.1.0](https://github.com/RobinTTY/NordigenApiClient/compare/v10.0.0...v10.1.0)

docs/sidebars.ts

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const sidebars: SidebarsConfig = {
66
"quickstart-guide",
77
"handling-api-responses",
88
"handling-authentication-tokens",
9+
"handling-rate-limits",
910
"using-a-different-base-address",
1011
"usage-with-older-dotnet-versions",
1112
"testing",
@@ -38,6 +39,7 @@ const sidebars: SidebarsConfig = {
3839
"api-reference/responses/address",
3940
"api-reference/responses/agreement",
4041
"api-reference/responses/amount-currency-pair",
42+
"api-reference/responses/api-rate-limits",
4143
"api-reference/responses/balance",
4244
"api-reference/responses/balance-type",
4345
"api-reference/responses/bank-account",

src/RobinTTY.NordigenApiClient.ExampleApplication/Program.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,4 @@
7272
Console.WriteLine($"Remittance: {transaction.RemittanceInformationUnstructured}");
7373
Console.WriteLine($"Booking date:{transaction.ValueDate}");
7474
Console.WriteLine($"Amount: {transactionAmount.Amount} {transactionAmount.Currency}");
75-
});
75+
});

src/RobinTTY.NordigenApiClient.Tests/.idea/.idea.RobinTTY.NordigenApiClient.dir/.idea/.gitignore

+13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/RobinTTY.NordigenApiClient.Tests/.idea/.idea.RobinTTY.NordigenApiClient.dir/.idea/.name

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/RobinTTY.NordigenApiClient.Tests/.idea/.idea.RobinTTY.NordigenApiClient.dir/.idea/encodings.xml

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/RobinTTY.NordigenApiClient.Tests/.idea/.idea.RobinTTY.NordigenApiClient.dir/.idea/indexLayout.xml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/RobinTTY.NordigenApiClient.Tests/.idea/.idea.RobinTTY.NordigenApiClient.dir/.idea/vcs.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/RobinTTY.NordigenApiClient.Tests/AuthenticationTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,4 @@ public void CheckForTokenExpiry()
7575
Assert.That(token.IsExpired(diffInvalid), Is.True);
7676
});
7777
}
78-
}
78+
}

src/RobinTTY.NordigenApiClient.Tests/EnumDescriptionConverterTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,4 @@ public void DeserializeEnum<T>(string descriptor, T expectedDeserializedValue)
6666
var enumValue = JsonSerializer.Deserialize<T>($"\"{descriptor}\"");
6767
Assert.That(enumValue, Is.EqualTo(expectedDeserializedValue));
6868
}
69-
}
69+
}

src/RobinTTY.NordigenApiClient.Tests/LiveApi/CredentialTests.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ public void Setup()
1717
#region RequestsWithSuccessfulResponse
1818

1919
/// <summary>
20-
/// Tests that <see cref="NordigenClient.JsonWebTokenPair" /> is populated after the first authenticated request is made.
20+
/// Tests that <see cref="NordigenClient.JsonWebTokenPair" /> is populated after the first authenticated request is
21+
/// made.
2122
/// </summary>
2223
[Test]
2324
public async Task CheckValidTokensAfterRequest()
@@ -105,4 +106,4 @@ public async Task ExecuteRequestWithUnauthorizedIp()
105106
}
106107

107108
#endregion
108-
}
109+
}

src/RobinTTY.NordigenApiClient.Tests/LiveApi/Endpoints/AccountsEndpointTests.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,8 @@ public async Task GetTransactionRangeInFuture()
210210
}
211211

212212
/// <summary>
213-
/// Tests the retrieval of transactions within a specific time frame where the date range is incorrect, since the endDate is before the startDate. This should throw an exception.
213+
/// Tests the retrieval of transactions within a specific time frame where the date range is incorrect, since the
214+
/// endDate is before the startDate. This should throw an exception.
214215
/// </summary>
215216
[Test]
216217
public void GetTransactionRangeWithIncorrectRange()
@@ -237,4 +238,4 @@ await _apiClient.AccountsEndpoint.GetTransactions(_accountId, DateOnly.FromDateT
237238
}
238239

239240
#endregion
240-
}
241+
}

src/RobinTTY.NordigenApiClient.Tests/LiveApi/Endpoints/AgreementsEndpointTests.cs

+5-3
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ await _apiClient.AgreementsEndpoint.CreateAgreement(null!, uint.MaxValue, uint.M
201201
}
202202

203203
/// <summary>
204-
/// Tests the creation of an end user agreement with invalid accessValidForDays and maxHistoricalDays for that particular institution.
204+
/// Tests the creation of an end user agreement with invalid accessValidForDays and maxHistoricalDays for that
205+
/// particular institution.
205206
/// </summary>
206207
[Test]
207208
public async Task CreateAgreementWithInvalidArgumentsForInstitution()
@@ -237,11 +238,12 @@ await _apiClient.AgreementsEndpoint.CreateAgreement("PKO_BPKOPLPW",
237238

238239
Assert.That(response.Error!.AccessScopeError!.Detail,
239240
Is.EqualTo("For this institution the following scopes are required together: ['details', 'balances']"));
240-
Assert.That(response.Error!.AccessScopeError.Summary, Is.EqualTo("Institution access scope dependencies error"));
241+
Assert.That(response.Error!.AccessScopeError.Summary,
242+
Is.EqualTo("Institution access scope dependencies error"));
241243

242244
Assert.That(new[] {response.Error!.InstitutionIdError, response.Error!.AgreementError}, Has.All.Null);
243245
});
244246
}
245247

246248
#endregion
247-
}
249+
}

src/RobinTTY.NordigenApiClient.Tests/LiveApi/Endpoints/InstitutionsEndpointTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,4 @@ public async Task GetNonExistingInstitution()
144144
}
145145

146146
#endregion
147-
}
147+
}

src/RobinTTY.NordigenApiClient.Tests/LiveApi/Endpoints/RequisitionsEndpointTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -208,4 +208,4 @@ await _apiClient.RequisitionsEndpoint.CreateRequisition("", redirect, agreementI
208208
}
209209

210210
#endregion
211-
}
211+
}

src/RobinTTY.NordigenApiClient.Tests/LiveApi/Endpoints/TokenEndpointTests.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ public async Task ReuseExpiredToken()
4848
}
4949

5050
/// <summary>
51-
/// Tests whether the <see cref="NordigenClient.TokenPairUpdated"/> event is raised when the token pair is updated
52-
/// automatically by the client itself.
51+
/// Tests whether the <see cref="NordigenClient.TokenPairUpdated" /> event is raised when the token pair is updated
52+
/// automatically by the client itself.
5353
/// </summary>
5454
[Test]
5555
public async Task TokenPairUpdateIsRaisedOnInternalUpdate()
@@ -68,10 +68,10 @@ public async Task TokenPairUpdateIsRaisedOnInternalUpdate()
6868
Assert.That(eventArgs.JsonWebTokenPair.RefreshToken.EncodedToken, Is.Not.Empty);
6969
});
7070
}
71-
71+
7272
/// <summary>
73-
/// Tests whether the <see cref="NordigenClient.TokenPairUpdated"/> event is raised when the token pair is updated
74-
/// by the user.
73+
/// Tests whether the <see cref="NordigenClient.TokenPairUpdated" /> event is raised when the token pair is updated
74+
/// by the user.
7575
/// </summary>
7676
[Test]
7777
public void TokenPairUpdateIsRaisedOnManualUpdate()
@@ -117,4 +117,4 @@ public async Task GetTokenWithInvalidCredentials()
117117
}
118118

119119
#endregion
120-
}
120+
}

src/RobinTTY.NordigenApiClient.Tests/LiveApi/NordigenApiClientTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,4 @@ private async Task ExecuteExampleRequest(NordigenClient apiClient)
7171
}
7272

7373
#endregion
74-
}
74+
}

0 commit comments

Comments
 (0)