Skip to content

Commit

Permalink
Fix CurrencyExchange deserialization. Resolves #6
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinTTY committed Dec 30, 2023
1 parent 8ce7ca8 commit f2e30fd
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public async Task GetTransactions()
matchesAll &= t.TransactionAmount.Currency == "EUR";
return matchesAll;
}));
Assert.That(transactions.PendingTransactions, Has.Count.EqualTo(1));
Assert.That(transactions.PendingTransactions, Has.Count.GreaterThanOrEqualTo(1));
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ internal class TransactionTests
public void DeserializeTransaction()
{
const string json =
"{ \"transactionId\": \"AB123456789\", \"entryReference\": \"123456789\", \"bookingDate\": \"2023-03-20\", \"bookingDateTime\": \"2023-03-20T00:00:00+00:00\", \"transactionAmount\": { \"amount\": \"-33.06\", \"currency\": \"GBP\" }, \"currencyExchange\": { \"sourceCurrency\": \"USD\", \"exchangeRate\": \"1.20961887\", \"unitCurrency\": \"GBP\", \"targetCurrency\": \"GBP\" }, \"remittanceInformationUnstructured\": \"my reference here\", \"additionalInformation\": \"123456789\", \"proprietaryBankTransactionCode\": \"OTHER_PURCHASE\", \"merchantCategoryCode\": \"5045\", \"internalTransactionId\": \"abcdef\" }";
"{ \"transactionId\": \"AB123456789\", \"entryReference\": \"123456789\", \"bookingDate\": \"2023-03-20\", \"bookingDateTime\": \"2023-03-20T00:00:00+00:00\", \"transactionAmount\": { \"amount\": \"-33.06\", \"currency\": \"GBP\" }, \"currencyExchange\":[{\"sourceCurrency\":\"USD\",\"exchangeRate\":\"1.20961887\",\"unitCurrency\":\"USD\",\"targetCurrency\":\"GBP\"}], \"remittanceInformationUnstructured\": \"my reference here\", \"additionalInformation\": \"123456789\", \"proprietaryBankTransactionCode\": \"OTHER_PURCHASE\", \"merchantCategoryCode\": \"5045\", \"internalTransactionId\": \"abcdef\" }";

// We need the culture specific decimal converter here, since it it accepting strings
var options = new JsonSerializerOptions
{
Expand All @@ -26,11 +27,11 @@ public void DeserializeTransaction()
Assert.Multiple(() =>
{
Assert.That(transaction!.CurrencyExchange, Is.Not.Null);
Assert.That(transaction.CurrencyExchange!.ExchangeRate, Is.EqualTo(1.20961887));
Assert.That(transaction.CurrencyExchange!.SourceCurrency, Is.EqualTo("USD"));
Assert.That(transaction.CurrencyExchange!.TargetCurrency, Is.EqualTo("GBP"));
Assert.That(transaction.CurrencyExchange!.UnitCurrency, Is.EqualTo("GBP"));
Assert.That(transaction.CurrencyExchange!.QuotationDate, Is.Null);
Assert.That(transaction.CurrencyExchange!.First().ExchangeRate, Is.EqualTo(1.20961887));
Assert.That(transaction.CurrencyExchange!.First().SourceCurrency, Is.EqualTo("USD"));
Assert.That(transaction.CurrencyExchange!.First().TargetCurrency, Is.EqualTo("GBP"));
Assert.That(transaction.CurrencyExchange!.First().UnitCurrency, Is.EqualTo("USD"));
Assert.That(transaction.CurrencyExchange!.First().QuotationDate, Is.Null);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public class Transaction
/// Array of the report exchange rate.
/// </summary>
[JsonPropertyName("currencyExchange")]
public CurrencyExchange? CurrencyExchange { get; }
public IEnumerable<CurrencyExchange>? CurrencyExchange { get; }

/// <summary>
/// The identification of the transaction as used for reference by the financial institution.
Expand Down Expand Up @@ -343,7 +343,7 @@ public Transaction(string? transactionId, string? debtorName, MinimalBankAccount
DateTime? valueDateTime, string? remittanceInformationStructured,
IEnumerable<string>? remittanceInformationStructuredArray, string? additionalInformation,
string? additionalInformationStructured, Balance? balanceAfterTransaction, string? checkId,
CurrencyExchange? currencyExchange, string? entryReference, string? internalTransactionId,
IEnumerable<CurrencyExchange>? currencyExchange, string? entryReference, string? internalTransactionId,
string? merchantCategoryCode, DateTime? bookingDateTime)
{
TransactionId = transactionId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<PackageTags>Nordigen; API; client</PackageTags>
<PackageReleaseNotes>$([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/release-notes.txt"))</PackageReleaseNotes>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Version>6.1.1</Version>
<Version>6.1.2</Version>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>
Expand Down
3 changes: 1 addition & 2 deletions src/RobinTTY.NordigenApiClient/release-notes.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
Improved package size and documentation.
Fixed balance type enum conversion and test.
Fixed CurrencyExchange deserialization.

0 comments on commit f2e30fd

Please sign in to comment.