From 0be695954dd3d3bdc31a95a5234e9878ab97c2ed Mon Sep 17 00:00:00 2001 From: Vincent Kok Date: Tue, 4 Jun 2024 20:54:44 +0200 Subject: [PATCH] Update GetBalanceTransactionListAsync and GetPrimaryBalanceTransactionListAsync methods to use a ListResponse instead of a custom type (#365) * #362 Update GetBalanceTransactionListAsync and GetPrimaryBalanceTransactionListAsync methods to use a ListResponse instead of a custom type * #362 Add GetBalanceTransactionListAsync method to retrieve a list of balance transactions by URL --- .../Client/Abstract/IBalanceClient.cs | 11 ++++- src/Mollie.Api/Client/BalanceClient.cs | 16 +++--- .../Factories/BalanceTransactionFactory.cs | 18 +++---- .../BalanceTransactionJsonConverter.cs | 4 +- .../BalanceTransaction/BalanceTransaction.cs | 48 ------------------ .../BalanceTransactionResponse.cs | 49 +++++++++++++------ .../BalanceTransactionResponseLinks.cs | 25 ---------- ...s => CaptureBalanceTransactionResponse.cs} | 2 +- ...> ChargebackBalanceTransactionResponse.cs} | 2 +- ...s => InvoiceBalanceTransactionResponse.cs} | 2 +- ...s => PaymentBalanceTransactionResponse.cs} | 2 +- ...cs => RefundBalanceTransactionResponse.cs} | 2 +- ...> SettlementBalanceTransactionResponse.cs} | 2 +- .../Api/BalanceTests.cs | 6 +-- .../Client/BalanceClientTests.cs | 14 +++--- .../BalanceTransactionFactoryTests.cs | 36 +++++++------- 16 files changed, 97 insertions(+), 142 deletions(-) delete mode 100644 src/Mollie.Api/Models/Balance/Response/BalanceTransaction/BalanceTransaction.cs delete mode 100644 src/Mollie.Api/Models/Balance/Response/BalanceTransaction/BalanceTransactionResponseLinks.cs rename src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/{CaptureBalanceTransaction.cs => CaptureBalanceTransactionResponse.cs} (79%) rename src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/{ChargebackBalanceTransaction.cs => ChargebackBalanceTransactionResponse.cs} (79%) rename src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/{InvoiceBalanceTransaction.cs => InvoiceBalanceTransactionResponse.cs} (76%) rename src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/{PaymentBalanceTransaction.cs => PaymentBalanceTransactionResponse.cs} (76%) rename src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/{RefundBalanceTransaction.cs => RefundBalanceTransactionResponse.cs} (79%) rename src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/{SettlementBalanceTransaction.cs => SettlementBalanceTransactionResponse.cs} (79%) diff --git a/src/Mollie.Api/Client/Abstract/IBalanceClient.cs b/src/Mollie.Api/Client/Abstract/IBalanceClient.cs index 6df4ec69..0ce13941 100644 --- a/src/Mollie.Api/Client/Abstract/IBalanceClient.cs +++ b/src/Mollie.Api/Client/Abstract/IBalanceClient.cs @@ -87,7 +87,7 @@ public interface IBalanceClient : IBaseMollieClient { /// with this ID is included in the result set as well. /// The number of balance transactions to return (with a maximum of 250). /// - Task GetBalanceTransactionListAsync(string balanceId, string? from = null, int? limit = null); + Task> GetBalanceTransactionListAsync(string balanceId, string? from = null, int? limit = null); /// /// With the List primary balance transactions endpoint you can retrieve a list of all the movements on your @@ -97,6 +97,13 @@ public interface IBalanceClient : IBaseMollieClient { /// with this ID is included in the result set as well. /// The number of balance transactions to return (with a maximum of 250). /// - Task GetPrimaryBalanceTransactionListAsync(string? from = null, int? limit = null); + Task> GetPrimaryBalanceTransactionListAsync(string? from = null, int? limit = null); + + /// + /// Retrieve a list of balance transactions by URL + /// + /// The URL from which to retrieve the balance transactions + /// + Task> GetBalanceTransactionListAsync(UrlObjectLink> url); } } diff --git a/src/Mollie.Api/Client/BalanceClient.cs b/src/Mollie.Api/Client/BalanceClient.cs index 791b42d3..ffe21cc1 100644 --- a/src/Mollie.Api/Client/BalanceClient.cs +++ b/src/Mollie.Api/Client/BalanceClient.cs @@ -49,15 +49,19 @@ public async Task GetPrimaryBalanceReportAsync(DateTime f return await GetAsync($"balances/primary/report{queryParameters.ToQueryString()}").ConfigureAwait(false); } - public async Task GetBalanceTransactionListAsync(string balanceId, string? from = null, int? limit = null) { + public async Task> GetBalanceTransactionListAsync(string balanceId, string? from = null, int? limit = null) { ValidateRequiredUrlParameter(nameof(balanceId), balanceId); - var queryParameters = BuildListBalanceTransactionsQueryParameters(from, limit); - return await GetAsync($"balances/{balanceId}/transactions{queryParameters.ToQueryString()}").ConfigureAwait(false); + return await GetListAsync>($"balances/{balanceId}/transactions", from, limit) + .ConfigureAwait(false); } - public async Task GetPrimaryBalanceTransactionListAsync(string? from = null, int? limit = null) { - var queryParameters = BuildListBalanceTransactionsQueryParameters(from, limit); - return await GetAsync($"balances/primary/transactions{queryParameters.ToQueryString()}").ConfigureAwait(false); + public async Task> GetPrimaryBalanceTransactionListAsync(string? from = null, int? limit = null) { + return await GetListAsync>($"balances/primary/transactions", from, limit) + .ConfigureAwait(false); + } + + public async Task> GetBalanceTransactionListAsync(UrlObjectLink> url) { + return await GetAsync(url).ConfigureAwait(false); } private Dictionary BuildListBalanceTransactionsQueryParameters(string? from, int? limit) { diff --git a/src/Mollie.Api/Framework/Factories/BalanceTransactionFactory.cs b/src/Mollie.Api/Framework/Factories/BalanceTransactionFactory.cs index aace03c4..a621ffb1 100644 --- a/src/Mollie.Api/Framework/Factories/BalanceTransactionFactory.cs +++ b/src/Mollie.Api/Framework/Factories/BalanceTransactionFactory.cs @@ -4,9 +4,9 @@ namespace Mollie.Api.Framework.Factories { internal class BalanceTransactionFactory { - public BalanceTransaction Create(string? type) { + public BalanceTransactionResponse Create(string? type) { if (string.IsNullOrEmpty(type)) { - return Activator.CreateInstance(); + return Activator.CreateInstance(); } switch (type) { @@ -16,24 +16,24 @@ public BalanceTransaction Create(string? type) { case BalanceTransactionContextType.ChargebackReversal: case BalanceTransactionContextType.ApplicationFee: case BalanceTransactionContextType.SplitPayment: - return Activator.CreateInstance(); + return Activator.CreateInstance(); case BalanceTransactionContextType.Capture: - return Activator.CreateInstance(); + return Activator.CreateInstance(); case BalanceTransactionContextType.Refund: case BalanceTransactionContextType.ReturnedRefund: case BalanceTransactionContextType.PlatformPaymentRefund: - return Activator.CreateInstance(); + return Activator.CreateInstance(); case BalanceTransactionContextType.Chargeback: case BalanceTransactionContextType.PlatformPaymentChargeback: - return Activator.CreateInstance(); + return Activator.CreateInstance(); case BalanceTransactionContextType.OutgoingTransfer: case BalanceTransactionContextType.CanceledOutgoingTransfer: case BalanceTransactionContextType.ReturnedTransfer: - return Activator.CreateInstance(); + return Activator.CreateInstance(); case BalanceTransactionContextType.InvoiceCompensation: - return Activator.CreateInstance(); + return Activator.CreateInstance(); default: - return Activator.CreateInstance(); + return Activator.CreateInstance(); } } } diff --git a/src/Mollie.Api/JsonConverters/BalanceTransactionJsonConverter.cs b/src/Mollie.Api/JsonConverters/BalanceTransactionJsonConverter.cs index b443cc7a..397e0fe4 100644 --- a/src/Mollie.Api/JsonConverters/BalanceTransactionJsonConverter.cs +++ b/src/Mollie.Api/JsonConverters/BalanceTransactionJsonConverter.cs @@ -4,14 +4,14 @@ using Newtonsoft.Json.Linq; namespace Mollie.Api.JsonConverters { - internal class BalanceTransactionJsonConverter : JsonCreationConverter { + internal class BalanceTransactionJsonConverter : JsonCreationConverter { private readonly BalanceTransactionFactory _balanceTransactionFactory; public BalanceTransactionJsonConverter(BalanceTransactionFactory balanceTransactionFactory) { _balanceTransactionFactory = balanceTransactionFactory; } - protected override BalanceTransaction Create(Type objectType, JObject jObject) { + protected override BalanceTransactionResponse Create(Type objectType, JObject jObject) { string? transactionType = GetTransactionType(jObject); return _balanceTransactionFactory.Create(transactionType); diff --git a/src/Mollie.Api/Models/Balance/Response/BalanceTransaction/BalanceTransaction.cs b/src/Mollie.Api/Models/Balance/Response/BalanceTransaction/BalanceTransaction.cs deleted file mode 100644 index f1f240e9..00000000 --- a/src/Mollie.Api/Models/Balance/Response/BalanceTransaction/BalanceTransaction.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; - -namespace Mollie.Api.Models.Balance.Response.BalanceTransaction { - public class BalanceTransaction { - /// - /// Indicates the response contains a balance transaction object. Will always contain balance_transaction - /// for this endpoint. - /// - public required string Resource { get; set; } - - /// - /// The identifier uniquely referring to this balance transaction. Mollie assigns this identifier at - /// transaction creation time. For example baltr_QM24QwzUWR4ev4Xfgyt29d. - /// - public required string Id { get; set; } - - /// - /// The type of movement, for example payment or refund. See Mollie docs for a full list of values - /// - public required string Type { get; set; } - - /// - /// The final amount that was moved to or from the balance, e.g. {"currency":"EUR", "value":"100.00"}. - /// If the transaction moves funds away from the balance, for example when it concerns a refund, the - /// amount will be negative. - /// - public required Amount ResultAmount { get; set; } - - /// - /// The amount that was to be moved to or from the balance, excluding deductions. If the transaction - /// moves funds away from the balance, for example when it concerns a refund, the amount will be negative. - /// - public required Amount InitialAmount { get; set; } - - /// - /// The total amount of deductions withheld from the movement. For example, if a €10,00 payment comes in - /// with a €0,29 fee, the deductions amount will be {"currency":"EUR", "value":"-0.29"}. When moving funds - /// to a balance, we always round the deduction to a ‘real’ amount. Any differences between these realtime - /// rounded amounts and the final invoice will be compensated when the invoice is generated. - /// - public required Amount Deductions { get; set; } - - /// - /// The date and time of the movement, in ISO 8601 format. - /// - public required DateTime CreatedAt { get; set; } - } -} diff --git a/src/Mollie.Api/Models/Balance/Response/BalanceTransaction/BalanceTransactionResponse.cs b/src/Mollie.Api/Models/Balance/Response/BalanceTransaction/BalanceTransactionResponse.cs index ad3df380..bb1571f5 100644 --- a/src/Mollie.Api/Models/Balance/Response/BalanceTransaction/BalanceTransactionResponse.cs +++ b/src/Mollie.Api/Models/Balance/Response/BalanceTransaction/BalanceTransactionResponse.cs @@ -1,29 +1,48 @@ -using System.Collections.Generic; -using Newtonsoft.Json; +using System; namespace Mollie.Api.Models.Balance.Response.BalanceTransaction { public class BalanceTransactionResponse { /// - /// The number of transactions found in _embedded, which is either the requested number - /// (with a maximum of 250) or the default number. + /// Indicates the response contains a balance transaction object. Will always contain balance_transaction + /// for this endpoint. /// - public required int Count { get; set; } + public required string Resource { get; set; } /// - /// The object containing the queried data. + /// The identifier uniquely referring to this balance transaction. Mollie assigns this identifier at + /// transaction creation time. For example baltr_QM24QwzUWR4ev4Xfgyt29d. /// - [JsonProperty("_embedded")] - public required BalanceTransactionEmbeddedResponse Embedded { get; set; } + public required string Id { get; set; } /// - /// Links to help navigate through the lists of balance transactions. Every URL object will contain an href and a type field. + /// The type of movement, for example payment or refund. See Mollie docs for a full list of values /// - [JsonProperty("_links")] - public required BalanceTransactionResponseLinks Links { get; set; } - } + public required string Type { get; set; } + + /// + /// The final amount that was moved to or from the balance, e.g. {"currency":"EUR", "value":"100.00"}. + /// If the transaction moves funds away from the balance, for example when it concerns a refund, the + /// amount will be negative. + /// + public required Amount ResultAmount { get; set; } + + /// + /// The amount that was to be moved to or from the balance, excluding deductions. If the transaction + /// moves funds away from the balance, for example when it concerns a refund, the amount will be negative. + /// + public required Amount InitialAmount { get; set; } + + /// + /// The total amount of deductions withheld from the movement. For example, if a €10,00 payment comes in + /// with a €0,29 fee, the deductions amount will be {"currency":"EUR", "value":"-0.29"}. When moving funds + /// to a balance, we always round the deduction to a ‘real’ amount. Any differences between these realtime + /// rounded amounts and the final invoice will be compensated when the invoice is generated. + /// + public required Amount Deductions { get; set; } - public class BalanceTransactionEmbeddedResponse { - [JsonProperty("balance_transactions")] - public required IEnumerable BalanceTransactions { get; set; } + /// + /// The date and time of the movement, in ISO 8601 format. + /// + public required DateTime CreatedAt { get; set; } } } diff --git a/src/Mollie.Api/Models/Balance/Response/BalanceTransaction/BalanceTransactionResponseLinks.cs b/src/Mollie.Api/Models/Balance/Response/BalanceTransaction/BalanceTransactionResponseLinks.cs deleted file mode 100644 index 0f0a3292..00000000 --- a/src/Mollie.Api/Models/Balance/Response/BalanceTransaction/BalanceTransactionResponseLinks.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Mollie.Api.Models.Url; - -namespace Mollie.Api.Models.Balance.Response.BalanceTransaction { - public class BalanceTransactionResponseLinks { - /// - /// The URL to the current set of balance transactions. - /// - public required UrlObjectLink Self { get; set; } - - /// - /// The previous set of balance transactions, if available. - /// - public required UrlLink Previous { get; set; } - - /// - /// The next set of balance transactions, if available. - /// - public required UrlLink Next { get; set; } - - /// - /// The URL to the balance transactions list endpoint documentation. - /// - public required UrlLink Documentation { get; set; } - } -} diff --git a/src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/CaptureBalanceTransaction.cs b/src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/CaptureBalanceTransactionResponse.cs similarity index 79% rename from src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/CaptureBalanceTransaction.cs rename to src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/CaptureBalanceTransactionResponse.cs index df73254e..ff030aa6 100644 --- a/src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/CaptureBalanceTransaction.cs +++ b/src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/CaptureBalanceTransactionResponse.cs @@ -1,5 +1,5 @@ namespace Mollie.Api.Models.Balance.Response.BalanceTransaction.Specific { - public class CaptureBalanceTransaction : BalanceTransaction { + public class CaptureBalanceTransactionResponse : BalanceTransactionResponse { public required CaptureTransactionContext Context { get; set; } } diff --git a/src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/ChargebackBalanceTransaction.cs b/src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/ChargebackBalanceTransactionResponse.cs similarity index 79% rename from src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/ChargebackBalanceTransaction.cs rename to src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/ChargebackBalanceTransactionResponse.cs index 1fc7f47e..add4f869 100644 --- a/src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/ChargebackBalanceTransaction.cs +++ b/src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/ChargebackBalanceTransactionResponse.cs @@ -1,5 +1,5 @@ namespace Mollie.Api.Models.Balance.Response.BalanceTransaction.Specific { - public class ChargebackBalanceTransaction : BalanceTransaction { + public class ChargebackBalanceTransactionResponse : BalanceTransactionResponse { public required ChargebackTransactionContext Context { get; set; } } diff --git a/src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/InvoiceBalanceTransaction.cs b/src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/InvoiceBalanceTransactionResponse.cs similarity index 76% rename from src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/InvoiceBalanceTransaction.cs rename to src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/InvoiceBalanceTransactionResponse.cs index 45a70f6b..312a065c 100644 --- a/src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/InvoiceBalanceTransaction.cs +++ b/src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/InvoiceBalanceTransactionResponse.cs @@ -1,5 +1,5 @@ namespace Mollie.Api.Models.Balance.Response.BalanceTransaction.Specific { - public class InvoiceBalanceTransaction : BalanceTransaction { + public class InvoiceBalanceTransactionResponse : BalanceTransactionResponse { public required InvoiceTransactionContext Context { get; set; } } diff --git a/src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/PaymentBalanceTransaction.cs b/src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/PaymentBalanceTransactionResponse.cs similarity index 76% rename from src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/PaymentBalanceTransaction.cs rename to src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/PaymentBalanceTransactionResponse.cs index bc603a0f..03f13a98 100644 --- a/src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/PaymentBalanceTransaction.cs +++ b/src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/PaymentBalanceTransactionResponse.cs @@ -1,5 +1,5 @@ namespace Mollie.Api.Models.Balance.Response.BalanceTransaction.Specific { - public class PaymentBalanceTransaction : BalanceTransaction { + public class PaymentBalanceTransactionResponse : BalanceTransactionResponse { public required PaymentTransactionContext Context { get; set; } } diff --git a/src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/RefundBalanceTransaction.cs b/src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/RefundBalanceTransactionResponse.cs similarity index 79% rename from src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/RefundBalanceTransaction.cs rename to src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/RefundBalanceTransactionResponse.cs index 8a804c29..7ed51f99 100644 --- a/src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/RefundBalanceTransaction.cs +++ b/src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/RefundBalanceTransactionResponse.cs @@ -1,5 +1,5 @@ namespace Mollie.Api.Models.Balance.Response.BalanceTransaction.Specific { - public class RefundBalanceTransaction : BalanceTransaction { + public class RefundBalanceTransactionResponse : BalanceTransactionResponse { public required RefundTransactionContext Context { get; set; } } diff --git a/src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/SettlementBalanceTransaction.cs b/src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/SettlementBalanceTransactionResponse.cs similarity index 79% rename from src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/SettlementBalanceTransaction.cs rename to src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/SettlementBalanceTransactionResponse.cs index 9dd9d012..6c978ed4 100644 --- a/src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/SettlementBalanceTransaction.cs +++ b/src/Mollie.Api/Models/Balance/Response/BalanceTransaction/Specific/SettlementBalanceTransactionResponse.cs @@ -1,5 +1,5 @@ namespace Mollie.Api.Models.Balance.Response.BalanceTransaction.Specific { - public class SettlementBalanceTransaction : BalanceTransaction { + public class SettlementBalanceTransactionResponse : BalanceTransactionResponse { public required SettlementTransactionContext Context { get; set; } } diff --git a/tests/Mollie.Tests.Integration/Api/BalanceTests.cs b/tests/Mollie.Tests.Integration/Api/BalanceTests.cs index a3d6b4cc..387dd843 100644 --- a/tests/Mollie.Tests.Integration/Api/BalanceTests.cs +++ b/tests/Mollie.Tests.Integration/Api/BalanceTests.cs @@ -112,8 +112,7 @@ public async Task ListBalanceTransactionsAsync_IsParsedCorrectly() { // Then: Make sure we can parse the result result.Should().NotBeNull(); - result.Embedded.Should().NotBeNull(); - result.Embedded.BalanceTransactions.Should().NotBeNull(); + result.Items.Should().NotBeNull(); result.Links.Should().NotBeNull(); result.Links.Self.Href.Should().Be($"https://api.mollie.com/v2/balances/{balanceId}/transactions?from={from}&limit={limit}"); } @@ -129,8 +128,7 @@ public async Task ListPrimaryBalanceTransactionsAsync_IsParsedCorrectly() { // Then: Make sure we can parse the result result.Should().NotBeNull(); - result.Embedded.Should().NotBeNull(); - result.Embedded.BalanceTransactions.Should().NotBeNull(); + result.Items.Should().NotBeNull(); } public void Dispose() diff --git a/tests/Mollie.Tests.Unit/Client/BalanceClientTests.cs b/tests/Mollie.Tests.Unit/Client/BalanceClientTests.cs index be53d225..b2c2928b 100644 --- a/tests/Mollie.Tests.Unit/Client/BalanceClientTests.cs +++ b/tests/Mollie.Tests.Unit/Client/BalanceClientTests.cs @@ -234,9 +234,9 @@ public async Task ListBalanceTransactionsAsync_StatusBalances_ResponseIsParsed() // Then: Response should be parsed mockHttp.VerifyNoOutstandingExpectation(); - balanceTransactions?.Embedded?.BalanceTransactions.Should().NotBeNull(); - balanceTransactions.Count.Should().Be(balanceTransactions.Embedded.BalanceTransactions.Count()); - var transaction = balanceTransactions.Embedded.BalanceTransactions.First(); + balanceTransactions?.Items?.Should().NotBeNull(); + balanceTransactions.Count.Should().Be(balanceTransactions.Items.Count()); + var transaction = balanceTransactions.Items.First(); transaction.Resource.Should().Be("balance_transactions"); transaction.Id.Should().Be("baltr_9S8yk4FFqqi2Qm6K3rqRH"); transaction.Type.Should().Be("outgoing-transfer"); @@ -244,8 +244,8 @@ public async Task ListBalanceTransactionsAsync_StatusBalances_ResponseIsParsed() transaction.ResultAmount.Currency.Should().Be(Currency.EUR); transaction.InitialAmount.Value.Should().Be("-7.76"); transaction.InitialAmount.Currency.Should().Be(Currency.EUR); - transaction.Should().BeOfType(); - var transactionContext = (SettlementBalanceTransaction)transaction; + transaction.Should().BeOfType(); + var transactionContext = (SettlementBalanceTransactionResponse)transaction; transactionContext.Context.SettlementId.Should().Be("stl_ma2vu8"); transactionContext.Context.TransferId.Should().Be("trf_ma2vu8"); } @@ -280,8 +280,8 @@ public async Task ListPrimaryBalanceTransactionsAsync_StatusBalances_ResponseIsP // Then: Response should be parsed mockHttp.VerifyNoOutstandingExpectation(); - balanceTransactions?.Embedded?.BalanceTransactions.Should().NotBeNull(); - balanceTransactions.Count.Should().Be(balanceTransactions.Embedded.BalanceTransactions.Count()); + balanceTransactions?.Items?.Should().NotBeNull(); + balanceTransactions.Count.Should().Be(balanceTransactions.Items.Count()); } private readonly string DefaultListBalanceTransactionsResponse = @" diff --git a/tests/Mollie.Tests.Unit/Framework/Factories/BalanceTransactionFactoryTests.cs b/tests/Mollie.Tests.Unit/Framework/Factories/BalanceTransactionFactoryTests.cs index d2fd14d0..6325c49d 100644 --- a/tests/Mollie.Tests.Unit/Framework/Factories/BalanceTransactionFactoryTests.cs +++ b/tests/Mollie.Tests.Unit/Framework/Factories/BalanceTransactionFactoryTests.cs @@ -8,24 +8,24 @@ namespace Mollie.Tests.Unit.Framework.Factories { public class BalanceTransactionFactoryTests { [Theory] - [InlineData(BalanceTransactionContextType.Payment, typeof(PaymentBalanceTransaction))] - [InlineData(BalanceTransactionContextType.Capture, typeof(CaptureBalanceTransaction))] - [InlineData(BalanceTransactionContextType.UnauthorizedDirectDebit, typeof(PaymentBalanceTransaction))] - [InlineData(BalanceTransactionContextType.FailedPayment, typeof(PaymentBalanceTransaction))] - [InlineData(BalanceTransactionContextType.Refund, typeof(RefundBalanceTransaction))] - [InlineData(BalanceTransactionContextType.ReturnedRefund, typeof(RefundBalanceTransaction))] - [InlineData(BalanceTransactionContextType.Chargeback, typeof(ChargebackBalanceTransaction))] - [InlineData(BalanceTransactionContextType.ChargebackReversal, typeof(PaymentBalanceTransaction))] - [InlineData(BalanceTransactionContextType.OutgoingTransfer, typeof(SettlementBalanceTransaction))] - [InlineData(BalanceTransactionContextType.CanceledOutgoingTransfer, typeof(SettlementBalanceTransaction))] - [InlineData(BalanceTransactionContextType.ReturnedTransfer, typeof(SettlementBalanceTransaction))] - [InlineData(BalanceTransactionContextType.InvoiceCompensation, typeof(InvoiceBalanceTransaction))] - [InlineData(BalanceTransactionContextType.BalanceCorrection, typeof(BalanceTransaction))] - [InlineData(BalanceTransactionContextType.ApplicationFee, typeof(PaymentBalanceTransaction))] - [InlineData(BalanceTransactionContextType.SplitPayment, typeof(PaymentBalanceTransaction))] - [InlineData(BalanceTransactionContextType.PlatformPaymentRefund, typeof(RefundBalanceTransaction))] - [InlineData(BalanceTransactionContextType.PlatformPaymentChargeback, typeof(ChargebackBalanceTransaction))] - [InlineData("UnknownType", typeof(BalanceTransaction))] + [InlineData(BalanceTransactionContextType.Payment, typeof(PaymentBalanceTransactionResponse))] + [InlineData(BalanceTransactionContextType.Capture, typeof(CaptureBalanceTransactionResponse))] + [InlineData(BalanceTransactionContextType.UnauthorizedDirectDebit, typeof(PaymentBalanceTransactionResponse))] + [InlineData(BalanceTransactionContextType.FailedPayment, typeof(PaymentBalanceTransactionResponse))] + [InlineData(BalanceTransactionContextType.Refund, typeof(RefundBalanceTransactionResponse))] + [InlineData(BalanceTransactionContextType.ReturnedRefund, typeof(RefundBalanceTransactionResponse))] + [InlineData(BalanceTransactionContextType.Chargeback, typeof(ChargebackBalanceTransactionResponse))] + [InlineData(BalanceTransactionContextType.ChargebackReversal, typeof(PaymentBalanceTransactionResponse))] + [InlineData(BalanceTransactionContextType.OutgoingTransfer, typeof(SettlementBalanceTransactionResponse))] + [InlineData(BalanceTransactionContextType.CanceledOutgoingTransfer, typeof(SettlementBalanceTransactionResponse))] + [InlineData(BalanceTransactionContextType.ReturnedTransfer, typeof(SettlementBalanceTransactionResponse))] + [InlineData(BalanceTransactionContextType.InvoiceCompensation, typeof(InvoiceBalanceTransactionResponse))] + [InlineData(BalanceTransactionContextType.BalanceCorrection, typeof(BalanceTransactionResponse))] + [InlineData(BalanceTransactionContextType.ApplicationFee, typeof(PaymentBalanceTransactionResponse))] + [InlineData(BalanceTransactionContextType.SplitPayment, typeof(PaymentBalanceTransactionResponse))] + [InlineData(BalanceTransactionContextType.PlatformPaymentRefund, typeof(RefundBalanceTransactionResponse))] + [InlineData(BalanceTransactionContextType.PlatformPaymentChargeback, typeof(ChargebackBalanceTransactionResponse))] + [InlineData("UnknownType", typeof(BalanceTransactionResponse))] public void Create_CreatesTypeBasedOnType(string type, Type expectedType) { // Given var sut = new BalanceTransactionFactory();