Skip to content

Commit

Permalink
Apply code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinTTY committed Aug 24, 2024
1 parent 2d3bb6a commit feba57e
Show file tree
Hide file tree
Showing 88 changed files with 306 additions and 201 deletions.
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@

# NordigenApiClient

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:
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:

- Token
- Institutions
- Agreements
- Requisitions
- Accounts

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).
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).

## Quickstart Guide

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

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:
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:

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

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.
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.

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

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

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

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/).
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/).
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@
Console.WriteLine($"Remittance: {transaction.RemittanceInformationUnstructured}");
Console.WriteLine($"Booking date:{transaction.ValueDate}");
Console.WriteLine($"Amount: {transactionAmount.Amount} {transactionAmount.Currency}");
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@ public void CheckForTokenExpiry()
Assert.That(token.IsExpired(diffInvalid), Is.True);
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ public void DeserializeEnum<T>(string descriptor, T expectedDeserializedValue)
var enumValue = JsonSerializer.Deserialize<T>($"\"{descriptor}\"");
Assert.That(enumValue, Is.EqualTo(expectedDeserializedValue));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public void Setup()
#region RequestsWithSuccessfulResponse

/// <summary>
/// Tests that <see cref="NordigenClient.JsonWebTokenPair" /> is populated after the first authenticated request is made.
/// Tests that <see cref="NordigenClient.JsonWebTokenPair" /> is populated after the first authenticated request is
/// made.
/// </summary>
[Test]
public async Task CheckValidTokensAfterRequest()
Expand Down Expand Up @@ -105,4 +106,4 @@ public async Task ExecuteRequestWithUnauthorizedIp()
}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ public async Task GetTransactionRangeInFuture()
}

/// <summary>
/// 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.
/// 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.
/// </summary>
[Test]
public void GetTransactionRangeWithIncorrectRange()
Expand All @@ -237,4 +238,4 @@ await _apiClient.AccountsEndpoint.GetTransactions(_accountId, DateOnly.FromDateT
}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ await _apiClient.AgreementsEndpoint.CreateAgreement(null!, uint.MaxValue, uint.M
}

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

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

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

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,4 @@ public async Task GetNonExistingInstitution()
}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,4 @@ await _apiClient.RequisitionsEndpoint.CreateRequisition("", redirect, agreementI
}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public async Task ReuseExpiredToken()
}

/// <summary>
/// Tests whether the <see cref="NordigenClient.TokenPairUpdated"/> event is raised when the token pair is updated
/// automatically by the client itself.
/// Tests whether the <see cref="NordigenClient.TokenPairUpdated" /> event is raised when the token pair is updated
/// automatically by the client itself.
/// </summary>
[Test]
public async Task TokenPairUpdateIsRaisedOnInternalUpdate()
Expand All @@ -68,10 +68,10 @@ public async Task TokenPairUpdateIsRaisedOnInternalUpdate()
Assert.That(eventArgs.JsonWebTokenPair.RefreshToken.EncodedToken, Is.Not.Empty);
});
}

/// <summary>
/// Tests whether the <see cref="NordigenClient.TokenPairUpdated"/> event is raised when the token pair is updated
/// by the user.
/// Tests whether the <see cref="NordigenClient.TokenPairUpdated" /> event is raised when the token pair is updated
/// by the user.
/// </summary>
[Test]
public void TokenPairUpdateIsRaisedOnManualUpdate()
Expand Down Expand Up @@ -117,4 +117,4 @@ public async Task GetTokenWithInvalidCredentials()
}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ private async Task ExecuteExampleRequest(NordigenClient apiClient)
}

#endregion
}
}
13 changes: 7 additions & 6 deletions src/RobinTTY.NordigenApiClient.Tests/Mocks/CredentialTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ public class CredentialTests
#region RequestsWithSuccessfulResponse

/// <summary>
/// Tests that <see cref="NordigenClient.JsonWebTokenPair" /> is populated after the first authenticated request is made.
/// Tests that <see cref="NordigenClient.JsonWebTokenPair" /> is populated after the first authenticated request is
/// made.
/// </summary>
[Test]
public async Task CheckValidTokensAfterRequest()
Expand All @@ -29,8 +30,8 @@ public async Task CheckValidTokensAfterRequest()
}

/// <summary>
/// Tests whether the <see cref="NordigenClient.TokenPairUpdated"/> event is raised when the token pair is updated
/// automatically by the client itself.
/// Tests whether the <see cref="NordigenClient.TokenPairUpdated" /> event is raised when the token pair is updated
/// automatically by the client itself.
/// </summary>
[Test]
public async Task TokenPairUpdateIsRaisedOnInternalUpdate()
Expand All @@ -52,8 +53,8 @@ public async Task TokenPairUpdateIsRaisedOnInternalUpdate()
}

/// <summary>
/// Tests whether the <see cref="NordigenClient.TokenPairUpdated"/> event is raised when the token pair is updated
/// by the user.
/// Tests whether the <see cref="NordigenClient.TokenPairUpdated" /> event is raised when the token pair is updated
/// by the user.
/// </summary>
[Test]
public void TokenPairUpdateIsRaisedOnManualUpdate()
Expand Down Expand Up @@ -120,4 +121,4 @@ public async Task ExecuteRequestWithUnauthorizedIp()
}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ public async Task GetTransactionRangeInFuture()
}

/// <summary>
/// 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.
/// 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.
/// </summary>
[Test]
public void GetTransactionRangeWithIncorrectRange()
Expand Down Expand Up @@ -262,4 +263,4 @@ await apiClient.AccountsEndpoint.GetTransactions(A.Dummy<Guid>(), DateOnly.FromD
}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -268,4 +268,4 @@ public async Task CreateAgreementWithInvalidParamsAtPolishInstitution()
}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,4 @@ public async Task GetNonExistingInstitution()
}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -235,4 +235,4 @@ await apiClient.RequisitionsEndpoint.CreateRequisition("", redirect, agreementId
}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ public async Task RefreshAccessToken()
}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ public abstract Task<HttpResponseMessage> FakeSendAsync(

// sealed so FakeItEasy won't intercept calls to this method
protected sealed override Task<HttpResponseMessage> SendAsync(
HttpRequestMessage request, CancellationToken cancellationToken)
=> FakeSendAsync(request, cancellationToken);
}
HttpRequestMessage request, CancellationToken cancellationToken) =>
FakeSendAsync(request, cancellationToken);
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,4 @@ internal class CredentialMockData(BasicResponse noAccountForGivenCredentialsErro
{
public BasicResponse NoAccountForGivenCredentialsError { get; set; } = noAccountForGivenCredentialsError;
public BasicResponse IpNotWhitelistedError { get; set; } = ipNotWhitelistedError;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

<ItemGroup>
<PackageReference Include="FakeItEasy" Version="8.2.0"/>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0"/>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0"/>
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0"/>
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0"/>
<PackageReference Include="NUnit" Version="4.1.0"/>
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0"/>
Expand All @@ -40,7 +40,7 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="appsettings.test.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ public void DeserializeTransactionWithSingleCurrencyExchange()
"For this institution the following scopes are required together: ['details', 'balances']; Some Other Error Detail"));
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,4 @@ public async Task DeserializeWithException()
"The following JSON content caused the problem: { \"transactionId\": \"AB123456789\", \"entryReference\": \"123456789\", \"bookingDate\": \"2023-03-20\", \"bookingDateTime\":"));
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ internal static void AssertBasicResponseMatchesExpectations(BasicResponse? respo
Assert.That(response?.Detail, Is.EqualTo(detail));
});
}
}
}
10 changes: 6 additions & 4 deletions src/RobinTTY.NordigenApiClient.Tests/Shared/TestHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace RobinTTY.NordigenApiClient.Tests.Shared;
internal static class TestHelpers
{
private static readonly JsonSerializerOptions JsonSerializerOptions;

public static TestSecrets Secrets { get; }
public static MockResponsesModel MockData { get; }

Expand Down Expand Up @@ -41,8 +42,9 @@ internal static NordigenClient GetConfiguredClient(string? baseAddress = null)
}

internal static NordigenClient GetMockClient(object? value, HttpStatusCode statusCode,
bool addDefaultAuthToken = true) => GetMockClient([new ValueTuple<object?, HttpStatusCode>(value, statusCode)],
addDefaultAuthToken);
bool addDefaultAuthToken = true) =>
GetMockClient([new ValueTuple<object?, HttpStatusCode>(value, statusCode)],
addDefaultAuthToken);

private static NordigenClient GetMockClient(List<(object? Value, HttpStatusCode StatusCode)> responses,
bool addDefaultAuthToken = true)
Expand Down Expand Up @@ -79,10 +81,10 @@ private static NordigenClient GetMockClient(List<(object? Value, HttpStatusCode
var credentials = new NordigenClientCredentials(Secrets.ValidSecretId, Secrets.ValidSecretKey);
return new NordigenClient(mockHttpClient, credentials);
}

private static TestSecrets? GetSecrets() =>
new ConfigurationBuilder()
.AddJsonFile("appsettings.test.json")
.AddUserSecrets<TestSecrets>()
.Build().Get<TestSecrets>();
}
}
2 changes: 1 addition & 1 deletion src/RobinTTY.NordigenApiClient.Tests/Shared/TestSecrets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ public class TestSecrets(
public string ValidSecretIdWithWhitelist { get; init; } = validSecretIdWithWhitelist;
public string ValidSecretKeyWithWhitelist { get; init; } = validSecretKeyWithWhitelist;
public string UnauthorizedJwtToken { get; init; } = unauthorizedJwtToken;
}
}
2 changes: 1 addition & 1 deletion src/RobinTTY.NordigenApiClient.Tests/Usings.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
global using System.Net;
global using System.Net.Http;
global using NUnit.Framework;
global using NUnit.Framework;
Loading

0 comments on commit feba57e

Please sign in to comment.