diff --git a/samples/Mollie.WebApplication.Blazor/Framework/Validators/StaticStringListAttribute.cs b/samples/Mollie.WebApplication.Blazor/Framework/Validators/StaticStringListAttribute.cs index c0eebf77..c732466a 100644 --- a/samples/Mollie.WebApplication.Blazor/Framework/Validators/StaticStringListAttribute.cs +++ b/samples/Mollie.WebApplication.Blazor/Framework/Validators/StaticStringListAttribute.cs @@ -1,24 +1,24 @@ using System.ComponentModel.DataAnnotations; using System.Reflection; -namespace Mollie.WebApplication.Blazor.Framework.Validators; +namespace Mollie.WebApplication.Blazor.Framework.Validators; public class StaticStringListAttribute : ValidationAttribute { private readonly Type _staticClass; public StaticStringListAttribute(Type staticClass) { - this._staticClass = staticClass; + _staticClass = staticClass; } protected override ValidationResult IsValid(object value, ValidationContext validationContext) { - IEnumerable validValues = this._staticClass + IEnumerable validValues = _staticClass .GetFields(BindingFlags.Static | BindingFlags.Public) .Select(x => x.GetValue(null).ToString()); if (validValues.Contains(value)) { return ValidationResult.Success; } - + return new ValidationResult($"The value \"{value}\" is invalid"); } } diff --git a/src/Mollie.Api/Client/BalanceClient.cs b/src/Mollie.Api/Client/BalanceClient.cs index 0ea2d588..dbf9644b 100644 --- a/src/Mollie.Api/Client/BalanceClient.cs +++ b/src/Mollie.Api/Client/BalanceClient.cs @@ -15,49 +15,49 @@ namespace Mollie.Api.Client { public class BalanceClient : BaseMollieClient, IBalanceClient { public BalanceClient(string apiKey, HttpClient? httpClient = null) : base(apiKey, httpClient) { } - + public async Task GetBalanceAsync(string balanceId) { - this.ValidateRequiredUrlParameter(nameof(balanceId), balanceId); - return await this.GetAsync($"balances/{balanceId}").ConfigureAwait(false); + ValidateRequiredUrlParameter(nameof(balanceId), balanceId); + return await GetAsync($"balances/{balanceId}").ConfigureAwait(false); } - + public async Task GetBalanceAsync(UrlObjectLink url) { - return await this.GetAsync(url).ConfigureAwait(false); + return await GetAsync(url).ConfigureAwait(false); } - + public async Task GetPrimaryBalanceAsync() { - return await this.GetAsync("balances/primary").ConfigureAwait(false); + return await GetAsync("balances/primary").ConfigureAwait(false); } - + public async Task> ListBalancesAsync(string? from = null, int? limit = null, string? currency = null) { var queryParameters = BuildListBalanceQueryParameters(currency); - return await this.GetListAsync>($"balances", from, limit, queryParameters).ConfigureAwait(false); + return await GetListAsync>($"balances", from, limit, queryParameters).ConfigureAwait(false); } - + public async Task> ListBalancesAsync(UrlObjectLink> url) { - return await this.GetAsync(url).ConfigureAwait(false); + return await GetAsync(url).ConfigureAwait(false); } public async Task GetBalanceReportAsync(string balanceId, DateTime from, DateTime until, string? grouping = null) { - this.ValidateRequiredUrlParameter(nameof(balanceId), balanceId); + ValidateRequiredUrlParameter(nameof(balanceId), balanceId); var queryParameters = BuildGetBalanceReportQueryParameters(from, until, grouping); - return await this.GetAsync($"balances/{balanceId}/report{queryParameters.ToQueryString()}").ConfigureAwait(false); + return await GetAsync($"balances/{balanceId}/report{queryParameters.ToQueryString()}").ConfigureAwait(false); } - + public async Task GetPrimaryBalanceReportAsync(DateTime from, DateTime until, string? grouping = null) { var queryParameters = BuildGetBalanceReportQueryParameters(from, until, grouping); - return await this.GetAsync($"balances/primary/report{queryParameters.ToQueryString()}").ConfigureAwait(false); + return await GetAsync($"balances/primary/report{queryParameters.ToQueryString()}").ConfigureAwait(false); } public async Task ListBalanceTransactionsAsync(string balanceId, string? from = null, int? limit = null) { - this.ValidateRequiredUrlParameter(nameof(balanceId), balanceId); + ValidateRequiredUrlParameter(nameof(balanceId), balanceId); var queryParameters = BuildListBalanceTransactionsQueryParameters(from, limit); - return await this.GetAsync($"balances/{balanceId}/transactions{queryParameters.ToQueryString()}").ConfigureAwait(false); + return await GetAsync($"balances/{balanceId}/transactions{queryParameters.ToQueryString()}").ConfigureAwait(false); } - + public async Task ListPrimaryBalanceTransactionsAsync(string? from = null, int? limit = null) { var queryParameters = BuildListBalanceTransactionsQueryParameters(from, limit); - return await this.GetAsync($"balances/primary/transactions{queryParameters.ToQueryString()}").ConfigureAwait(false); + return await GetAsync($"balances/primary/transactions{queryParameters.ToQueryString()}").ConfigureAwait(false); } private Dictionary BuildListBalanceTransactionsQueryParameters(string? from, int? limit) { @@ -74,11 +74,11 @@ private Dictionary BuildGetBalanceReportQueryParameters(DateTime result.AddValueIfNotNullOrEmpty("grouping", grouping); return result; } - + private Dictionary BuildListBalanceQueryParameters(string? currency) { var result = new Dictionary(); result.AddValueIfNotNullOrEmpty("currency", currency); return result; } } -} \ No newline at end of file +} diff --git a/src/Mollie.Api/Client/BaseMollieClient.cs b/src/Mollie.Api/Client/BaseMollieClient.cs index fb319a5a..afd586c5 100644 --- a/src/Mollie.Api/Client/BaseMollieClient.cs +++ b/src/Mollie.Api/Client/BaseMollieClient.cs @@ -48,7 +48,7 @@ public IDisposable WithIdempotencyKey(string value) { } private async Task SendHttpRequest(HttpMethod httpMethod, string relativeUri, object? data = null) { - HttpRequestMessage httpRequest = this.CreateHttpRequest(httpMethod, relativeUri); + HttpRequestMessage httpRequest = CreateHttpRequest(httpMethod, relativeUri); if (data != null) { var jsonData = _jsonConverterService.Serialize(data); var content = new StringContent(jsonData, Encoding.UTF8, "application/json"); @@ -60,7 +60,7 @@ private async Task SendHttpRequest(HttpMethod httpMethod, string relativeU } protected async Task GetListAsync(string relativeUri, string? from, int? limit, IDictionary? otherParameters = null) { - string url = relativeUri + this.BuildListQueryString(from, limit, otherParameters); + string url = relativeUri + BuildListQueryString(from, limit, otherParameters); return await SendHttpRequest(HttpMethod.Get, url).ConfigureAwait(false); } @@ -135,7 +135,7 @@ protected virtual HttpRequestMessage CreateHttpRequest(HttpMethod method, string HttpRequestMessage httpRequest = new HttpRequestMessage(method, new Uri(new Uri(_apiEndpoint), relativeUri)); httpRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); httpRequest.Headers.Authorization = new AuthenticationHeaderValue("Bearer", _apiKey); - httpRequest.Headers.Add("User-Agent", this.GetUserAgent()); + httpRequest.Headers.Add("User-Agent", GetUserAgent()); var idemPotencyKey = _idempotencyKey.Value ?? Guid.NewGuid().ToString(); httpRequest.Headers.Add("Idempotency-Key", idemPotencyKey); httpRequest.Content = content; diff --git a/src/Mollie.Api/Client/CaptureClient.cs b/src/Mollie.Api/Client/CaptureClient.cs index fcf2786b..75c214a6 100644 --- a/src/Mollie.Api/Client/CaptureClient.cs +++ b/src/Mollie.Api/Client/CaptureClient.cs @@ -15,39 +15,39 @@ public CaptureClient(string apiKey, HttpClient? httpClient = null) : base(apiKey } public async Task GetCaptureAsync(string paymentId, string captureId, bool testmode = false) { - this.ValidateRequiredUrlParameter(nameof(paymentId), paymentId); - this.ValidateRequiredUrlParameter(nameof(captureId), captureId); + ValidateRequiredUrlParameter(nameof(paymentId), paymentId); + ValidateRequiredUrlParameter(nameof(captureId), captureId); var queryParameters = BuildQueryParameters(testmode); - return await this.GetAsync($"payments/{paymentId}/captures/{captureId}{queryParameters.ToQueryString()}") + return await GetAsync($"payments/{paymentId}/captures/{captureId}{queryParameters.ToQueryString()}") .ConfigureAwait(false); } - + public async Task GetCaptureAsync(UrlObjectLink url) { - return await this.GetAsync(url).ConfigureAwait(false); + return await GetAsync(url).ConfigureAwait(false); } public async Task> GetCapturesListAsync(string paymentId, bool testmode = false) { - this.ValidateRequiredUrlParameter(nameof(paymentId), paymentId); + ValidateRequiredUrlParameter(nameof(paymentId), paymentId); var queryParameters = BuildQueryParameters(testmode); - return await this.GetAsync>($"payments/{paymentId}/captures{queryParameters.ToQueryString()}") + return await GetAsync>($"payments/{paymentId}/captures{queryParameters.ToQueryString()}") .ConfigureAwait(false); } - + public async Task> GetCapturesListAsync(UrlObjectLink> url) { - return await this.GetAsync(url).ConfigureAwait(false); + return await GetAsync(url).ConfigureAwait(false); } public async Task CreateCapture(string paymentId, CaptureRequest captureRequest, bool testmode = false) { - this.ValidateRequiredUrlParameter(nameof(paymentId), paymentId); + ValidateRequiredUrlParameter(nameof(paymentId), paymentId); var queryParameters = BuildQueryParameters(testmode); - return await this.PostAsync($"payments/{paymentId}/captures{queryParameters.ToQueryString()}", captureRequest) + return await PostAsync($"payments/{paymentId}/captures{queryParameters.ToQueryString()}", captureRequest) .ConfigureAwait(false); } - + private Dictionary BuildQueryParameters(bool testmode) { var result = new Dictionary(); result.AddValueIfTrue("testmode", testmode); return result; } } -} \ No newline at end of file +} diff --git a/src/Mollie.Api/Client/ChargebacksClient.cs b/src/Mollie.Api/Client/ChargebacksClient.cs index 9c49db1b..f333911d 100644 --- a/src/Mollie.Api/Client/ChargebacksClient.cs +++ b/src/Mollie.Api/Client/ChargebacksClient.cs @@ -13,41 +13,41 @@ public ChargebacksClient(string apiKey, HttpClient? httpClient = null) : base(ap } public async Task GetChargebackAsync(string paymentId, string chargebackId, bool testmode = false) { - this.ValidateRequiredUrlParameter(nameof(paymentId), paymentId); - this.ValidateRequiredUrlParameter(nameof(chargebackId), chargebackId); - var queryParameters = this.BuildQueryParameters(testmode); - return await this.GetAsync($"payments/{paymentId}/chargebacks/{chargebackId}{queryParameters.ToQueryString()}") + ValidateRequiredUrlParameter(nameof(paymentId), paymentId); + ValidateRequiredUrlParameter(nameof(chargebackId), chargebackId); + var queryParameters = BuildQueryParameters(testmode); + return await GetAsync($"payments/{paymentId}/chargebacks/{chargebackId}{queryParameters.ToQueryString()}") .ConfigureAwait(false); } public async Task> GetChargebacksListAsync(string paymentId, string? from = null, int? limit = null, bool testmode = false) { - this.ValidateRequiredUrlParameter(nameof(paymentId), paymentId); - var queryParameters = this.BuildQueryParameters(testmode); + ValidateRequiredUrlParameter(nameof(paymentId), paymentId); + var queryParameters = BuildQueryParameters(testmode); return await this .GetListAsync>($"payments/{paymentId}/chargebacks", from, limit, queryParameters) .ConfigureAwait(false); } public async Task> GetChargebacksListAsync(string? profileId = null, bool testmode = false) { - var queryParameters = this.BuildQueryParameters(profileId, testmode); - return await this.GetListAsync>($"chargebacks", null, null, queryParameters).ConfigureAwait(false); + var queryParameters = BuildQueryParameters(profileId, testmode); + return await GetListAsync>($"chargebacks", null, null, queryParameters).ConfigureAwait(false); } - + public async Task> GetChargebacksListAsync(UrlObjectLink> url) { - return await this.GetAsync(url).ConfigureAwait(false); + return await GetAsync(url).ConfigureAwait(false); } - + private Dictionary BuildQueryParameters(string? profileId, bool testmode) { var result = new Dictionary(); result.AddValueIfNotNullOrEmpty(nameof(profileId), profileId); result.AddValueIfTrue(nameof(testmode), testmode); return result; } - + private Dictionary BuildQueryParameters(bool testmode) { var result = new Dictionary(); result.AddValueIfTrue(nameof(testmode), testmode); return result; } } -} \ No newline at end of file +} diff --git a/src/Mollie.Api/Client/ClientLinkClient.cs b/src/Mollie.Api/Client/ClientLinkClient.cs index fd343324..908162e4 100644 --- a/src/Mollie.Api/Client/ClientLinkClient.cs +++ b/src/Mollie.Api/Client/ClientLinkClient.cs @@ -14,19 +14,19 @@ public class ClientLinkClient : OauthBaseMollieClient, IClientLinkClient public ClientLinkClient(string clientId, string oauthAccessToken, HttpClient? httpClient = null) : base(oauthAccessToken, httpClient) { - this._clientId = clientId; + _clientId = clientId; } public async Task CreateClientLinkAsync(ClientLinkRequest request) { - return await this.PostAsync($"client-links", request) + return await PostAsync($"client-links", request) .ConfigureAwait(false); } public string GenerateClientLinkWithParameters( string clientLinkUrl, string state, - List scopes, + List scopes, bool forceApprovalPrompt = false) { var parameters = new Dictionary { @@ -39,4 +39,4 @@ public string GenerateClientLinkWithParameters( return clientLinkUrl + parameters.ToQueryString(); } } -} \ No newline at end of file +} diff --git a/src/Mollie.Api/Client/ConnectClient.cs b/src/Mollie.Api/Client/ConnectClient.cs index c52d7659..02a201fb 100644 --- a/src/Mollie.Api/Client/ConnectClient.cs +++ b/src/Mollie.Api/Client/ConnectClient.cs @@ -12,7 +12,7 @@ namespace Mollie.Api.Client { public class ConnectClient : BaseMollieClient, IConnectClient { private const string AuthorizeEndPoint = "https://www.mollie.com/oauth2/authorize"; private const string TokenEndPoint = "https://api.mollie.nl/oauth2/"; - + private readonly string _clientId; private readonly string _clientSecret; @@ -24,21 +24,21 @@ public ConnectClient(string clientId, string clientSecret, HttpClient? httpClien if (string.IsNullOrWhiteSpace(clientSecret)) { throw new ArgumentNullException(nameof(clientSecret)); } - - this._clientSecret = clientSecret; - this._clientId = clientId; + + _clientSecret = clientSecret; + _clientId = clientId; } public string GetAuthorizationUrl( - string state, - List scopes, - string? redirectUri = null, - bool forceApprovalPrompt = false, - string? locale = null, + string state, + List scopes, + string? redirectUri = null, + bool forceApprovalPrompt = false, + string? locale = null, string? landingPage = null) { - + var parameters = new Dictionary { - {"client_id", this._clientId}, + {"client_id", _clientId}, {"state", state}, {"scope", string.Join(" ", scopes)}, {"response_type", "code"}, @@ -52,17 +52,17 @@ public string GetAuthorizationUrl( } public async Task GetAccessTokenAsync(TokenRequest request) { - return await this.PostAsync("tokens", request).ConfigureAwait(false); + return await PostAsync("tokens", request).ConfigureAwait(false); } public async Task RevokeTokenAsync(RevokeTokenRequest request) { - await this.DeleteAsync("tokens", request).ConfigureAwait(false); + await DeleteAsync("tokens", request).ConfigureAwait(false); } protected override HttpRequestMessage CreateHttpRequest(HttpMethod method, string relativeUri, HttpContent? content = null) { HttpRequestMessage httpRequest = new HttpRequestMessage(method, new Uri(new Uri(ConnectClient.TokenEndPoint), relativeUri)); httpRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); - httpRequest.Headers.Authorization = new AuthenticationHeaderValue("Basic", this.Base64Encode($"{this._clientId}:{this._clientSecret}")); + httpRequest.Headers.Authorization = new AuthenticationHeaderValue("Basic", Base64Encode($"{_clientId}:{_clientSecret}")); httpRequest.Content = content; return httpRequest; @@ -73,4 +73,4 @@ private string Base64Encode(string value) { return Convert.ToBase64String(bytes); } } -} \ No newline at end of file +} diff --git a/src/Mollie.Api/Client/CustomerClient.cs b/src/Mollie.Api/Client/CustomerClient.cs index ccf8f3ce..a1c194cc 100644 --- a/src/Mollie.Api/Client/CustomerClient.cs +++ b/src/Mollie.Api/Client/CustomerClient.cs @@ -16,57 +16,57 @@ public CustomerClient(string apiKey, HttpClient? httpClient = null) : base(apiKe } public async Task CreateCustomerAsync(CustomerRequest request) { - return await this.PostAsync($"customers", request).ConfigureAwait(false); + return await PostAsync($"customers", request).ConfigureAwait(false); } public async Task UpdateCustomerAsync(string customerId, CustomerRequest request) { - this.ValidateRequiredUrlParameter(nameof(customerId), customerId); - return await this.PostAsync($"customers/{customerId}", request).ConfigureAwait(false); + ValidateRequiredUrlParameter(nameof(customerId), customerId); + return await PostAsync($"customers/{customerId}", request).ConfigureAwait(false); } public async Task DeleteCustomerAsync(string customerId, bool testmode = false) { - this.ValidateRequiredUrlParameter(nameof(customerId), customerId); + ValidateRequiredUrlParameter(nameof(customerId), customerId); var data = TestmodeModel.Create(testmode); - await this.DeleteAsync($"customers/{customerId}", data).ConfigureAwait(false); + await DeleteAsync($"customers/{customerId}", data).ConfigureAwait(false); } public async Task GetCustomerAsync(string customerId, bool testmode = false) { - this.ValidateRequiredUrlParameter(nameof(customerId), customerId); - var queryParameters = this.BuildQueryParameters(testmode); - return await this.GetAsync($"customers/{customerId}{queryParameters.ToQueryString()}").ConfigureAwait(false); + ValidateRequiredUrlParameter(nameof(customerId), customerId); + var queryParameters = BuildQueryParameters(testmode); + return await GetAsync($"customers/{customerId}{queryParameters.ToQueryString()}").ConfigureAwait(false); } public async Task GetCustomerAsync(UrlObjectLink url) { - return await this.GetAsync(url).ConfigureAwait(false); + return await GetAsync(url).ConfigureAwait(false); } public async Task> GetCustomerListAsync(UrlObjectLink> url) { - return await this.GetAsync(url).ConfigureAwait(false); + return await GetAsync(url).ConfigureAwait(false); } public async Task> GetCustomerListAsync(string? from = null, int? limit = null, bool testmode = false) { - var queryParameters = this.BuildQueryParameters(testmode); - return await this.GetListAsync>("customers", from, limit, queryParameters) + var queryParameters = BuildQueryParameters(testmode); + return await GetListAsync>("customers", from, limit, queryParameters) .ConfigureAwait(false); } public async Task> GetCustomerPaymentListAsync(string customerId, string? from = null, int? limit = null, string? profileId = null, bool testmode = false) { - this.ValidateRequiredUrlParameter(nameof(customerId), customerId); + ValidateRequiredUrlParameter(nameof(customerId), customerId); var queryParameters = BuildQueryParameters(profileId, testmode); - return await this.GetListAsync>($"customers/{customerId}/payments", from, limit, queryParameters).ConfigureAwait(false); + return await GetListAsync>($"customers/{customerId}/payments", from, limit, queryParameters).ConfigureAwait(false); } public async Task CreateCustomerPayment(string customerId, PaymentRequest paymentRequest) { - this.ValidateRequiredUrlParameter(nameof(customerId), customerId); + ValidateRequiredUrlParameter(nameof(customerId), customerId); return await PostAsync($"customers/{customerId}/payments", paymentRequest).ConfigureAwait(false); } - + private Dictionary BuildQueryParameters(bool testmode = false) { var result = new Dictionary(); result.AddValueIfTrue("testmode", testmode); return result; } - + private Dictionary BuildQueryParameters(string? profileId, bool testmode) { var result = new Dictionary(); result.AddValueIfNotNullOrEmpty("profileId", profileId); @@ -74,4 +74,4 @@ private Dictionary BuildQueryParameters(string? profileId, bool return result; } } -} \ No newline at end of file +} diff --git a/src/Mollie.Api/Client/InvoicesClient.cs b/src/Mollie.Api/Client/InvoicesClient.cs index f56003a4..361139fc 100644 --- a/src/Mollie.Api/Client/InvoicesClient.cs +++ b/src/Mollie.Api/Client/InvoicesClient.cs @@ -14,12 +14,12 @@ public InvoicesClient(string oauthAccessToken, HttpClient? httpClient = null) : } public async Task GetInvoiceAsync(string invoiceId) { - this.ValidateRequiredUrlParameter(nameof(invoiceId), invoiceId); - return await this.GetAsync($"invoices/{invoiceId}").ConfigureAwait(false); + ValidateRequiredUrlParameter(nameof(invoiceId), invoiceId); + return await GetAsync($"invoices/{invoiceId}").ConfigureAwait(false); } public async Task GetInvoiceAsync(UrlObjectLink url) { - return await this.GetAsync(url).ConfigureAwait(false); + return await GetAsync(url).ConfigureAwait(false); } public async Task> GetInvoiceListAsync( @@ -28,12 +28,12 @@ public async Task> GetInvoiceListAsync( parameters.AddValueIfNotNullOrEmpty(nameof(reference), reference); parameters.AddValueIfNotNullOrEmpty(nameof(year), Convert.ToString(year)); - return await this.GetListAsync>($"invoices", from, limit, parameters) + return await GetListAsync>($"invoices", from, limit, parameters) .ConfigureAwait(false); } - + public async Task> GetInvoiceListAsync(UrlObjectLink> url) { - return await this.GetAsync(url).ConfigureAwait(false); + return await GetAsync(url).ConfigureAwait(false); } } -} \ No newline at end of file +} diff --git a/src/Mollie.Api/Client/MandateClient.cs b/src/Mollie.Api/Client/MandateClient.cs index 400c374c..ef5e3d6a 100644 --- a/src/Mollie.Api/Client/MandateClient.cs +++ b/src/Mollie.Api/Client/MandateClient.cs @@ -14,41 +14,41 @@ public MandateClient(string apiKey, HttpClient? httpClient = null) : base(apiKey } public async Task GetMandateAsync(string customerId, string mandateId, bool testmode = false) { - this.ValidateRequiredUrlParameter(nameof(customerId), customerId); - this.ValidateRequiredUrlParameter(nameof(mandateId), mandateId); - var queryParameters = this.BuildQueryParameters(testmode); - return await this.GetAsync($"customers/{customerId}/mandates/{mandateId}{queryParameters.ToQueryString()}").ConfigureAwait(false); + ValidateRequiredUrlParameter(nameof(customerId), customerId); + ValidateRequiredUrlParameter(nameof(mandateId), mandateId); + var queryParameters = BuildQueryParameters(testmode); + return await GetAsync($"customers/{customerId}/mandates/{mandateId}{queryParameters.ToQueryString()}").ConfigureAwait(false); } public async Task> GetMandateListAsync(string customerId, string? from = null, int? limit = null, bool testmode = false) { - this.ValidateRequiredUrlParameter(nameof(customerId), customerId); - var queryParameters = this.BuildQueryParameters(testmode); - return await this.GetListAsync>($"customers/{customerId}/mandates", from, limit, queryParameters) + ValidateRequiredUrlParameter(nameof(customerId), customerId); + var queryParameters = BuildQueryParameters(testmode); + return await GetListAsync>($"customers/{customerId}/mandates", from, limit, queryParameters) .ConfigureAwait(false); } public async Task CreateMandateAsync(string customerId, MandateRequest request) { - this.ValidateRequiredUrlParameter(nameof(customerId), customerId); - return await this.PostAsync($"customers/{customerId}/mandates", request).ConfigureAwait(false); + ValidateRequiredUrlParameter(nameof(customerId), customerId); + return await PostAsync($"customers/{customerId}/mandates", request).ConfigureAwait(false); } public async Task> GetMandateListAsync(UrlObjectLink> url) { - return await this.GetAsync(url).ConfigureAwait(false); + return await GetAsync(url).ConfigureAwait(false); } public async Task GetMandateAsync(UrlObjectLink url) { - return await this.GetAsync(url).ConfigureAwait(false); + return await GetAsync(url).ConfigureAwait(false); } public async Task RevokeMandate(string customerId, string mandateId, bool testmode = false) { var data = TestmodeModel.Create(testmode); - await this.DeleteAsync($"customers/{customerId}/mandates/{mandateId}", data).ConfigureAwait(false); + await DeleteAsync($"customers/{customerId}/mandates/{mandateId}", data).ConfigureAwait(false); } - + private Dictionary BuildQueryParameters(bool testmode = false) { var result = new Dictionary(); result.AddValueIfTrue("testmode", testmode); return result; } } -} \ No newline at end of file +} diff --git a/src/Mollie.Api/Client/MollieApiException.cs b/src/Mollie.Api/Client/MollieApiException.cs index ec412005..2f01213d 100644 --- a/src/Mollie.Api/Client/MollieApiException.cs +++ b/src/Mollie.Api/Client/MollieApiException.cs @@ -7,11 +7,11 @@ public class MollieApiException : Exception { public MollieErrorMessage Details { get; set; } public MollieApiException(string json) : base(ParseErrorMessage(json).ToString()){ - this.Details = ParseErrorMessage(json); + Details = ParseErrorMessage(json); } private static MollieErrorMessage ParseErrorMessage(string json) { return JsonConvert.DeserializeObject(json)!; } } -} \ No newline at end of file +} diff --git a/src/Mollie.Api/Client/OauthBaseMollieClient.cs b/src/Mollie.Api/Client/OauthBaseMollieClient.cs index 86080021..1f9f5555 100644 --- a/src/Mollie.Api/Client/OauthBaseMollieClient.cs +++ b/src/Mollie.Api/Client/OauthBaseMollieClient.cs @@ -8,7 +8,7 @@ public OauthBaseMollieClient(string oauthAccessToken, HttpClient? httpClient = n throw new ArgumentNullException(nameof(oauthAccessToken), "Mollie API key cannot be empty"); } - this.ValidateApiKeyIsOauthAccesstoken(true); + ValidateApiKeyIsOauthAccesstoken(true); } } -} \ No newline at end of file +} diff --git a/src/Mollie.Api/Client/OnboardingClient.cs b/src/Mollie.Api/Client/OnboardingClient.cs index 01b9f782..701fb39d 100644 --- a/src/Mollie.Api/Client/OnboardingClient.cs +++ b/src/Mollie.Api/Client/OnboardingClient.cs @@ -10,11 +10,11 @@ public OnboardingClient(string apiKey, HttpClient? httpClient = null) : base(api } public async Task GetOnboardingStatusAsync() { - return await this.GetAsync("onboarding/me").ConfigureAwait(false); + return await GetAsync("onboarding/me").ConfigureAwait(false); } public async Task SubmitOnboardingDataAsync(SubmitOnboardingDataRequest request) { - await this.PostAsync("onboarding/me", request).ConfigureAwait(false); + await PostAsync("onboarding/me", request).ConfigureAwait(false); } } } diff --git a/src/Mollie.Api/Client/OrderClient.cs b/src/Mollie.Api/Client/OrderClient.cs index 594f02de..2e95b2b4 100644 --- a/src/Mollie.Api/Client/OrderClient.cs +++ b/src/Mollie.Api/Client/OrderClient.cs @@ -17,66 +17,66 @@ public OrderClient(string apiKey, HttpClient? httpClient = null) : base(apiKey, } public async Task CreateOrderAsync(OrderRequest orderRequest) { - return await this.PostAsync("orders", orderRequest).ConfigureAwait(false); + return await PostAsync("orders", orderRequest).ConfigureAwait(false); } public async Task GetOrderAsync(string orderId, bool embedPayments = false, bool embedRefunds = false, bool embedShipments = false, bool testmode = false) { - this.ValidateRequiredUrlParameter(nameof(orderId), orderId); - var queryParameters = this.BuildQueryParameters(embedPayments, embedRefunds, embedShipments, testmode); - return await this.GetAsync($"orders/{orderId}{queryParameters.ToQueryString()}").ConfigureAwait(false); + ValidateRequiredUrlParameter(nameof(orderId), orderId); + var queryParameters = BuildQueryParameters(embedPayments, embedRefunds, embedShipments, testmode); + return await GetAsync($"orders/{orderId}{queryParameters.ToQueryString()}").ConfigureAwait(false); } public async Task UpdateOrderAsync(string orderId, OrderUpdateRequest orderUpdateRequest) { - this.ValidateRequiredUrlParameter(nameof(orderId), orderId); - return await this.PatchAsync($"orders/{orderId}", orderUpdateRequest).ConfigureAwait(false); + ValidateRequiredUrlParameter(nameof(orderId), orderId); + return await PatchAsync($"orders/{orderId}", orderUpdateRequest).ConfigureAwait(false); } public async Task UpdateOrderLinesAsync(string orderId, string orderLineId, OrderLineUpdateRequest orderLineUpdateRequest) { - this.ValidateRequiredUrlParameter(nameof(orderId), orderId); - this.ValidateRequiredUrlParameter(nameof(orderLineId), orderLineId); - return await this.PatchAsync($"orders/{orderId}/lines/{orderLineId}", orderLineUpdateRequest).ConfigureAwait(false); + ValidateRequiredUrlParameter(nameof(orderId), orderId); + ValidateRequiredUrlParameter(nameof(orderLineId), orderLineId); + return await PatchAsync($"orders/{orderId}/lines/{orderLineId}", orderLineUpdateRequest).ConfigureAwait(false); } public async Task ManageOrderLinesAsync(string orderId, ManageOrderLinesRequest manageOrderLinesRequest) { - this.ValidateRequiredUrlParameter(nameof(orderId), orderId); - return await this.PatchAsync($"orders/{orderId}/lines", manageOrderLinesRequest).ConfigureAwait(false); + ValidateRequiredUrlParameter(nameof(orderId), orderId); + return await PatchAsync($"orders/{orderId}/lines", manageOrderLinesRequest).ConfigureAwait(false); } public async Task CancelOrderAsync(string orderId, bool testmode = false) { - this.ValidateRequiredUrlParameter(nameof(orderId), orderId); + ValidateRequiredUrlParameter(nameof(orderId), orderId); var data = TestmodeModel.Create(testmode); - await this.DeleteAsync($"orders/{orderId}", data).ConfigureAwait(false); + await DeleteAsync($"orders/{orderId}", data).ConfigureAwait(false); } public async Task> GetOrderListAsync( string? from = null, int? limit = null, string? profileId = null, bool testmode = false, SortDirection? sort = null) { var queryParameters = BuildQueryParameters(profileId, testmode, sort); - return await this.GetListAsync>($"orders", from, limit, queryParameters).ConfigureAwait(false); + return await GetListAsync>($"orders", from, limit, queryParameters).ConfigureAwait(false); } public async Task> GetOrderListAsync(UrlObjectLink> url) { - return await this.GetAsync(url).ConfigureAwait(false); + return await GetAsync(url).ConfigureAwait(false); } public async Task CancelOrderLinesAsync(string orderId, OrderLineCancellationRequest cancelationRequest) { - this.ValidateRequiredUrlParameter(nameof(orderId), orderId); - await this.DeleteAsync($"orders/{orderId}/lines", cancelationRequest).ConfigureAwait(false); + ValidateRequiredUrlParameter(nameof(orderId), orderId); + await DeleteAsync($"orders/{orderId}/lines", cancelationRequest).ConfigureAwait(false); } public async Task CreateOrderPaymentAsync(string orderId, OrderPaymentRequest createOrderPaymentRequest) { - this.ValidateRequiredUrlParameter(nameof(orderId), orderId); - return await this.PostAsync($"orders/{orderId}/payments", createOrderPaymentRequest).ConfigureAwait(false); + ValidateRequiredUrlParameter(nameof(orderId), orderId); + return await PostAsync($"orders/{orderId}/payments", createOrderPaymentRequest).ConfigureAwait(false); } public async Task CreateOrderRefundAsync(string orderId, OrderRefundRequest createOrderRefundRequest) { - this.ValidateRequiredUrlParameter(nameof(orderId), orderId); - return await this.PostAsync($"orders/{orderId}/refunds", createOrderRefundRequest); + ValidateRequiredUrlParameter(nameof(orderId), orderId); + return await PostAsync($"orders/{orderId}/refunds", createOrderRefundRequest); } public async Task> GetOrderRefundListAsync(string orderId, string? from = null, int? limit = null, bool testmode = false) { - this.ValidateRequiredUrlParameter(nameof(orderId), orderId); + ValidateRequiredUrlParameter(nameof(orderId), orderId); var queryParameters = BuildQueryParameters(null, testmode); - return await this.GetListAsync>($"orders/{orderId}/refunds", from, limit, queryParameters).ConfigureAwait(false); + return await GetListAsync>($"orders/{orderId}/refunds", from, limit, queryParameters).ConfigureAwait(false); } private Dictionary BuildQueryParameters(string? profileId = null, bool testmode = false, SortDirection? sort = null) { @@ -86,10 +86,10 @@ private Dictionary BuildQueryParameters(string? profileId = null result.AddValueIfNotNullOrEmpty(nameof(sort), sort?.ToString()?.ToLowerInvariant()); return result; } - + private Dictionary BuildQueryParameters(bool embedPayments = false, bool embedRefunds = false, bool embedShipments = false, bool testmode = false) { var result = new Dictionary(); - result.AddValueIfNotNullOrEmpty("embed", this.BuildEmbedParameter(embedPayments, embedRefunds, embedShipments)); + result.AddValueIfNotNullOrEmpty("embed", BuildEmbedParameter(embedPayments, embedRefunds, embedShipments)); result.AddValueIfTrue("testmode", testmode); return result; } @@ -102,4 +102,4 @@ private string BuildEmbedParameter(bool embedPayments = false, bool embedRefunds return includeList.ToIncludeParameter(); } } -} \ No newline at end of file +} diff --git a/src/Mollie.Api/Client/OrganizationsClient.cs b/src/Mollie.Api/Client/OrganizationsClient.cs index c638dbcc..8e523d7b 100644 --- a/src/Mollie.Api/Client/OrganizationsClient.cs +++ b/src/Mollie.Api/Client/OrganizationsClient.cs @@ -11,24 +11,24 @@ public OrganizationsClient(string oauthAccessToken, HttpClient? httpClient = nul } public async Task GetCurrentOrganizationAsync() { - return await this.GetAsync($"organizations/me").ConfigureAwait(false); + return await GetAsync($"organizations/me").ConfigureAwait(false); } public async Task GetOrganizationAsync(string organizationId) { - this.ValidateRequiredUrlParameter(nameof(organizationId), organizationId); - return await this.GetAsync($"organizations/{organizationId}").ConfigureAwait(false); + ValidateRequiredUrlParameter(nameof(organizationId), organizationId); + return await GetAsync($"organizations/{organizationId}").ConfigureAwait(false); } public async Task GetOrganizationAsync(UrlObjectLink url) { - return await this.GetAsync(url).ConfigureAwait(false); + return await GetAsync(url).ConfigureAwait(false); } public async Task> GetOrganizationsListAsync(string? from = null, int? limit = null) { - return await this.GetListAsync>("organizations", from, limit, null).ConfigureAwait(false); + return await GetListAsync>("organizations", from, limit, null).ConfigureAwait(false); } - + public async Task> GetOrganizationsListAsync(UrlObjectLink> url) { - return await this.GetAsync(url).ConfigureAwait(false); + return await GetAsync(url).ConfigureAwait(false); } } -} \ No newline at end of file +} diff --git a/src/Mollie.Api/Client/PaymentClient.cs b/src/Mollie.Api/Client/PaymentClient.cs index d2b746a3..b0bd6703 100644 --- a/src/Mollie.Api/Client/PaymentClient.cs +++ b/src/Mollie.Api/Client/PaymentClient.cs @@ -16,69 +16,69 @@ public PaymentClient(string apiKey, HttpClient? httpClient = null) : base(apiKey public async Task CreatePaymentAsync(PaymentRequest paymentRequest, bool includeQrCode = false) { if (!string.IsNullOrWhiteSpace(paymentRequest.ProfileId) || paymentRequest.Testmode.HasValue || paymentRequest.ApplicationFee != null) { - this.ValidateApiKeyIsOauthAccesstoken(); + ValidateApiKeyIsOauthAccesstoken(); } - var queryParameters = this.BuildQueryParameters( + var queryParameters = BuildQueryParameters( includeQrCode: includeQrCode); - return await this.PostAsync($"payments{queryParameters.ToQueryString()}", paymentRequest).ConfigureAwait(false); + return await PostAsync($"payments{queryParameters.ToQueryString()}", paymentRequest).ConfigureAwait(false); } public async Task GetPaymentAsync( - string paymentId, - bool testmode = false, - bool includeQrCode = false, - bool includeRemainderDetails = false, - bool embedRefunds = false, + string paymentId, + bool testmode = false, + bool includeQrCode = false, + bool includeRemainderDetails = false, + bool embedRefunds = false, bool embedChargebacks = false) { - + if (testmode) { - this.ValidateApiKeyIsOauthAccesstoken(); + ValidateApiKeyIsOauthAccesstoken(); } - this.ValidateRequiredUrlParameter(nameof(paymentId), paymentId); + ValidateRequiredUrlParameter(nameof(paymentId), paymentId); - var queryParameters = this.BuildQueryParameters( + var queryParameters = BuildQueryParameters( testmode: testmode, includeQrCode: includeQrCode, includeRemainderDetails: includeRemainderDetails, embedRefunds: embedRefunds, embedChargebacks: embedChargebacks ); - return await this.GetAsync($"payments/{paymentId}{queryParameters.ToQueryString()}").ConfigureAwait(false); + return await GetAsync($"payments/{paymentId}{queryParameters.ToQueryString()}").ConfigureAwait(false); } public async Task DeletePaymentAsync(string paymentId, bool testmode = false) { - this.ValidateRequiredUrlParameter(nameof(paymentId), paymentId); - + ValidateRequiredUrlParameter(nameof(paymentId), paymentId); + var data = TestmodeModel.Create(testmode); - await this.DeleteAsync($"payments/{paymentId}", data).ConfigureAwait(false); + await DeleteAsync($"payments/{paymentId}", data).ConfigureAwait(false); } public async Task GetPaymentAsync(UrlObjectLink url) { - return await this.GetAsync(url).ConfigureAwait(false); + return await GetAsync(url).ConfigureAwait(false); } public async Task> GetPaymentListAsync(UrlObjectLink> url) { - return await this.GetAsync(url).ConfigureAwait(false); + return await GetAsync(url).ConfigureAwait(false); } public async Task> GetPaymentListAsync( - string? from = null, + string? from = null, int? limit = null, - string? profileId = null, - bool testmode = false, - bool includeQrCode = false, - bool embedRefunds = false, + string? profileId = null, + bool testmode = false, + bool includeQrCode = false, + bool embedRefunds = false, bool embedChargebacks = false, SortDirection? sort = null) { - + if (!string.IsNullOrWhiteSpace(profileId) || testmode) { - this.ValidateApiKeyIsOauthAccesstoken(); + ValidateApiKeyIsOauthAccesstoken(); } - var queryParameters = this.BuildQueryParameters( + var queryParameters = BuildQueryParameters( profileId: profileId, testmode: testmode, includeQrCode: includeQrCode, @@ -86,29 +86,29 @@ public async Task> GetPaymentListAsync( embedChargebacks: embedChargebacks, sort: sort); - return await this.GetListAsync>($"payments", from, limit, queryParameters).ConfigureAwait(false); + return await GetListAsync>($"payments", from, limit, queryParameters).ConfigureAwait(false); } public async Task UpdatePaymentAsync(string paymentId, PaymentUpdateRequest paymentUpdateRequest) { - this.ValidateRequiredUrlParameter(nameof(paymentId), paymentId); - - return await this.PatchAsync($"payments/{paymentId}", paymentUpdateRequest).ConfigureAwait(false); + ValidateRequiredUrlParameter(nameof(paymentId), paymentId); + + return await PatchAsync($"payments/{paymentId}", paymentUpdateRequest).ConfigureAwait(false); } private Dictionary BuildQueryParameters( - string? profileId = null, - bool testmode = false, - bool includeQrCode = false, - bool includeRemainderDetails = false, - bool embedRefunds = false, + string? profileId = null, + bool testmode = false, + bool includeQrCode = false, + bool includeRemainderDetails = false, + bool embedRefunds = false, bool embedChargebacks = false, SortDirection? sort = null) { - + var result = new Dictionary(); result.AddValueIfTrue(nameof(testmode), testmode); result.AddValueIfNotNullOrEmpty(nameof(profileId), profileId); - result.AddValueIfNotNullOrEmpty("include", this.BuildIncludeParameter(includeQrCode, includeRemainderDetails)); - result.AddValueIfNotNullOrEmpty("embed", this.BuildEmbedParameter(embedRefunds, embedChargebacks)); + result.AddValueIfNotNullOrEmpty("include", BuildIncludeParameter(includeQrCode, includeRemainderDetails)); + result.AddValueIfNotNullOrEmpty("embed", BuildEmbedParameter(embedRefunds, embedChargebacks)); result.AddValueIfNotNullOrEmpty(nameof(sort), sort?.ToString()?.ToLowerInvariant()); return result; } @@ -128,4 +128,4 @@ private string BuildEmbedParameter(bool embedRefunds = false, bool embedChargeba return embedList.ToIncludeParameter(); } } -} \ No newline at end of file +} diff --git a/src/Mollie.Api/Client/PaymentLinkClient.cs b/src/Mollie.Api/Client/PaymentLinkClient.cs index 118f11e5..db0d8bcf 100644 --- a/src/Mollie.Api/Client/PaymentLinkClient.cs +++ b/src/Mollie.Api/Client/PaymentLinkClient.cs @@ -18,48 +18,48 @@ public async Task CreatePaymentLinkAsync(PaymentLinkRequest { if (!string.IsNullOrWhiteSpace(paymentLinkRequest.ProfileId) || paymentLinkRequest.Testmode.HasValue) { - this.ValidateApiKeyIsOauthAccesstoken(); + ValidateApiKeyIsOauthAccesstoken(); } - return await this.PostAsync($"payment-links", paymentLinkRequest).ConfigureAwait(false); + return await PostAsync($"payment-links", paymentLinkRequest).ConfigureAwait(false); } public async Task GetPaymentLinkAsync(string paymentLinkId, bool testmode = false) { - this.ValidateRequiredUrlParameter(nameof(paymentLinkId), paymentLinkId); + ValidateRequiredUrlParameter(nameof(paymentLinkId), paymentLinkId); if (testmode) { - this.ValidateApiKeyIsOauthAccesstoken(); + ValidateApiKeyIsOauthAccesstoken(); } - var queryParameters = this.BuildQueryParameters( + var queryParameters = BuildQueryParameters( testmode: testmode); - return await this.GetAsync($"payment-links/{paymentLinkId}{queryParameters.ToQueryString()}").ConfigureAwait(false); + return await GetAsync($"payment-links/{paymentLinkId}{queryParameters.ToQueryString()}").ConfigureAwait(false); } - + public async Task GetPaymentLinkAsync(UrlObjectLink url) { - return await this.GetAsync(url).ConfigureAwait(false); + return await GetAsync(url).ConfigureAwait(false); } - - + + public async Task> GetPaymentLinkListAsync(UrlObjectLink> url) { - return await this.GetAsync(url).ConfigureAwait(false); + return await GetAsync(url).ConfigureAwait(false); } - + public async Task> GetPaymentLinkListAsync(string? from = null, int? limit = null, string? profileId = null, bool testmode = false) { if (!string.IsNullOrWhiteSpace(profileId) || testmode) { - this.ValidateApiKeyIsOauthAccesstoken(); + ValidateApiKeyIsOauthAccesstoken(); } - var queryParameters = this.BuildQueryParameters( + var queryParameters = BuildQueryParameters( profileId: profileId, testmode: testmode); - return await this.GetListAsync>("payment-links", from, limit, queryParameters).ConfigureAwait(false); + return await GetListAsync>("payment-links", from, limit, queryParameters).ConfigureAwait(false); } private Dictionary BuildQueryParameters(string? profileId = null, bool testmode = false) @@ -70,4 +70,4 @@ private Dictionary BuildQueryParameters(string? profileId = null return result; } } -} \ No newline at end of file +} diff --git a/src/Mollie.Api/Client/PaymentMethodClient.cs b/src/Mollie.Api/Client/PaymentMethodClient.cs index 505f5fb2..da73bfab 100644 --- a/src/Mollie.Api/Client/PaymentMethodClient.cs +++ b/src/Mollie.Api/Client/PaymentMethodClient.cs @@ -17,57 +17,57 @@ public PaymentMethodClient(string apiKey, HttpClient? httpClient = null) : base( } public async Task GetPaymentMethodAsync( - string paymentMethod, - bool includeIssuers = false, - string? locale = null, - bool includePricing = false, - string? profileId = null, - bool testmode = false, + string paymentMethod, + bool includeIssuers = false, + string? locale = null, + bool includePricing = false, + string? profileId = null, + bool testmode = false, string? currency = null) { - - this.ValidateRequiredUrlParameter(nameof(paymentMethod), paymentMethod); - - Dictionary queryParameters = this.BuildQueryParameters( - locale: locale, - currency: currency, - profileId: profileId, - testmode: testmode, - includeIssuers: includeIssuers, + + ValidateRequiredUrlParameter(nameof(paymentMethod), paymentMethod); + + Dictionary queryParameters = BuildQueryParameters( + locale: locale, + currency: currency, + profileId: profileId, + testmode: testmode, + includeIssuers: includeIssuers, includePricing: includePricing); - return await this.GetAsync($"methods/{paymentMethod.ToLower()}{queryParameters.ToQueryString()}").ConfigureAwait(false); + return await GetAsync($"methods/{paymentMethod.ToLower()}{queryParameters.ToQueryString()}").ConfigureAwait(false); } public async Task> GetAllPaymentMethodListAsync( - string? locale = null, - Amount? amount = null, - bool includeIssuers = false, - bool includePricing = false, + string? locale = null, + Amount? amount = null, + bool includeIssuers = false, + bool includePricing = false, string? profileId = null) { - - Dictionary queryParameters = this.BuildQueryParameters( + + Dictionary queryParameters = BuildQueryParameters( locale: locale, amount: amount, includeIssuers: includeIssuers, includePricing: includePricing, profileId: profileId); - return await this.GetListAsync>("methods/all", null, null, queryParameters).ConfigureAwait(false); + return await GetListAsync>("methods/all", null, null, queryParameters).ConfigureAwait(false); } public async Task> GetPaymentMethodListAsync( string? sequenceType = null, - string? locale = null, - Amount? amount = null, - bool includeIssuers = false, - bool includePricing = false, - string? profileId = null, - bool testmode = false, - Resource? resource = null, + string? locale = null, + Amount? amount = null, + bool includeIssuers = false, + bool includePricing = false, + string? profileId = null, + bool testmode = false, + Resource? resource = null, string? billingCountry = null, string? includeWallets = null) { - - Dictionary queryParameters = this.BuildQueryParameters( + + Dictionary queryParameters = BuildQueryParameters( sequenceType: sequenceType, locale: locale, amount: amount, @@ -79,26 +79,26 @@ public async Task> GetPaymentMethodListAsync billingCountry: billingCountry, includeWallets: includeWallets); - return await this.GetListAsync>("methods", null, null, queryParameters).ConfigureAwait(false); + return await GetListAsync>("methods", null, null, queryParameters).ConfigureAwait(false); } public async Task GetPaymentMethodAsync(UrlObjectLink url) { - return await this.GetAsync(url).ConfigureAwait(false); + return await GetAsync(url).ConfigureAwait(false); } private Dictionary BuildQueryParameters( - string? sequenceType = null, - string? locale = null, - Amount? amount = null, - bool includeIssuers = false, - bool includePricing = false, - string? profileId = null, - bool testmode = false, - Resource? resource = null, - string? currency = null, + string? sequenceType = null, + string? locale = null, + Amount? amount = null, + bool includeIssuers = false, + bool includePricing = false, + string? profileId = null, + bool testmode = false, + Resource? resource = null, + string? currency = null, string? billingCountry = null, string? includeWallets = null) { - + var result = new Dictionary(); result.AddValueIfTrue(nameof(testmode), testmode); result.AddValueIfNotNullOrEmpty(nameof(sequenceType), sequenceType?.ToLower()); @@ -106,7 +106,7 @@ private Dictionary BuildQueryParameters( result.AddValueIfNotNullOrEmpty(nameof(locale), locale); result.AddValueIfNotNullOrEmpty("amount[currency]", amount?.Currency); result.AddValueIfNotNullOrEmpty("amount[value]", amount?.Value); - result.AddValueIfNotNullOrEmpty("include", this.BuildIncludeParameter(includeIssuers, includePricing)); + result.AddValueIfNotNullOrEmpty("include", BuildIncludeParameter(includeIssuers, includePricing)); result.AddValueIfNotNullOrEmpty(nameof(resource), resource?.ToString()?.ToLower()); result.AddValueIfNotNullOrEmpty(nameof(currency), currency); result.AddValueIfNotNullOrEmpty(nameof(billingCountry), billingCountry); @@ -121,4 +121,4 @@ private string BuildIncludeParameter(bool includeIssuers = false, bool includePr return includeList.ToIncludeParameter(); } } -} \ No newline at end of file +} diff --git a/src/Mollie.Api/Client/PermissionsClient.cs b/src/Mollie.Api/Client/PermissionsClient.cs index 6393b62e..fe6a6e83 100644 --- a/src/Mollie.Api/Client/PermissionsClient.cs +++ b/src/Mollie.Api/Client/PermissionsClient.cs @@ -12,16 +12,16 @@ public PermissionsClient(string oauthAccessToken, HttpClient? httpClient = null) } public async Task GetPermissionAsync(string permissionId) { - this.ValidateRequiredUrlParameter(nameof(permissionId), permissionId); - return await this.GetAsync($"permissions/{permissionId}").ConfigureAwait(false); + ValidateRequiredUrlParameter(nameof(permissionId), permissionId); + return await GetAsync($"permissions/{permissionId}").ConfigureAwait(false); } public async Task GetPermissionAsync(UrlObjectLink url) { - return await this.GetAsync(url).ConfigureAwait(false); + return await GetAsync(url).ConfigureAwait(false); } public async Task> GetPermissionListAsync() { - return await this.GetListAsync>("permissions", null, null).ConfigureAwait(false); + return await GetListAsync>("permissions", null, null).ConfigureAwait(false); } } -} \ No newline at end of file +} diff --git a/src/Mollie.Api/Client/ProfileClient.cs b/src/Mollie.Api/Client/ProfileClient.cs index aa40b84c..3a17eb2b 100644 --- a/src/Mollie.Api/Client/ProfileClient.cs +++ b/src/Mollie.Api/Client/ProfileClient.cs @@ -13,82 +13,82 @@ public ProfileClient(string apiKey, HttpClient? httpClient = null) : base(apiKey } public async Task CreateProfileAsync(ProfileRequest request) { - return await this.PostAsync("profiles", request).ConfigureAwait(false); + return await PostAsync("profiles", request).ConfigureAwait(false); } public async Task GetProfileAsync(string profileId) { - this.ValidateRequiredUrlParameter(nameof(profileId), profileId); - return await this.GetAsync($"profiles/{profileId}").ConfigureAwait(false); + ValidateRequiredUrlParameter(nameof(profileId), profileId); + return await GetAsync($"profiles/{profileId}").ConfigureAwait(false); } - + public async Task GetProfileAsync(UrlObjectLink url) { - return await this.GetAsync(url).ConfigureAwait(false); + return await GetAsync(url).ConfigureAwait(false); } public async Task GetCurrentProfileAsync() { - return await this.GetAsync("profiles/me").ConfigureAwait(false); + return await GetAsync("profiles/me").ConfigureAwait(false); } public async Task> GetProfileListAsync(string? from = null, int? limit = null) { - return await this.GetListAsync>("profiles", from, limit).ConfigureAwait(false); + return await GetListAsync>("profiles", from, limit).ConfigureAwait(false); } - + public async Task> GetProfileListAsync(UrlObjectLink> url) { - return await this.GetAsync(url).ConfigureAwait(false); + return await GetAsync(url).ConfigureAwait(false); } public async Task UpdateProfileAsync(string profileId, ProfileRequest request) { - this.ValidateRequiredUrlParameter(nameof(profileId), profileId); - return await this.PatchAsync($"profiles/{profileId}", request).ConfigureAwait(false); + ValidateRequiredUrlParameter(nameof(profileId), profileId); + return await PatchAsync($"profiles/{profileId}", request).ConfigureAwait(false); } public async Task EnablePaymentMethodAsync(string profileId, string paymentMethod) { - this.ValidateRequiredUrlParameter(nameof(profileId), profileId); - this.ValidateRequiredUrlParameter(nameof(paymentMethod), paymentMethod); - return await this.PostAsync($"profiles/{profileId}/methods/{paymentMethod}", null).ConfigureAwait(false); + ValidateRequiredUrlParameter(nameof(profileId), profileId); + ValidateRequiredUrlParameter(nameof(paymentMethod), paymentMethod); + return await PostAsync($"profiles/{profileId}/methods/{paymentMethod}", null).ConfigureAwait(false); } public async Task EnablePaymentMethodAsync(string paymentMethod) { - this.ValidateRequiredUrlParameter(nameof(paymentMethod), paymentMethod); - return await this.PostAsync($"profiles/me/methods/{paymentMethod}", null).ConfigureAwait(false); + ValidateRequiredUrlParameter(nameof(paymentMethod), paymentMethod); + return await PostAsync($"profiles/me/methods/{paymentMethod}", null).ConfigureAwait(false); } public async Task DisablePaymentMethodAsync(string profileId, string paymentMethod) { - this.ValidateRequiredUrlParameter(nameof(profileId), profileId); - this.ValidateRequiredUrlParameter(nameof(paymentMethod), paymentMethod); - await this.DeleteAsync($"profiles/{profileId}/methods/{paymentMethod}").ConfigureAwait(false); + ValidateRequiredUrlParameter(nameof(profileId), profileId); + ValidateRequiredUrlParameter(nameof(paymentMethod), paymentMethod); + await DeleteAsync($"profiles/{profileId}/methods/{paymentMethod}").ConfigureAwait(false); } public async Task DisablePaymentMethodAsync(string paymentMethod) { - this.ValidateRequiredUrlParameter(nameof(paymentMethod), paymentMethod); - await this.DeleteAsync($"profiles/me/methods/{paymentMethod}").ConfigureAwait(false); + ValidateRequiredUrlParameter(nameof(paymentMethod), paymentMethod); + await DeleteAsync($"profiles/me/methods/{paymentMethod}").ConfigureAwait(false); } public async Task DeleteProfileAsync(string profileId) { - this.ValidateRequiredUrlParameter(nameof(profileId), profileId); - await this.DeleteAsync($"profiles/{profileId}").ConfigureAwait(false); + ValidateRequiredUrlParameter(nameof(profileId), profileId); + await DeleteAsync($"profiles/{profileId}").ConfigureAwait(false); } public async Task EnableGiftCardIssuerAsync(string profileId, string issuer) { - this.ValidateRequiredUrlParameter(nameof(profileId), profileId); - this.ValidateRequiredUrlParameter(nameof(issuer), issuer); - return await this.PostAsync($"profiles/{profileId}/methods/giftcard/issuers/{issuer}", null).ConfigureAwait(false); + ValidateRequiredUrlParameter(nameof(profileId), profileId); + ValidateRequiredUrlParameter(nameof(issuer), issuer); + return await PostAsync($"profiles/{profileId}/methods/giftcard/issuers/{issuer}", null).ConfigureAwait(false); } public async Task EnableGiftCardIssuerAsync(string issuer) { - this.ValidateRequiredUrlParameter(nameof(issuer), issuer); - return await this.PostAsync($"profiles/me/methods/giftcard/issuers/{issuer}", null).ConfigureAwait(false); + ValidateRequiredUrlParameter(nameof(issuer), issuer); + return await PostAsync($"profiles/me/methods/giftcard/issuers/{issuer}", null).ConfigureAwait(false); } public async Task DisableGiftCardIssuerAsync(string profileId, string issuer) { - this.ValidateRequiredUrlParameter(nameof(profileId), profileId); - this.ValidateRequiredUrlParameter(nameof(issuer), issuer); - await this.DeleteAsync($"profiles/{profileId}/methods/giftcard/issuers/{issuer}", null).ConfigureAwait(false); + ValidateRequiredUrlParameter(nameof(profileId), profileId); + ValidateRequiredUrlParameter(nameof(issuer), issuer); + await DeleteAsync($"profiles/{profileId}/methods/giftcard/issuers/{issuer}", null).ConfigureAwait(false); } public async Task DisableGiftCardIssuerAsync(string issuer) { - this.ValidateRequiredUrlParameter(nameof(issuer), issuer); - await this.DeleteAsync($"profiles/me/methods/giftcard/issuers/{issuer}", null).ConfigureAwait(false); + ValidateRequiredUrlParameter(nameof(issuer), issuer); + await DeleteAsync($"profiles/me/methods/giftcard/issuers/{issuer}", null).ConfigureAwait(false); } } -} \ No newline at end of file +} diff --git a/src/Mollie.Api/Client/RefundClient.cs b/src/Mollie.Api/Client/RefundClient.cs index 1acdaf70..a5c2883b 100644 --- a/src/Mollie.Api/Client/RefundClient.cs +++ b/src/Mollie.Api/Client/RefundClient.cs @@ -13,56 +13,56 @@ public RefundClient(string apiKey, HttpClient? httpClient = null) : base(apiKey, } public async Task CreateRefundAsync(string paymentId, RefundRequest refundRequest) { - this.ValidateRequiredUrlParameter(nameof(paymentId), paymentId); - + ValidateRequiredUrlParameter(nameof(paymentId), paymentId); + if (refundRequest.Testmode.HasValue) { - this.ValidateApiKeyIsOauthAccesstoken(); + ValidateApiKeyIsOauthAccesstoken(); } - return await this.PostAsync($"payments/{paymentId}/refunds", refundRequest).ConfigureAwait(false); + return await PostAsync($"payments/{paymentId}/refunds", refundRequest).ConfigureAwait(false); } public async Task> GetRefundListAsync(string? from = null, int? limit = null, bool testmode = false) { - var queryParameters = this.BuildQueryParameters(testmode: testmode); - - return await this.GetListAsync>($"refunds", from, limit, queryParameters).ConfigureAwait(false); + var queryParameters = BuildQueryParameters(testmode: testmode); + + return await GetListAsync>($"refunds", from, limit, queryParameters).ConfigureAwait(false); } - + public async Task> GetRefundListAsync(string paymentId, string? from = null, int? limit = null, bool testmode = false) { - this.ValidateRequiredUrlParameter(nameof(paymentId), paymentId); - var queryParameters = this.BuildQueryParameters(testmode: testmode); + ValidateRequiredUrlParameter(nameof(paymentId), paymentId); + var queryParameters = BuildQueryParameters(testmode: testmode); - return await this.GetListAsync>($"payments/{paymentId}/refunds", from, limit, queryParameters).ConfigureAwait(false); + return await GetListAsync>($"payments/{paymentId}/refunds", from, limit, queryParameters).ConfigureAwait(false); } public async Task> GetRefundListAsync(UrlObjectLink> url) { - return await this.GetAsync(url).ConfigureAwait(false); + return await GetAsync(url).ConfigureAwait(false); } public async Task GetRefundAsync(UrlObjectLink url) { - return await this.GetAsync(url).ConfigureAwait(false); + return await GetAsync(url).ConfigureAwait(false); } public async Task GetRefundAsync(string paymentId, string refundId, bool testmode = false) { - this.ValidateRequiredUrlParameter(nameof(paymentId), paymentId); - this.ValidateRequiredUrlParameter(nameof(refundId), refundId); - var queryParameters = this.BuildQueryParameters(testmode: testmode); - return await this.GetAsync($"payments/{paymentId}/refunds/{refundId}{queryParameters.ToQueryString()}").ConfigureAwait(false); + ValidateRequiredUrlParameter(nameof(paymentId), paymentId); + ValidateRequiredUrlParameter(nameof(refundId), refundId); + var queryParameters = BuildQueryParameters(testmode: testmode); + return await GetAsync($"payments/{paymentId}/refunds/{refundId}{queryParameters.ToQueryString()}").ConfigureAwait(false); } public async Task CancelRefundAsync(string paymentId, string refundId, bool testmode = default) { - this.ValidateRequiredUrlParameter(nameof(paymentId), paymentId); - this.ValidateRequiredUrlParameter(nameof(refundId), refundId); - var queryParameters = this.BuildQueryParameters(testmode: testmode); - await this.DeleteAsync($"payments/{paymentId}/refunds/{refundId}{queryParameters.ToQueryString()}").ConfigureAwait(false); + ValidateRequiredUrlParameter(nameof(paymentId), paymentId); + ValidateRequiredUrlParameter(nameof(refundId), refundId); + var queryParameters = BuildQueryParameters(testmode: testmode); + await DeleteAsync($"payments/{paymentId}/refunds/{refundId}{queryParameters.ToQueryString()}").ConfigureAwait(false); } - + private Dictionary BuildQueryParameters(bool testmode = false) { var result = new Dictionary(); result.AddValueIfTrue(nameof(testmode), testmode); return result; } } -} \ No newline at end of file +} diff --git a/src/Mollie.Api/Client/SettlementsClient.cs b/src/Mollie.Api/Client/SettlementsClient.cs index 38f08d6a..85020638 100644 --- a/src/Mollie.Api/Client/SettlementsClient.cs +++ b/src/Mollie.Api/Client/SettlementsClient.cs @@ -15,71 +15,71 @@ public SettlementsClient(string oauthAccessToken, HttpClient? httpClient = null) } public async Task GetSettlementAsync(string settlementId) { - this.ValidateRequiredUrlParameter(nameof(settlementId), settlementId); - return await this.GetAsync($"settlements/{settlementId}").ConfigureAwait(false); + ValidateRequiredUrlParameter(nameof(settlementId), settlementId); + return await GetAsync($"settlements/{settlementId}").ConfigureAwait(false); } public async Task GetNextSettlement() { - return await this.GetAsync($"settlements/next").ConfigureAwait(false); + return await GetAsync($"settlements/next").ConfigureAwait(false); } public async Task GetOpenSettlement() { - return await this.GetAsync($"settlements/open").ConfigureAwait(false); + return await GetAsync($"settlements/open").ConfigureAwait(false); } public async Task> GetSettlementsListAsync(string? reference = null, string? offset = null, int? count = null) { var queryString = !string.IsNullOrWhiteSpace(reference) ? $"?reference={reference}" : string.Empty; - return await this.GetListAsync>($"settlements{queryString}", offset, count).ConfigureAwait(false); + return await GetListAsync>($"settlements{queryString}", offset, count).ConfigureAwait(false); } public async Task> GetSettlementsListAsync(UrlObjectLink> url) { - return await this.GetAsync(url).ConfigureAwait(false); + return await GetAsync(url).ConfigureAwait(false); } public async Task> GetSettlementPaymentsListAsync(string settlementId, string? offset = null, int? count = null) { - this.ValidateRequiredUrlParameter(nameof(settlementId), settlementId); - return await this.GetListAsync>($"settlements/{settlementId}/payments", offset, count).ConfigureAwait(false); + ValidateRequiredUrlParameter(nameof(settlementId), settlementId); + return await GetListAsync>($"settlements/{settlementId}/payments", offset, count).ConfigureAwait(false); } public async Task> GetSettlementPaymentsListAsync(UrlObjectLink> url) { - return await this.GetAsync(url).ConfigureAwait(false); + return await GetAsync(url).ConfigureAwait(false); } public async Task> GetSettlementRefundsListAsync(string settlementId, string? offset = null, int? count = null) { - this.ValidateRequiredUrlParameter(nameof(settlementId), settlementId); - return await this.GetListAsync>($"settlements/{settlementId}/refunds", offset, count).ConfigureAwait(false); + ValidateRequiredUrlParameter(nameof(settlementId), settlementId); + return await GetListAsync>($"settlements/{settlementId}/refunds", offset, count).ConfigureAwait(false); } public async Task> GetSettlementRefundsListAsync(UrlObjectLink> url) { - return await this.GetAsync(url).ConfigureAwait(false); + return await GetAsync(url).ConfigureAwait(false); } public async Task> GetSettlementChargebacksListAsync(string settlementId, string? offset = null, int? count = null) { - this.ValidateRequiredUrlParameter(nameof(settlementId), settlementId); - return await this.GetListAsync>($"settlements/{settlementId}/chargebacks", offset, count).ConfigureAwait(false); + ValidateRequiredUrlParameter(nameof(settlementId), settlementId); + return await GetListAsync>($"settlements/{settlementId}/chargebacks", offset, count).ConfigureAwait(false); } public async Task> GetSettlementChargebacksListAsync(UrlObjectLink> url) { - return await this.GetAsync(url).ConfigureAwait(false); + return await GetAsync(url).ConfigureAwait(false); } public async Task> GetSettlementCapturesListAsync(string settlementId, string? offset = null, int? count = null) { - this.ValidateRequiredUrlParameter(nameof(settlementId), settlementId); - return await this.GetListAsync>($"settlements/{settlementId}/captures", offset, count).ConfigureAwait(false); + ValidateRequiredUrlParameter(nameof(settlementId), settlementId); + return await GetListAsync>($"settlements/{settlementId}/captures", offset, count).ConfigureAwait(false); } public async Task> GetSettlementCapturesListAsync(UrlObjectLink> url) { - return await this.GetAsync(url).ConfigureAwait(false); + return await GetAsync(url).ConfigureAwait(false); } public async Task GetSettlementAsync(UrlObjectLink url) { - return await this.GetAsync(url).ConfigureAwait(false); + return await GetAsync(url).ConfigureAwait(false); } public async Task> ListSettlementCapturesAsync(string settlementId) diff --git a/src/Mollie.Api/Client/ShipmentClient.cs b/src/Mollie.Api/Client/ShipmentClient.cs index 859f283e..9b71f64e 100644 --- a/src/Mollie.Api/Client/ShipmentClient.cs +++ b/src/Mollie.Api/Client/ShipmentClient.cs @@ -14,44 +14,44 @@ public ShipmentClient(string apiKey, HttpClient? httpClient = null) : base(apiKe } public async Task CreateShipmentAsync(string orderId, ShipmentRequest shipmentRequest) { - this.ValidateRequiredUrlParameter(nameof(orderId), orderId); - return await this.PostAsync($"orders/{orderId}/shipments", shipmentRequest) + ValidateRequiredUrlParameter(nameof(orderId), orderId); + return await PostAsync($"orders/{orderId}/shipments", shipmentRequest) .ConfigureAwait(false); } public async Task GetShipmentAsync(string orderId, string shipmentId, bool testmode = false) { - this.ValidateRequiredUrlParameter(nameof(orderId), orderId); - this.ValidateRequiredUrlParameter(nameof(shipmentId), shipmentId); - var queryParameters = this.BuildQueryParameters(testmode); - return await this.GetAsync($"orders/{orderId}/shipments/{shipmentId}{queryParameters.ToQueryString()}") + ValidateRequiredUrlParameter(nameof(orderId), orderId); + ValidateRequiredUrlParameter(nameof(shipmentId), shipmentId); + var queryParameters = BuildQueryParameters(testmode); + return await GetAsync($"orders/{orderId}/shipments/{shipmentId}{queryParameters.ToQueryString()}") .ConfigureAwait(false); } - + public async Task GetShipmentAsync(UrlObjectLink url) { - return await this.GetAsync(url).ConfigureAwait(false); + return await GetAsync(url).ConfigureAwait(false); } public async Task> GetShipmentsListAsync(string orderId, bool testmode = false) { - this.ValidateRequiredUrlParameter(nameof(orderId), orderId); - var queryParameters = this.BuildQueryParameters(testmode); - return await this.GetAsync>($"orders/{orderId}/shipments{queryParameters.ToQueryString()}") + ValidateRequiredUrlParameter(nameof(orderId), orderId); + var queryParameters = BuildQueryParameters(testmode); + return await GetAsync>($"orders/{orderId}/shipments{queryParameters.ToQueryString()}") .ConfigureAwait(false); } - + public async Task> GetShipmentsListAsync(UrlObjectLink> url) { - return await this.GetAsync(url).ConfigureAwait(false); + return await GetAsync(url).ConfigureAwait(false); } public async Task UpdateShipmentAsync(string orderId, string shipmentId, ShipmentUpdateRequest shipmentUpdateRequest) { - this.ValidateRequiredUrlParameter(nameof(orderId), orderId); - this.ValidateRequiredUrlParameter(nameof(shipmentId), shipmentId); - return await this.PatchAsync($"orders/{orderId}/shipments/{shipmentId}", shipmentUpdateRequest).ConfigureAwait(false); + ValidateRequiredUrlParameter(nameof(orderId), orderId); + ValidateRequiredUrlParameter(nameof(shipmentId), shipmentId); + return await PatchAsync($"orders/{orderId}/shipments/{shipmentId}", shipmentUpdateRequest).ConfigureAwait(false); } - + private Dictionary BuildQueryParameters(bool testmode = false) { var result = new Dictionary(); result.AddValueIfTrue("testmode", testmode); return result; } } -} \ No newline at end of file +} diff --git a/src/Mollie.Api/Client/SubscriptionClient.cs b/src/Mollie.Api/Client/SubscriptionClient.cs index b29c43e7..a0ced421 100644 --- a/src/Mollie.Api/Client/SubscriptionClient.cs +++ b/src/Mollie.Api/Client/SubscriptionClient.cs @@ -15,67 +15,67 @@ public SubscriptionClient(string apiKey, HttpClient? httpClient = null) : base(a } public async Task> GetSubscriptionListAsync(string customerId, string? from = null, int? limit = null, string? profileId = null, bool testmode = false) { - this.ValidateRequiredUrlParameter(nameof(customerId), customerId); + ValidateRequiredUrlParameter(nameof(customerId), customerId); var queryParameters = BuildQueryParameters(profileId, testmode); - return await this.GetListAsync>($"customers/{customerId}/subscriptions", from, limit, queryParameters) + return await GetListAsync>($"customers/{customerId}/subscriptions", from, limit, queryParameters) .ConfigureAwait(false); } public async Task> GetAllSubscriptionList(string? from = null, int? limit = null, string? profileId = null, bool testmode = false) { - var queryParameters = this.BuildQueryParameters(profileId, testmode); - return await this.GetListAsync>($"subscriptions", from, limit, queryParameters) + var queryParameters = BuildQueryParameters(profileId, testmode); + return await GetListAsync>($"subscriptions", from, limit, queryParameters) .ConfigureAwait(false); } public async Task> GetSubscriptionListAsync(UrlObjectLink> url) { - return await this.GetAsync(url).ConfigureAwait(false); + return await GetAsync(url).ConfigureAwait(false); } public async Task GetSubscriptionAsync(UrlObjectLink url) { - return await this.GetAsync(url).ConfigureAwait(false); + return await GetAsync(url).ConfigureAwait(false); } public async Task GetSubscriptionAsync(string customerId, string subscriptionId, bool testmode = false) { - this.ValidateRequiredUrlParameter(nameof(customerId), customerId); - this.ValidateRequiredUrlParameter(nameof(subscriptionId), subscriptionId); - var queryParameters = this.BuildQueryParameters(testmode); - return await this.GetAsync($"customers/{customerId}/subscriptions/{subscriptionId}{queryParameters.ToQueryString()}") + ValidateRequiredUrlParameter(nameof(customerId), customerId); + ValidateRequiredUrlParameter(nameof(subscriptionId), subscriptionId); + var queryParameters = BuildQueryParameters(testmode); + return await GetAsync($"customers/{customerId}/subscriptions/{subscriptionId}{queryParameters.ToQueryString()}") .ConfigureAwait(false); } public async Task CreateSubscriptionAsync(string customerId, SubscriptionRequest request) { - this.ValidateRequiredUrlParameter(nameof(customerId), customerId); - return await this.PostAsync($"customers/{customerId}/subscriptions", request) + ValidateRequiredUrlParameter(nameof(customerId), customerId); + return await PostAsync($"customers/{customerId}/subscriptions", request) .ConfigureAwait(false); } public async Task CancelSubscriptionAsync(string customerId, string subscriptionId, bool testmode = false) { - this.ValidateRequiredUrlParameter(nameof(customerId), customerId); - this.ValidateRequiredUrlParameter(nameof(subscriptionId), subscriptionId); + ValidateRequiredUrlParameter(nameof(customerId), customerId); + ValidateRequiredUrlParameter(nameof(subscriptionId), subscriptionId); var data = TestmodeModel.Create(testmode); - await this.DeleteAsync($"customers/{customerId}/subscriptions/{subscriptionId}", data).ConfigureAwait(false); + await DeleteAsync($"customers/{customerId}/subscriptions/{subscriptionId}", data).ConfigureAwait(false); } public async Task UpdateSubscriptionAsync(string customerId, string subscriptionId, SubscriptionUpdateRequest request) { - this.ValidateRequiredUrlParameter(nameof(customerId), customerId); - this.ValidateRequiredUrlParameter(nameof(subscriptionId), subscriptionId); - return await this.PatchAsync($"customers/{customerId}/subscriptions/{subscriptionId}", request).ConfigureAwait(false); + ValidateRequiredUrlParameter(nameof(customerId), customerId); + ValidateRequiredUrlParameter(nameof(subscriptionId), subscriptionId); + return await PatchAsync($"customers/{customerId}/subscriptions/{subscriptionId}", request).ConfigureAwait(false); } public async Task> GetSubscriptionPaymentListAsync(string customerId, string subscriptionId, string? from = null, int? limit = null, bool testmode = false) { - this.ValidateRequiredUrlParameter(nameof(customerId), customerId); - this.ValidateRequiredUrlParameter(nameof(subscriptionId), subscriptionId); - var queryParameters = this.BuildQueryParameters(testmode); - return await this.GetListAsync>($"customers/{customerId}/subscriptions/{subscriptionId}/payments", from, limit, queryParameters) + ValidateRequiredUrlParameter(nameof(customerId), customerId); + ValidateRequiredUrlParameter(nameof(subscriptionId), subscriptionId); + var queryParameters = BuildQueryParameters(testmode); + return await GetListAsync>($"customers/{customerId}/subscriptions/{subscriptionId}/payments", from, limit, queryParameters) .ConfigureAwait(false); } - + private Dictionary BuildQueryParameters(bool testmode = false) { var result = new Dictionary(); result.AddValueIfTrue("testmode", testmode); return result; } - + private Dictionary BuildQueryParameters(string? profileId, bool testmode) { var result = new Dictionary(); result.AddValueIfNotNullOrEmpty("profileId", profileId); @@ -83,4 +83,4 @@ private Dictionary BuildQueryParameters(string? profileId, bool return result; } } -} \ No newline at end of file +} diff --git a/src/Mollie.Api/Client/TerminalClient.cs b/src/Mollie.Api/Client/TerminalClient.cs index 34ea9997..86f02d27 100644 --- a/src/Mollie.Api/Client/TerminalClient.cs +++ b/src/Mollie.Api/Client/TerminalClient.cs @@ -11,25 +11,25 @@ namespace Mollie.Api.Client { public class TerminalClient : BaseMollieClient, ITerminalClient { public TerminalClient(string apiKey, HttpClient? httpClient = null) : base(apiKey, httpClient) { } - + public async Task GetTerminalAsync(string terminalId) { - this.ValidateRequiredUrlParameter(nameof(terminalId), terminalId); + ValidateRequiredUrlParameter(nameof(terminalId), terminalId); return await GetAsync($"terminals/{terminalId}").ConfigureAwait(false); } - + public async Task GetTerminalAsync(UrlObjectLink url) { return await GetAsync(url).ConfigureAwait(false); } - + public async Task> GetTerminalListAsync(string? from = null, int? limit = null, string? profileId = null, bool testmode = false) { var queryParameters = BuildQueryParameters(profileId, testmode); return await GetListAsync>("terminals", from, limit, queryParameters).ConfigureAwait(false); } - + public async Task> GetTerminalListAsync(UrlObjectLink> url) { return await GetAsync(url).ConfigureAwait(false); } - + private Dictionary BuildQueryParameters(string? profileId, bool testmode) { var result = new Dictionary(); result.AddValueIfNotNullOrEmpty("profileId", profileId); @@ -37,4 +37,4 @@ private Dictionary BuildQueryParameters(string? profileId, bool return result; } } -} \ No newline at end of file +} diff --git a/src/Mollie.Api/Client/WalletClient.cs b/src/Mollie.Api/Client/WalletClient.cs index d922b43c..5f7ff87b 100644 --- a/src/Mollie.Api/Client/WalletClient.cs +++ b/src/Mollie.Api/Client/WalletClient.cs @@ -8,9 +8,9 @@ namespace Mollie.Api.Client { public class WalletClient : BaseMollieClient, IWalletClient { public WalletClient(string apiKey, HttpClient? httpClient = null) : base(apiKey, httpClient) { } - + public async Task RequestApplePayPaymentSessionAsync(ApplePayPaymentSessionRequest request) { - return await this.PostAsync("wallets/applepay/sessions", request).ConfigureAwait(false); + return await PostAsync("wallets/applepay/sessions", request).ConfigureAwait(false); } } -} \ No newline at end of file +} diff --git a/src/Mollie.Api/Framework/JsonConverterService.cs b/src/Mollie.Api/Framework/JsonConverterService.cs index 29e0be21..32074232 100644 --- a/src/Mollie.Api/Framework/JsonConverterService.cs +++ b/src/Mollie.Api/Framework/JsonConverterService.cs @@ -9,7 +9,7 @@ internal class JsonConverterService { private readonly JsonSerializerSettings _defaultJsonDeserializerSettings; public JsonConverterService() { - this._defaultJsonDeserializerSettings = this.CreateDefaultJsonDeserializerSettings(); + _defaultJsonDeserializerSettings = CreateDefaultJsonDeserializerSettings(); } public string Serialize(object objectToSerialize) { @@ -44,4 +44,4 @@ private JsonSerializerSettings CreateDefaultJsonDeserializerSettings() { }; } } -} \ No newline at end of file +} diff --git a/src/Mollie.Api/JsonConverters/BalanceTransactionJsonConverter.cs b/src/Mollie.Api/JsonConverters/BalanceTransactionJsonConverter.cs index d173bbf4..b443cc7a 100644 --- a/src/Mollie.Api/JsonConverters/BalanceTransactionJsonConverter.cs +++ b/src/Mollie.Api/JsonConverters/BalanceTransactionJsonConverter.cs @@ -14,9 +14,9 @@ public BalanceTransactionJsonConverter(BalanceTransactionFactory balanceTransact protected override BalanceTransaction Create(Type objectType, JObject jObject) { string? transactionType = GetTransactionType(jObject); - return this._balanceTransactionFactory.Create(transactionType); + return _balanceTransactionFactory.Create(transactionType); } - + private string? GetTransactionType(JObject jObject) { if (FieldExists("type", jObject)) { string? typeValue = (string?)jObject["type"]; @@ -28,4 +28,4 @@ protected override BalanceTransaction Create(Type objectType, JObject jObject) { return null; } } -} \ No newline at end of file +} diff --git a/src/Mollie.Api/JsonConverters/PaymentResponseConverter.cs b/src/Mollie.Api/JsonConverters/PaymentResponseConverter.cs index 91494a79..74dfd0f5 100644 --- a/src/Mollie.Api/JsonConverters/PaymentResponseConverter.cs +++ b/src/Mollie.Api/JsonConverters/PaymentResponseConverter.cs @@ -8,17 +8,17 @@ internal class PaymentResponseConverter : JsonCreationConverter private readonly PaymentResponseFactory _paymentResponseFactory; public PaymentResponseConverter(PaymentResponseFactory paymentResponseFactory) { - this._paymentResponseFactory = paymentResponseFactory; + _paymentResponseFactory = paymentResponseFactory; } protected override PaymentResponse Create(Type objectType, JObject jObject) { string? paymentMethod = GetPaymentMethod(jObject); - return this._paymentResponseFactory.Create(paymentMethod); + return _paymentResponseFactory.Create(paymentMethod); } private string? GetPaymentMethod(JObject jObject) { - if (this.FieldExists("method", jObject)) { + if (FieldExists("method", jObject)) { string paymentMethodValue = (string) jObject["method"]!; if (!string.IsNullOrEmpty(paymentMethodValue)) { return paymentMethodValue; @@ -28,4 +28,4 @@ protected override PaymentResponse Create(Type objectType, JObject jObject) { return null; } } -} \ No newline at end of file +} diff --git a/src/Mollie.Api/Models/Customer/CustomerRequest.cs b/src/Mollie.Api/Models/Customer/CustomerRequest.cs index a110e0d1..d9f95251 100644 --- a/src/Mollie.Api/Models/Customer/CustomerRequest.cs +++ b/src/Mollie.Api/Models/Customer/CustomerRequest.cs @@ -14,7 +14,7 @@ public record CustomerRequest { public string? Email { get; set; } /// - /// Allows you to preset the language to be used in the payment screens shown to the consumer. When this parameter is not + /// Allows you to preset the language to be used in the payment screens shown to the consumer. When this parameter is not /// provided, the browser language will be used instead in the payment flow (which is usually more accurate). /// public string? Locale { get; set; } @@ -25,14 +25,14 @@ public record CustomerRequest { /// [JsonConverter(typeof(RawJsonConverter))] public string? Metadata { get; set; } - + /// /// Oauth only - Optional – Set this to true to make this customer a test customer. /// public bool? Testmode { get; set; } public void SetMetadata(object metadataObj, JsonSerializerSettings? jsonSerializerSettings = null) { - this.Metadata = JsonConvert.SerializeObject(metadataObj, jsonSerializerSettings); + Metadata = JsonConvert.SerializeObject(metadataObj, jsonSerializerSettings); } } -} \ No newline at end of file +} diff --git a/src/Mollie.Api/Models/Order/Request/ManageOrderLines/ManageOrderLinesUpdateOperation.cs b/src/Mollie.Api/Models/Order/Request/ManageOrderLines/ManageOrderLinesUpdateOperation.cs index c91d2245..f0f9acc7 100644 --- a/src/Mollie.Api/Models/Order/Request/ManageOrderLines/ManageOrderLinesUpdateOperation.cs +++ b/src/Mollie.Api/Models/Order/Request/ManageOrderLines/ManageOrderLinesUpdateOperation.cs @@ -1,9 +1,9 @@ namespace Mollie.Api.Models.Order.Request.ManageOrderLines { public record ManageOrderLinesUpdateOperation : ManageOrderLinesOperation { public required ManageOrderLinesUpdateOperationData Data { get; init; } - + public ManageOrderLinesUpdateOperation() { - this.Operation = OrderLineOperation.Update; + Operation = OrderLineOperation.Update; } } -} \ No newline at end of file +} diff --git a/src/Mollie.Api/Models/Order/Request/OrderLineUpdateRequest.cs b/src/Mollie.Api/Models/Order/Request/OrderLineUpdateRequest.cs index 718a13ae..0e97d11c 100644 --- a/src/Mollie.Api/Models/Order/Request/OrderLineUpdateRequest.cs +++ b/src/Mollie.Api/Models/Order/Request/OrderLineUpdateRequest.cs @@ -17,14 +17,14 @@ public record OrderLineUpdateRequest { /// A link pointing to the product page in your web shop of the product sold. /// public string? ProductUrl { get; set; } - + /// /// The SKU, EAN, ISBN or UPC of the product sold. The maximum character length is 64. /// public string? Sku { get; set; } /// - /// Provide any data you like, for example a string or a JSON object. We will + /// Provide any data you like, for example a string or a JSON object. We will /// save the data alongside the order line. Whenever you fetch the order with our API, /// we'll also include the metadata. You can use up to approximately 1kB. /// @@ -42,36 +42,36 @@ public record OrderLineUpdateRequest { public Amount? UnitPrice { get; set; } /// - /// Any discounts applied to the order line. For example, if you have a two-for-one sale, you should pass the + /// Any discounts applied to the order line. For example, if you have a two-for-one sale, you should pass the /// amount discounted as a positive amount. /// public Amount? DiscountAmount { get; set; } /// - /// The total amount of the line, including VAT and discounts. Adding all totalAmount values together should + /// The total amount of the line, including VAT and discounts. Adding all totalAmount values together should /// result in the same amount as the amount top level property. /// public Amount? TotalAmount { get; set; } /// - /// The amount of value-added tax on the line. The totalAmount field includes VAT, so the vatAmount can be + /// The amount of value-added tax on the line. The totalAmount field includes VAT, so the vatAmount can be /// calculated with the formula totalAmount × (vatRate / (100 + vatRate)). /// public Amount? VatAmount { get; set; } /// - /// The VAT rate applied to the order line, for example "21.00" for 21%. The vatRate should be passed as a + /// The VAT rate applied to the order line, for example "21.00" for 21%. The vatRate should be passed as a /// string and not as a float to ensure the correct number of decimals are passed. /// public string? VatRate { get; set; } - + /// /// Oauth only - Optional /// public bool? Testmode { get; set; } public void SetMetadata(object metadataObj, JsonSerializerSettings? jsonSerializerSettings = null) { - this.Metadata = JsonConvert.SerializeObject(metadataObj, jsonSerializerSettings); + Metadata = JsonConvert.SerializeObject(metadataObj, jsonSerializerSettings); } } } diff --git a/src/Mollie.Api/Models/Order/Request/OrderRequest.cs b/src/Mollie.Api/Models/Order/Request/OrderRequest.cs index f4b5d105..96162b69 100644 --- a/src/Mollie.Api/Models/Order/Request/OrderRequest.cs +++ b/src/Mollie.Api/Models/Order/Request/OrderRequest.cs @@ -20,7 +20,7 @@ public record OrderRequest { /// /// The lines in the order. Each line contains details such as a description of the item ordered, its - /// price et cetera. + /// price et cetera. /// public required IEnumerable Lines { get; init; } @@ -49,33 +49,33 @@ public record OrderRequest { /// /// The URL your consumer will be redirected to when the consumer explicitly cancels the payment. If this URL /// is not provided, the consumer will be redirected to the redirectUrl instead — see above. - /// + /// /// Mollie will always give you status updates via webhooks, including for the canceled status. This parameter /// is therefore entirely optional, but can be useful when implementing a dedicated consumer-facing flow to handle /// payment cancellations. - /// + /// /// The parameter can be omitted for orders with payment.sequenceType set to recurring. /// public string? CancelUrl { get; set; } - + /// /// Set the webhook URL, where we will send order status changes to. /// public string? WebhookUrl { get; set; } /// - /// Allows you to preset the language to be used in the hosted payment pages shown to the consumer. + /// Allows you to preset the language to be used in the hosted payment pages shown to the consumer. /// public required string Locale { get; init; } /// /// Normally, a payment method selection screen is shown. However, when using this parameter, your customer /// will skip the selection screen and will be sent directly to the chosen payment method. The parameter enables - /// you to fully integrate the payment method selection into your website. See the + /// you to fully integrate the payment method selection into your website. See the /// Mollie.Api.Models.Payment.PaymentMethod class for a full list of known values. /// [JsonIgnore] - public string? Method { + public string? Method { get => Methods?.FirstOrDefault(); set { if (value == null) { @@ -90,10 +90,10 @@ public string? Method { /// /// Normally, a payment method screen is shown. However, when using this parameter, you can choose a specific payment method - /// and your customer will skip the selection screen and is sent directly to the chosen payment method. The parameter + /// and your customer will skip the selection screen and is sent directly to the chosen payment method. The parameter /// enables you to fully integrate the payment method selection into your website. - /// You can also specify the methods in an array.By doing so we will still show the payment method selection screen but will - /// only show the methods specified in the array. For example, you can use this functionality to only show payment methods + /// You can also specify the methods in an array.By doing so we will still show the payment method selection screen but will + /// only show the methods specified in the array. For example, you can use this functionality to only show payment methods /// from a specific country to your customer. /// [JsonProperty("method")] @@ -112,13 +112,13 @@ public string? Method { public string? Metadata { get; set; } /// - /// The date the order should expire in YYYY-MM-DD format. The minimum date is tomorrow and the maximum date is 100 days + /// The date the order should expire in YYYY-MM-DD format. The minimum date is tomorrow and the maximum date is 100 days /// after tomorrow. /// public string? ExpiresAt { get; set; } /// - /// For digital goods, you must make sure to apply the VAT rate from your customer’s country in most jurisdictions. Use + /// For digital goods, you must make sure to apply the VAT rate from your customer’s country in most jurisdictions. Use /// this parameter to restrict the payment methods available to your customer to methods from the billing country only. /// public bool? ShopperCountryMustMatchBillingCountry { get; set; } @@ -128,7 +128,7 @@ public string? Method { /// [JsonProperty("payment.applicationFee")] public ApplicationFee? ApplicationFee { get; set; } - + /// /// Oauth only - The payment profile's unique identifier, for example pfl_3RkSN1zuPE. /// @@ -140,7 +140,7 @@ public string? Method { public bool? Testmode { get; set; } public void SetMetadata(object metadataObj, JsonSerializerSettings? jsonSerializerSettings = null) { - this.Metadata = JsonConvert.SerializeObject(metadataObj, jsonSerializerSettings); + Metadata = JsonConvert.SerializeObject(metadataObj, jsonSerializerSettings); } } -} \ No newline at end of file +} diff --git a/src/Mollie.Api/Models/Order/Response/OrderResponse.cs b/src/Mollie.Api/Models/Order/Response/OrderResponse.cs index 2475a565..dd166899 100644 --- a/src/Mollie.Api/Models/Order/Response/OrderResponse.cs +++ b/src/Mollie.Api/Models/Order/Response/OrderResponse.cs @@ -23,7 +23,7 @@ public record OrderResponse { public required string ProfileId { get; init; } /// - /// The payment method last used when paying for the order - See the + /// The payment method last used when paying for the order - See the /// Mollie.Api.Models.Payment.PaymentMethod class for a full list of known values. /// public string? Method { get; set; } @@ -80,13 +80,13 @@ public record OrderResponse { public OrderAddressDetails? ShippingAddress { get; set; } /// - /// The locale used during checkout. + /// The locale used during checkout. /// public required string Locale { get; init; } /// - /// Provide any data you like, for example a string or a JSON object. We will save the data - /// alongside the order. Whenever you fetch the order with our API, we’ll also include the + /// Provide any data you like, for example a string or a JSON object. We will save the data + /// alongside the order. Whenever you fetch the order with our API, we’ll also include the /// metadata. You can use up to approximately 1kB. /// [JsonConverter(typeof(RawJsonConverter))] @@ -96,7 +96,7 @@ public record OrderResponse { /// The URL your customer will be redirected to after completing or canceling the payment process. /// public string? RedirectUrl { get; set; } - + /// /// The optional redirect URL you provided during payment creation. Consumer that explicitly cancel the /// order will be redirected to this URL if provided, or otherwise to the redirectUrl instead — see above. @@ -162,7 +162,7 @@ public record OrderResponse { public required OrderResponseLinks Links { get; init; } public T? GetMetadata(JsonSerializerSettings? jsonSerializerSettings = null) { - return Metadata != null ? JsonConvert.DeserializeObject(this.Metadata, jsonSerializerSettings) : default; + return Metadata != null ? JsonConvert.DeserializeObject(Metadata, jsonSerializerSettings) : default; } } -} \ No newline at end of file +} diff --git a/src/Mollie.Api/Models/Payment/Request/ApplePayPaymentRequest.cs b/src/Mollie.Api/Models/Payment/Request/ApplePayPaymentRequest.cs index 1b73ab6d..3e13dcce 100644 --- a/src/Mollie.Api/Models/Payment/Request/ApplePayPaymentRequest.cs +++ b/src/Mollie.Api/Models/Payment/Request/ApplePayPaymentRequest.cs @@ -2,7 +2,7 @@ public record ApplePayPaymentRequest : PaymentRequest { public ApplePayPaymentRequest() { - this.Method = PaymentMethod.ApplePay; + Method = PaymentMethod.ApplePay; } /// @@ -11,4 +11,4 @@ public ApplePayPaymentRequest() /// public string? ApplePayPaymentToken { get; set; } } -} \ No newline at end of file +} diff --git a/src/Mollie.Api/Models/Payment/Request/BankTransferPaymentRequest.cs b/src/Mollie.Api/Models/Payment/Request/BankTransferPaymentRequest.cs index 47862430..c4c696ed 100644 --- a/src/Mollie.Api/Models/Payment/Request/BankTransferPaymentRequest.cs +++ b/src/Mollie.Api/Models/Payment/Request/BankTransferPaymentRequest.cs @@ -1,7 +1,7 @@ namespace Mollie.Api.Models.Payment.Request { public record BankTransferPaymentRequest : PaymentRequest { public BankTransferPaymentRequest() { - this.Method = PaymentMethod.BankTransfer; + Method = PaymentMethod.BankTransfer; } /// @@ -17,4 +17,4 @@ public BankTransferPaymentRequest() { /// public string? DueDate { get; set; } } -} \ No newline at end of file +} diff --git a/src/Mollie.Api/Models/Payment/Request/CreditCardPaymentRequest.cs b/src/Mollie.Api/Models/Payment/Request/CreditCardPaymentRequest.cs index ea758a65..e0a14b57 100644 --- a/src/Mollie.Api/Models/Payment/Request/CreditCardPaymentRequest.cs +++ b/src/Mollie.Api/Models/Payment/Request/CreditCardPaymentRequest.cs @@ -1,17 +1,17 @@ namespace Mollie.Api.Models.Payment.Request { public record CreditCardPaymentRequest : PaymentRequest { public CreditCardPaymentRequest() { - this.Method = PaymentMethod.CreditCard; + Method = PaymentMethod.CreditCard; } /// - /// The card holder�s address details. We advise to provide these details to improve the credit card + /// The card holder�s address details. We advise to provide these details to improve the credit card /// fraud protection, and thus improve conversion. /// public AddressObject? BillingAddress { get; set; } /// - /// The shipping address details. We advise to provide these details to improve the credit card fraud + /// The shipping address details. We advise to provide these details to improve the credit card fraud /// protection, and thus improve conversion. /// public AddressObject? ShippingAddress { get; set; } @@ -22,4 +22,4 @@ public CreditCardPaymentRequest() { /// public string? CardToken { get; set; } } -} \ No newline at end of file +} diff --git a/src/Mollie.Api/Models/Payment/Request/GiftcardPaymentRequest.cs b/src/Mollie.Api/Models/Payment/Request/GiftcardPaymentRequest.cs index 641f3251..9ac9ce24 100644 --- a/src/Mollie.Api/Models/Payment/Request/GiftcardPaymentRequest.cs +++ b/src/Mollie.Api/Models/Payment/Request/GiftcardPaymentRequest.cs @@ -1,11 +1,11 @@ namespace Mollie.Api.Models.Payment.Request { public record GiftcardPaymentRequest : PaymentRequest { public GiftcardPaymentRequest() { - this.Method = PaymentMethod.GiftCard; + Method = PaymentMethod.GiftCard; } /// - /// The gift card brand to use for the payment. These issuers are not dynamically available through the Issuers API, + /// The gift card brand to use for the payment. These issuers are not dynamically available through the Issuers API, /// but can be retrieved by using the issuers include in the Methods API. If you need a brand not in the list, contact /// our support department. If only one issuer is activated on your account, you can omit this parameter. /// @@ -21,4 +21,4 @@ public GiftcardPaymentRequest() { /// public string? VoucherPin { get; set; } } -} \ No newline at end of file +} diff --git a/src/Mollie.Api/Models/Payment/Request/IDealPaymentRequest.cs b/src/Mollie.Api/Models/Payment/Request/IDealPaymentRequest.cs index 98949aa5..88b10afc 100644 --- a/src/Mollie.Api/Models/Payment/Request/IDealPaymentRequest.cs +++ b/src/Mollie.Api/Models/Payment/Request/IDealPaymentRequest.cs @@ -1,7 +1,7 @@ namespace Mollie.Api.Models.Payment.Request { public record IdealPaymentRequest : PaymentRequest { public IdealPaymentRequest() { - this.Method = PaymentMethod.Ideal; + Method = PaymentMethod.Ideal; } /// @@ -10,4 +10,4 @@ public IdealPaymentRequest() { /// public string? Issuer { get; set; } } -} \ No newline at end of file +} diff --git a/src/Mollie.Api/Models/Payment/Request/KbcPaymentRequest.cs b/src/Mollie.Api/Models/Payment/Request/KbcPaymentRequest.cs index ba78c266..41b44241 100644 --- a/src/Mollie.Api/Models/Payment/Request/KbcPaymentRequest.cs +++ b/src/Mollie.Api/Models/Payment/Request/KbcPaymentRequest.cs @@ -1,14 +1,14 @@ namespace Mollie.Api.Models.Payment.Request { public record KbcPaymentRequest : PaymentRequest { public KbcPaymentRequest() { - this.Method = PaymentMethod.Kbc; + Method = PaymentMethod.Kbc; } /// - /// The issuer to use for the KBC/CBC payment. These issuers are not dynamically available through the Issuers API, - /// but can be retrieved by using the issuers include in the Methods API. See the Mollie.Api.Models.Payment.Request.KbcIssuer + /// The issuer to use for the KBC/CBC payment. These issuers are not dynamically available through the Issuers API, + /// but can be retrieved by using the issuers include in the Methods API. See the Mollie.Api.Models.Payment.Request.KbcIssuer /// class for a full list of known values. /// public string? Issuer { get; set; } } -} \ No newline at end of file +} diff --git a/src/Mollie.Api/Models/Payment/Request/PayPalPaymentRequest.cs b/src/Mollie.Api/Models/Payment/Request/PayPalPaymentRequest.cs index 88744d57..d20e3daf 100644 --- a/src/Mollie.Api/Models/Payment/Request/PayPalPaymentRequest.cs +++ b/src/Mollie.Api/Models/Payment/Request/PayPalPaymentRequest.cs @@ -1,17 +1,17 @@ namespace Mollie.Api.Models.Payment.Request { public record PayPalPaymentRequest : PaymentRequest { public PayPalPaymentRequest() { - this.Method = PaymentMethod.PayPal; + Method = PaymentMethod.PayPal; } /// - /// The shipping address details. We advise to provide these details to improve PayPal�s fraud protection, + /// The shipping address details. We advise to provide these details to improve PayPal�s fraud protection, /// and thus improve conversion. /// public AddressObject? ShippingAddress { get; set; } /// - /// The unique ID you have used for the PayPal fraud library. You should include this if you use PayPal + /// The unique ID you have used for the PayPal fraud library. You should include this if you use PayPal /// for an on-demand payment. The maximum character length is 32. /// Please refer to the Recurring payments guide for more information on how to implement the fraud library. /// @@ -24,4 +24,4 @@ public PayPalPaymentRequest() { /// public bool? DigitalGoods { get; set; } } -} \ No newline at end of file +} diff --git a/src/Mollie.Api/Models/Payment/Request/PaySafeCardPaymentRequest.cs b/src/Mollie.Api/Models/Payment/Request/PaySafeCardPaymentRequest.cs index 5bffd535..949b526f 100644 --- a/src/Mollie.Api/Models/Payment/Request/PaySafeCardPaymentRequest.cs +++ b/src/Mollie.Api/Models/Payment/Request/PaySafeCardPaymentRequest.cs @@ -1,7 +1,7 @@ namespace Mollie.Api.Models.Payment.Request { public record PaySafeCardPaymentRequest : PaymentRequest { public PaySafeCardPaymentRequest() { - this.Method = PaymentMethod.PaySafeCard; + Method = PaymentMethod.PaySafeCard; } /// @@ -9,4 +9,4 @@ public PaySafeCardPaymentRequest() { /// public string? CustomerReference { get; set; } } -} \ No newline at end of file +} diff --git a/src/Mollie.Api/Models/Payment/Request/PaymentRequest.cs b/src/Mollie.Api/Models/Payment/Request/PaymentRequest.cs index 2dccf7e3..6cb0b4d0 100644 --- a/src/Mollie.Api/Models/Payment/Request/PaymentRequest.cs +++ b/src/Mollie.Api/Models/Payment/Request/PaymentRequest.cs @@ -12,9 +12,9 @@ public record PaymentRequest public required Amount Amount { get; init; } /// - /// The description of the payment you’re creating. This will be shown to the consumer on their card or bank statement - /// when possible. We truncate the description automatically according to the limits of the used payment method. The - /// description is also visible in any exports you generate. We recommend you use a unique identifier so that you can + /// The description of the payment you’re creating. This will be shown to the consumer on their card or bank statement + /// when possible. We truncate the description automatically according to the limits of the used payment method. The + /// description is also visible in any exports you generate. We recommend you use a unique identifier so that you can /// always link the payment to the order.This is particularly useful for bookkeeping. /// public required string Description { get; init; } @@ -25,7 +25,7 @@ public record PaymentRequest /// identifier – like your order ID – so you can show the right page referencing the order when the consumer returns. /// public string? RedirectUrl { get; set; } - + /// /// The URL your consumer will be redirected to when the consumer explicitly cancels the payment. If this URL is not /// provided, the consumer will be redirected to the redirectUrl instead — see above. @@ -42,22 +42,22 @@ public record PaymentRequest public string? WebhookUrl { get; set; } /// - /// Allows you to preset the language to be used in the payment screens shown to the consumer. Setting a locale is highly - /// recommended and will greatly improve your conversion rate. When this parameter is omitted, the browser language will + /// Allows you to preset the language to be used in the payment screens shown to the consumer. Setting a locale is highly + /// recommended and will greatly improve your conversion rate. When this parameter is omitted, the browser language will /// be used instead if supported by the payment method. You can provide any ISO 15897 locale, but our payment screen currently - /// only supports the following languages: en_US nl_NL nl_BE fr_FR fr_BE de_DE de_AT de_CH es_ES ca_ES pt_PT it_IT nb_NO + /// only supports the following languages: en_US nl_NL nl_BE fr_FR fr_BE de_DE de_AT de_CH es_ES ca_ES pt_PT it_IT nb_NO /// sv_SE fi_FI da_DK is_IS hu_HU pl_PL lv_LV lt_LT /// public string? Locale { get; set; } /// - /// Normally, a payment method selection screen is shown. However, when using this parameter, your customer will skip the - /// selection screen and will be sent directly to the chosen payment method. The parameter enables you to fully integrate + /// Normally, a payment method selection screen is shown. However, when using this parameter, your customer will skip the + /// selection screen and will be sent directly to the chosen payment method. The parameter enables you to fully integrate /// the payment method selection into your website, however note Mollie’s country based conversion optimization is lost. /// See the Mollie.Api.Models.Payment.PaymentMethod class for a full list of known values. /// [JsonIgnore] - public string? Method { + public string? Method { get => Methods?.FirstOrDefault(); set { if (value == null) { @@ -72,26 +72,26 @@ public string? Method { /// /// Normally, a payment method screen is shown. However, when using this parameter, you can choose a specific payment method - /// and your customer will skip the selection screen and is sent directly to the chosen payment method. The parameter + /// and your customer will skip the selection screen and is sent directly to the chosen payment method. The parameter /// enables you to fully integrate the payment method selection into your website. - /// You can also specify the methods in an array.By doing so we will still show the payment method selection screen but will - /// only show the methods specified in the array. For example, you can use this functionality to only show payment methods + /// You can also specify the methods in an array.By doing so we will still show the payment method selection screen but will + /// only show the methods specified in the array. For example, you can use this functionality to only show payment methods /// from a specific country to your customer. /// [JsonProperty("method")] public IList? Methods { get; set; } /// - /// Provide any data you like, for example a string or a JSON object. We will save the data alongside the payment. Whenever + /// Provide any data you like, for example a string or a JSON object. We will save the data alongside the payment. Whenever /// you fetch the payment with our API, we’ll also include the metadata. You can use up to approximately 1kB. /// [JsonConverter(typeof(RawJsonConverter))] public string? Metadata { get; set; } /// - /// Indicate which type of payment this is in a recurring sequence. If set to first, a first payment is created for the - /// customer, allowing the customer to agree to automatic recurring charges taking place on their account in the future. - /// If set to recurring, the customer’s card is charged automatically. Defaults to oneoff, which is a regular non-recurring + /// Indicate which type of payment this is in a recurring sequence. If set to first, a first payment is created for the + /// customer, allowing the customer to agree to automatic recurring charges taking place on their account in the future. + /// If set to recurring, the customer’s card is charged automatically. Defaults to oneoff, which is a regular non-recurring /// payment(see also: Recurring). See the Mollie.Api.Models.Payment.SequenceType class for a full list of known values. /// public string? SequenceType { get; set; } @@ -102,7 +102,7 @@ public string? Method { public string? CustomerId { get; set; } /// - /// When creating recurring payments, the ID of a specific Mandate may be supplied to indicate which of the consumer’s accounts + /// When creating recurring payments, the ID of a specific Mandate may be supplied to indicate which of the consumer’s accounts /// should be credited. /// public string? MandateId { get; set; } @@ -124,7 +124,7 @@ public string? Method { public string? TerminalId { get; set; } /// - /// Oauth only - Optional – Adding an Application Fee allows you to charge the merchant a small sum for the payment and transfer + /// Oauth only - Optional – Adding an Application Fee allows you to charge the merchant a small sum for the payment and transfer /// this to your own account. /// public ApplicationFee? ApplicationFee { get; set; } @@ -137,13 +137,13 @@ public string? Method { public IList? Routings { get; set; } /// - /// For digital goods in most jurisdictions, you must apply the VAT rate from your customer’s country. Choose the VAT rates - /// you have used for the order to ensure your customer’s country matches the VAT country. Use this parameter to restrict the + /// For digital goods in most jurisdictions, you must apply the VAT rate from your customer’s country. Choose the VAT rates + /// you have used for the order to ensure your customer’s country matches the VAT country. Use this parameter to restrict the /// payment methods available to your customer to those from a single country. If available, the credit card method will still /// be offered, but only cards from the allowed country are accepted. /// public string? RestrictPaymentMethodsToCountry { get; set; } - + /// /// Indicates whether the capture will be scheduled automatically or not. Set to manual to capture the payment manually using the /// Create capture endpoint. Set to automatic by default, which indicates the payment will be captured automatically, without @@ -151,7 +151,7 @@ public string? Method { /// See the Mollie.Api.Models.Capture.CaptureMode class for a full list of known values. /// public string? CaptureMode { get; set; } - + /// /// Interval to wait before the payment is captured, for example 8 hours or 2 days. In order to schedule an automatic capture, /// the captureMode must be set to either automatic or be omitted. @@ -164,7 +164,7 @@ public void SetMetadata(object metadataObj, JsonSerializerSettings? jsonSerializ } public override string ToString() { - return $"Method: {Method} - Amount: {this.Amount}"; + return $"Method: {Method} - Amount: {Amount}"; } } -} \ No newline at end of file +} diff --git a/src/Mollie.Api/Models/Payment/Request/PaymentUpdateRequest.cs b/src/Mollie.Api/Models/Payment/Request/PaymentUpdateRequest.cs index 107afb33..10a1df43 100644 --- a/src/Mollie.Api/Models/Payment/Request/PaymentUpdateRequest.cs +++ b/src/Mollie.Api/Models/Payment/Request/PaymentUpdateRequest.cs @@ -4,9 +4,9 @@ namespace Mollie.Api.Models.Payment.Request { public record PaymentUpdateRequest { /// - /// The description of the payment. This will be shown to your customer on their card or bank statement + /// The description of the payment. This will be shown to your customer on their card or bank statement /// when possible. We truncate the description automatically according to the limits of the used payment - /// method. The description is also visible in any exports you generate. We recommend you use a unique + /// method. The description is also visible in any exports you generate. We recommend you use a unique /// identifier so that you can always link the payment to the order in your back office.This is particularly /// useful for bookkeeping. /// @@ -25,22 +25,22 @@ public record PaymentUpdateRequest { public string? WebhookUrl { get; set; } /// - /// Provide any data you like, for example a string or a JSON object. We will save the data alongside the payment. Whenever + /// Provide any data you like, for example a string or a JSON object. We will save the data alongside the payment. Whenever /// you fetch the payment with our API, we’ll also include the metadata. You can use up to approximately 1kB. /// [JsonConverter(typeof(RawJsonConverter))] public string? Metadata { get; set; } /// - /// For digital goods in most jurisdictions, you must apply the VAT rate from your customer’s country. Choose the VAT rates - /// you have used for the order to ensure your customer’s country matches the VAT country. Use this parameter to restrict the + /// For digital goods in most jurisdictions, you must apply the VAT rate from your customer’s country. Choose the VAT rates + /// you have used for the order to ensure your customer’s country matches the VAT country. Use this parameter to restrict the /// payment methods available to your customer to those from a single country. If available, the credit card method will still /// be offered, but only cards from the allowed country are accepted. /// public string? RestrictPaymentMethodsToCountry { get; set; } public void SetMetadata(object metadataObj, JsonSerializerSettings? jsonSerializerSettings = null) { - this.Metadata = JsonConvert.SerializeObject(metadataObj, jsonSerializerSettings); + Metadata = JsonConvert.SerializeObject(metadataObj, jsonSerializerSettings); } } } diff --git a/src/Mollie.Api/Models/Payment/Request/Przelewy24PaymentRequest.cs b/src/Mollie.Api/Models/Payment/Request/Przelewy24PaymentRequest.cs index 36d91383..95445a08 100644 --- a/src/Mollie.Api/Models/Payment/Request/Przelewy24PaymentRequest.cs +++ b/src/Mollie.Api/Models/Payment/Request/Przelewy24PaymentRequest.cs @@ -4,7 +4,7 @@ public record Przelewy24PaymentRequest : PaymentRequest { public Przelewy24PaymentRequest() { - this.Method = PaymentMethod.Przelewy24; + Method = PaymentMethod.Przelewy24; } /// @@ -12,4 +12,4 @@ public Przelewy24PaymentRequest() /// public string? BillingEmail { get; set; } } -} \ No newline at end of file +} diff --git a/src/Mollie.Api/Models/Payment/Request/SepaDirectDebitRequest.cs b/src/Mollie.Api/Models/Payment/Request/SepaDirectDebitRequest.cs index 9de8425f..0851a753 100644 --- a/src/Mollie.Api/Models/Payment/Request/SepaDirectDebitRequest.cs +++ b/src/Mollie.Api/Models/Payment/Request/SepaDirectDebitRequest.cs @@ -1,7 +1,7 @@ namespace Mollie.Api.Models.Payment.Request { public record SepaDirectDebitRequest : PaymentRequest { public SepaDirectDebitRequest() { - this.Method = PaymentMethod.DirectDebit; + Method = PaymentMethod.DirectDebit; } /// @@ -14,4 +14,4 @@ public SepaDirectDebitRequest() { /// public string? ConsumerAccount { get; set; } } -} \ No newline at end of file +} diff --git a/src/Mollie.Api/Models/PaymentLink/Request/PaymentLinkRequest.cs b/src/Mollie.Api/Models/PaymentLink/Request/PaymentLinkRequest.cs index 972a8379..152ea0ff 100644 --- a/src/Mollie.Api/Models/PaymentLink/Request/PaymentLinkRequest.cs +++ b/src/Mollie.Api/Models/PaymentLink/Request/PaymentLinkRequest.cs @@ -11,7 +11,7 @@ public record PaymentLinkRequest public required Amount Amount { get; init; } /// - /// This description will also be used as the payment description and will be shown to your customer on their card or bank + /// This description will also be used as the payment description and will be shown to your customer on their card or bank /// statement when possible. /// public required string Description { get; init; } @@ -43,7 +43,7 @@ public record PaymentLinkRequest public bool? Testmode { get; set; } public override string ToString() { - return $"Amount: {this.Amount} - Description: {this.Description}"; + return $"Amount: {Amount} - Description: {Description}"; } } -} \ No newline at end of file +} diff --git a/src/Mollie.Api/Models/Shipment/Response/ShipmentResponse.cs b/src/Mollie.Api/Models/Shipment/Response/ShipmentResponse.cs index fcc46253..2b7466be 100644 --- a/src/Mollie.Api/Models/Shipment/Response/ShipmentResponse.cs +++ b/src/Mollie.Api/Models/Shipment/Response/ShipmentResponse.cs @@ -52,7 +52,7 @@ public record ShipmentResponse public required ShipmentResponseLinks Links { get; init; } public T? GetMetadata(JsonSerializerSettings? jsonSerializerSettings = null) { - return Metadata != null ? JsonConvert.DeserializeObject(this.Metadata, jsonSerializerSettings) : default; + return Metadata != null ? JsonConvert.DeserializeObject(Metadata, jsonSerializerSettings) : default; } } } diff --git a/src/Mollie.Api/Models/Subscription/SubscriptionUpdateRequest.cs b/src/Mollie.Api/Models/Subscription/SubscriptionUpdateRequest.cs index 4e2ff392..fd7362bb 100644 --- a/src/Mollie.Api/Models/Subscription/SubscriptionUpdateRequest.cs +++ b/src/Mollie.Api/Models/Subscription/SubscriptionUpdateRequest.cs @@ -49,14 +49,14 @@ public record SubscriptionUpdateRequest { /// The mandate used for this subscription. Please note that this parameter can not set together with method. /// public string? MandateId { get; set; } - + /// /// Oauth only - Optional – Set this to true to make this subscription a test subscription. /// public bool? Testmode { get; set; } public void SetMetadata(object metadataObj, JsonSerializerSettings? jsonSerializerSettings = null) { - this.Metadata = JsonConvert.SerializeObject(metadataObj, jsonSerializerSettings); + Metadata = JsonConvert.SerializeObject(metadataObj, jsonSerializerSettings); } } -} \ No newline at end of file +} diff --git a/tests/Mollie.Tests.Integration/Api/ApiExceptionTests.cs b/tests/Mollie.Tests.Integration/Api/ApiExceptionTests.cs index a0dc4d70..bbd3d586 100644 --- a/tests/Mollie.Tests.Integration/Api/ApiExceptionTests.cs +++ b/tests/Mollie.Tests.Integration/Api/ApiExceptionTests.cs @@ -7,19 +7,19 @@ using Mollie.Tests.Integration.Framework; using Xunit; -namespace Mollie.Tests.Integration.Api; +namespace Mollie.Tests.Integration.Api; public class ApiExceptionTests : BaseMollieApiTestClass { [DefaultRetryFact] public async Task ShouldThrowMollieApiExceptionWhenInvalidParametersAreGiven() { // If: we create a payment request with invalid parameters - using IPaymentClient paymentClient = new PaymentClient(this.ApiKey); + using IPaymentClient paymentClient = new PaymentClient(ApiKey); PaymentRequest paymentRequest = new PaymentRequest() { Amount = new Amount(Currency.EUR, "100.00"), Description = null, RedirectUrl = null }; - + // Then: Send the payment request to the Mollie Api, this should throw a mollie api exception MollieApiException apiException = await Assert.ThrowsAsync(() => paymentClient.CreatePaymentAsync(paymentRequest)); apiException.Should().NotBeNull(); @@ -28,4 +28,4 @@ public async Task ShouldThrowMollieApiExceptionWhenInvalidParametersAreGiven() { apiException.Details.Title.Should().Be("Unprocessable Entity"); apiException.Details.Detail.Should().Be("The description is invalid"); } -} \ No newline at end of file +} diff --git a/tests/Mollie.Tests.Integration/Api/BalanceTests.cs b/tests/Mollie.Tests.Integration/Api/BalanceTests.cs index e3007419..7eaf7580 100644 --- a/tests/Mollie.Tests.Integration/Api/BalanceTests.cs +++ b/tests/Mollie.Tests.Integration/Api/BalanceTests.cs @@ -10,16 +10,16 @@ using Mollie.Tests.Integration.Framework; using Xunit; -namespace Mollie.Tests.Integration.Api; +namespace Mollie.Tests.Integration.Api; [Trait("TestCategory", "AccessKeyIntegrationTest")] public class BalanceTests : BaseMollieApiTestClass, IDisposable { private readonly IBalanceClient _balanceClient; public BalanceTests() { - _balanceClient = new BalanceClient(this.ApiKey); + _balanceClient = new BalanceClient(ApiKey); } - + [DefaultRetryFact] public async Task GetPrimaryBalanceAsync_IsParsedCorrectly() { // When: We retrieve the primary balance from the Mollie API @@ -37,18 +37,18 @@ public async Task GetPrimaryBalanceAsync_IsParsedCorrectly() { result.PendingAmount.Should().NotBeNull(); result.TransferThreshold.Should().NotBeNull(); } - + [DefaultRetryFact] public async Task GetBalanceAsync_IsParsedCorrectly() { // Given: We get a balance id from the list balances endpoint - var balanceList = await this._balanceClient.ListBalancesAsync(); + var balanceList = await _balanceClient.ListBalancesAsync(); if (balanceList.Count == 0) { Assert.Fail("No balance found to retrieve"); } var firstBalance = balanceList.Items.First(); // When: We retrieve a specific balance from the Mollie API - var result = await this._balanceClient.GetBalanceAsync(firstBalance.Id); + var result = await _balanceClient.GetBalanceAsync(firstBalance.Id); // Then: Make sure we can parse the result result.Should().NotBeNull(); @@ -63,17 +63,17 @@ public async Task GetBalanceAsync_IsParsedCorrectly() { result.PendingAmount.Should().Be(firstBalance.PendingAmount); result.TransferThreshold.Should().Be(firstBalance.TransferThreshold); } - + [DefaultRetryFact] public async Task ListBalancesAsync_IsParsedCorrectly() { // When: We retrieve the list of balances - var result = await this._balanceClient.ListBalancesAsync(); + var result = await _balanceClient.ListBalancesAsync(); // Then: Make sure we can parse the result result.Should().NotBeNull(); result.Items.Count.Should().Be(result.Count); } - + [DefaultRetryTheory] [InlineData(ReportGrouping.TransactionCategories, typeof(TransactionCategoriesReportResponse))] [InlineData(ReportGrouping.StatusBalances, typeof(StatusBalanceReportResponse))] @@ -81,12 +81,12 @@ public async Task GetBalanceReportAsync_IsParsedCorrectly(string grouping, Type // Given: We retrieve the primary balance var from = new DateTime(2022, 11, 1); var until = new DateTime(2022, 11, 30); - var primaryBalance = await this._balanceClient.GetPrimaryBalanceAsync(); - + var primaryBalance = await _balanceClient.GetPrimaryBalanceAsync(); + // When: We retrieve the primary balance report - var result = await this._balanceClient.GetBalanceReportAsync( + var result = await _balanceClient.GetBalanceReportAsync( balanceId: primaryBalance.Id, - from: from, + from: from, until: until, grouping: grouping); @@ -99,16 +99,16 @@ public async Task GetBalanceReportAsync_IsParsedCorrectly(string grouping, Type result.Until.Should().Be(until); result.Grouping.Should().Be(grouping); } - + [DefaultRetryFact] public async Task ListBalanceTransactionsAsync_IsParsedCorrectly() { // Given var balanceId = "bal_CKjKwQdjCwCSArXFAJNFH"; var from = "baltr_9S8yk4FFqqi2Qm6K3rqRH"; var limit = 250; - + // When: We list the balance transactions - var result = await this._balanceClient.ListBalanceTransactionsAsync(balanceId, from, limit); + var result = await _balanceClient.ListBalanceTransactionsAsync(balanceId, from, limit); // Then: Make sure we can parse the result result.Should().NotBeNull(); @@ -117,15 +117,15 @@ public async Task ListBalanceTransactionsAsync_IsParsedCorrectly() { result.Links.Should().NotBeNull(); result.Links.Self.Href.Should().Be($"https://api.mollie.com/v2/balances/{balanceId}/transactions?from={from}&limit={limit}"); } - + [DefaultRetryFact] public async Task ListPrimaryBalanceTransactionsAsync_IsParsedCorrectly() { // Given var from = "baltr_9S8yk4FFqqi2Qm6K3rqRH"; var limit = 250; - + // When: We list the balance transactions - var result = await this._balanceClient.ListPrimaryBalanceTransactionsAsync(from, limit); + var result = await _balanceClient.ListPrimaryBalanceTransactionsAsync(from, limit); // Then: Make sure we can parse the result result.Should().NotBeNull(); @@ -137,4 +137,4 @@ public void Dispose() { _balanceClient?.Dispose(); } -} \ No newline at end of file +} diff --git a/tests/Mollie.Tests.Integration/Api/CaptureTests.cs b/tests/Mollie.Tests.Integration/Api/CaptureTests.cs index 0821dd3a..c54b5fef 100644 --- a/tests/Mollie.Tests.Integration/Api/CaptureTests.cs +++ b/tests/Mollie.Tests.Integration/Api/CaptureTests.cs @@ -16,12 +16,12 @@ namespace Mollie.Tests.Integration.Api; public class CaptureTests : BaseMollieApiTestClass, IDisposable { private readonly ICaptureClient _captureClient; private readonly IPaymentClient _paymentClient; - + public CaptureTests() { - _captureClient = new CaptureClient(this.ApiKey); - _paymentClient = new PaymentClient(this.ApiKey); + _captureClient = new CaptureClient(ApiKey); + _paymentClient = new PaymentClient(ApiKey); } - + [DefaultRetryFact(Skip = "We can only test this in debug mode, because we actually have to use the PaymentUrl" + " to make the payment, since Mollie can only capture payments that have been authorized")] public async Task CanCreateCaptureForPaymentWithManualCaptureMode() { @@ -29,12 +29,12 @@ public async Task CanCreateCaptureForPaymentWithManualCaptureMode() { PaymentRequest paymentRequest = new PaymentRequest() { Amount = new Amount(Currency.EUR, 1000.00m), Description = "Description", - RedirectUrl = this.DefaultRedirectUrl, + RedirectUrl = DefaultRedirectUrl, Method = PaymentMethod.CreditCard, CaptureMode = CaptureMode.Manual }; var payment = await _paymentClient.CreatePaymentAsync(paymentRequest); - + // When: We create a capture for the payment var captureRequest = new CaptureRequest { @@ -59,7 +59,7 @@ public async Task CanRetrieveCaptureListForPayment() PaymentRequest paymentRequest = new PaymentRequest() { Amount = new Amount(Currency.EUR, 1000.00m), Description = "Description", - RedirectUrl = this.DefaultRedirectUrl, + RedirectUrl = DefaultRedirectUrl, Method = PaymentMethod.CreditCard, CaptureMode = CaptureMode.Manual }; @@ -71,10 +71,10 @@ public async Task CanRetrieveCaptureListForPayment() Metadata = "my-metadata string" }; await _captureClient.CreateCapture(payment.Id, captureRequest); - + // When: we retrieve the captures of the payment var captureList = await _captureClient.GetCapturesListAsync(payment.Id); - + // Then captureList.Count.Should().Be(1); var capture = captureList.Items.Single(); @@ -83,10 +83,10 @@ public async Task CanRetrieveCaptureListForPayment() capture.Resource.Should().Be("capture"); capture.Metadata.Should().Be(captureRequest.Metadata); } - + public void Dispose() { _captureClient?.Dispose(); _paymentClient?.Dispose(); } -} \ No newline at end of file +} diff --git a/tests/Mollie.Tests.Integration/Api/ConnectTests.cs b/tests/Mollie.Tests.Integration/Api/ConnectTests.cs index d755f106..67d6ecb1 100644 --- a/tests/Mollie.Tests.Integration/Api/ConnectTests.cs +++ b/tests/Mollie.Tests.Integration/Api/ConnectTests.cs @@ -5,46 +5,46 @@ using System.Threading.Tasks; using FluentAssertions; -namespace Mollie.Tests.Integration.Api; +namespace Mollie.Tests.Integration.Api; public class ConnectTests : BaseMollieApiTestClass { [DefaultRetryFact] public void GetAuthorizationUrl_WithSingleScope_GeneratesAuthorizationUrl() { // Given: We create a new connect client - using ConnectClient connectClient = new ConnectClient(this.ClientId, this.ClientSecret); + using ConnectClient connectClient = new ConnectClient(ClientId, ClientSecret); // When: We get the authorization URL string authorizationUrl = connectClient.GetAuthorizationUrl("abcde", new List() { AppPermissions.PaymentsRead }); - // Then: - string expectedUrl = $"https://www.mollie.com/oauth2/authorize?client_id={this.ClientId}&state=abcde&scope=payments.read&response_type=code&approval_prompt=auto"; + // Then: + string expectedUrl = $"https://www.mollie.com/oauth2/authorize?client_id={ClientId}&state=abcde&scope=payments.read&response_type=code&approval_prompt=auto"; authorizationUrl.Should().Be(expectedUrl); } [DefaultRetryFact] public void GetAuthorizationUrl_WithMultipleScopes_GeneratesAuthorizationUrl() { // Given: We create a new connect client - using ConnectClient connectClient = new ConnectClient(this.ClientId, this.ClientSecret); + using ConnectClient connectClient = new ConnectClient(ClientId, ClientSecret); // When: We get the authorization URL string authorizationUrl = connectClient.GetAuthorizationUrl("abcdef", new List() { - AppPermissions.PaymentsRead, - AppPermissions.PaymentsWrite, - AppPermissions.ProfilesRead, + AppPermissions.PaymentsRead, + AppPermissions.PaymentsWrite, + AppPermissions.ProfilesRead, AppPermissions.ProfilesWrite }); - // Then: - string expectedUrl = $"https://www.mollie.com/oauth2/authorize?client_id={this.ClientId}" + + // Then: + string expectedUrl = $"https://www.mollie.com/oauth2/authorize?client_id={ClientId}" + $"&state=abcdef&scope=payments.read+payments.write+profiles.read+profiles.write&response_type=code&approval_prompt=auto"; authorizationUrl.Should().Be(expectedUrl); } - + [DefaultRetryFact(Skip = "We can only test this in debug mode, because we login to the mollie dashboard and login to get the auth token")] public async Task GetAccessTokenAsync_WithValidTokenRequest_ReturnsAccessToken() { // Given: We fetch create a token request string authCode = "abcde"; // Set a valid access token here - using ConnectClient connectClient = new ConnectClient(this.ClientId, this.ClientSecret); + using ConnectClient connectClient = new ConnectClient(ClientId, ClientSecret); TokenRequest tokenRequest = new TokenRequest(authCode, DefaultRedirectUrl); // When: We request the auth code @@ -58,7 +58,7 @@ public async Task GetAccessTokenAsync_WithValidTokenRequest_ReturnsAccessToken() public async Task RevokeAccessTokenAsync_WithValidToken_DoesNotThrowError() { // Given: We create a revoke token request string accessToken = "abcde"; - using ConnectClient connectClient = new ConnectClient(this.ClientId, this.ClientSecret); + using ConnectClient connectClient = new ConnectClient(ClientId, ClientSecret); RevokeTokenRequest revokeTokenRequest = new RevokeTokenRequest() { TokenTypeHint = TokenType.AccessToken, Token = accessToken @@ -67,4 +67,4 @@ public async Task RevokeAccessTokenAsync_WithValidToken_DoesNotThrowError() { // When: we send the request await connectClient.RevokeTokenAsync(revokeTokenRequest); } -} \ No newline at end of file +} diff --git a/tests/Mollie.Tests.Integration/Api/CustomerTests.cs b/tests/Mollie.Tests.Integration/Api/CustomerTests.cs index d81f7d0f..70a3c703 100644 --- a/tests/Mollie.Tests.Integration/Api/CustomerTests.cs +++ b/tests/Mollie.Tests.Integration/Api/CustomerTests.cs @@ -14,19 +14,19 @@ using Mollie.Tests.Integration.Framework; using Xunit; -namespace Mollie.Tests.Integration.Api; +namespace Mollie.Tests.Integration.Api; public class CustomerTests : BaseMollieApiTestClass, IDisposable { private readonly ICustomerClient _customerClient; - + public CustomerTests() { - _customerClient = new CustomerClient(this.ApiKey); + _customerClient = new CustomerClient(ApiKey); } - + [DefaultRetryFact] public async Task CanRetrieveCustomerList() { // When: Retrieve customer list with default settings - ListResponse response = await this._customerClient.GetCustomerListAsync(); + ListResponse response = await _customerClient.GetCustomerListAsync(); // Then response.Should().NotBeNull(); @@ -39,7 +39,7 @@ public async Task ListCustomersNeverReturnsMoreCustomersThenTheNumberOfRequested int numberOfCustomers = 5; // When: Retrieve 5 customers - ListResponse response = await this._customerClient.GetCustomerListAsync(null, numberOfCustomers); + ListResponse response = await _customerClient.GetCustomerListAsync(null, numberOfCustomers); // Then numberOfCustomers.Should().Be(response.Items.Count); @@ -52,7 +52,7 @@ public async Task CanCreateNewCustomer() { string email = "johnsmit@mollie.com"; // When: We send the customer request to Mollie - CustomerResponse result = await this.CreateCustomer(name, email); + CustomerResponse result = await CreateCustomer(name, email); // Then: Make sure the requested parameters match the response parameter values result.Should().NotBeNull(); @@ -63,7 +63,7 @@ public async Task CanCreateNewCustomer() { [DefaultRetryFact] public async Task CanUpdateCustomer() { // If: We retrieve the customer list - ListResponse response = await this._customerClient.GetCustomerListAsync(); + ListResponse response = await _customerClient.GetCustomerListAsync(); // When: We update one of the customers in the list string customerIdToUpdate = response.Items.First().Id; @@ -71,7 +71,7 @@ public async Task CanUpdateCustomer() { CustomerRequest updateParameters = new CustomerRequest() { Name = newCustomerName }; - CustomerResponse result = await this._customerClient.UpdateCustomerAsync(customerIdToUpdate, updateParameters); + CustomerResponse result = await _customerClient.UpdateCustomerAsync(customerIdToUpdate, updateParameters); // Then: Make sure the new name is updated result.Should().NotBeNull(); @@ -81,14 +81,14 @@ public async Task CanUpdateCustomer() { [DefaultRetryFact] public async Task CanDeleteCustomer() { // If: We retrieve the customer list - ListResponse response = await this._customerClient.GetCustomerListAsync(); + ListResponse response = await _customerClient.GetCustomerListAsync(); // When: We delete one of the customers in the list string customerIdToDelete = response.Items.First().Id; - await this._customerClient.DeleteCustomerAsync(customerIdToDelete); + await _customerClient.DeleteCustomerAsync(customerIdToDelete); // Then: Make sure its deleted - MollieApiException apiException = await Assert.ThrowsAsync(() => this._customerClient.GetCustomerAsync(customerIdToDelete)); + MollieApiException apiException = await Assert.ThrowsAsync(() => _customerClient.GetCustomerAsync(customerIdToDelete)); apiException.Details.Status.Should().Be((int)HttpStatusCode.Gone); } @@ -97,10 +97,10 @@ public async Task CanGetCustomerByUrlObject() { // If: We create a customer request with only the required parameters string name = "Smit"; string email = "johnsmit@mollie.com"; - CustomerResponse createdCustomer = await this.CreateCustomer(name, email); + CustomerResponse createdCustomer = await CreateCustomer(name, email); // When: We try to retrieve the customer by Url object - CustomerResponse retrievedCustomer = await this._customerClient.GetCustomerAsync(createdCustomer.Links.Self); + CustomerResponse retrievedCustomer = await _customerClient.GetCustomerAsync(createdCustomer.Links.Self); // Then: Make sure it's retrieved retrievedCustomer.Name.Should().Be(createdCustomer.Name); @@ -118,7 +118,7 @@ public async Task CanCreateCustomerWithJsonMetadata() { }; // When: We try to retrieve the customer by Url object - CustomerResponse retrievedCustomer = await this._customerClient.CreateCustomerAsync(customerRequest); + CustomerResponse retrievedCustomer = await _customerClient.CreateCustomerAsync(customerRequest); // Then: Make sure it's retrieved IsJsonResultEqual(customerRequest.Metadata, retrievedCustomer.Metadata).Should().BeTrue(); @@ -135,7 +135,7 @@ public async Task CanCreateCustomerWithStringMetadata() { }; // When: We try to retrieve the customer by Url object - CustomerResponse retrievedCustomer = await this._customerClient.CreateCustomerAsync(customerRequest); + CustomerResponse retrievedCustomer = await _customerClient.CreateCustomerAsync(customerRequest); // Then: Make sure it's retrieved retrievedCustomer.Metadata.Should().Be(customerRequest.Metadata); @@ -146,15 +146,15 @@ public async Task CanCreateNewCustomerPayment() { // If: We create a customer request with only the required parameters string name = "Smit"; string email = "johnsmit@mollie.com"; - CustomerResponse customer = await this.CreateCustomer(name, email); + CustomerResponse customer = await CreateCustomer(name, email); PaymentRequest paymentRequest = new PaymentRequest() { Amount = new Amount(Currency.EUR, "100.00"), Description = "Description", - RedirectUrl = this.DefaultRedirectUrl + RedirectUrl = DefaultRedirectUrl }; // When: We create a payment request for this customer to Mollie - PaymentResponse paymentResponse = await this._customerClient.CreateCustomerPayment(customer.Id, paymentRequest); + PaymentResponse paymentResponse = await _customerClient.CreateCustomerPayment(customer.Id, paymentRequest); // Then: Make sure the requested parameters match the response parameter values paymentResponse.Should().NotBeNull(); @@ -168,11 +168,11 @@ private async Task CreateCustomer(string name, string email) { Locale = Locale.nl_NL }; - return await this._customerClient.CreateCustomerAsync(customerRequest); + return await _customerClient.CreateCustomerAsync(customerRequest); } public void Dispose() { _customerClient?.Dispose(); } -} \ No newline at end of file +} diff --git a/tests/Mollie.Tests.Integration/Api/MandateTests.cs b/tests/Mollie.Tests.Integration/Api/MandateTests.cs index 4841f048..4fc21881 100644 --- a/tests/Mollie.Tests.Integration/Api/MandateTests.cs +++ b/tests/Mollie.Tests.Integration/Api/MandateTests.cs @@ -10,25 +10,25 @@ using Mollie.Api.Models.Payment; using Mollie.Tests.Integration.Framework; -namespace Mollie.Tests.Integration.Api; +namespace Mollie.Tests.Integration.Api; public class MandateTests : BaseMollieApiTestClass, IDisposable { private readonly IMandateClient _mandateClient; private readonly ICustomerClient _customerClient; public MandateTests() { - _mandateClient = new MandateClient(this.ApiKey); - _customerClient = new CustomerClient(this.ApiKey); + _mandateClient = new MandateClient(ApiKey); + _customerClient = new CustomerClient(ApiKey); } - + [DefaultRetryFact] public async Task CanRetrieveMandateList() { // We can only test this if there are customers - ListResponse customers = await this._customerClient.GetCustomerListAsync(); + ListResponse customers = await _customerClient.GetCustomerListAsync(); if (customers.Count > 0) { // When: Retrieve mandate list with default settings - ListResponse response = await this._mandateClient.GetMandateListAsync(customers.Items.First().Id); + ListResponse response = await _mandateClient.GetMandateListAsync(customers.Items.First().Id); // Then response.Should().NotBeNull(); @@ -39,14 +39,14 @@ public async Task CanRetrieveMandateList() { [DefaultRetryFact] public async Task ListMandatesNeverReturnsMoreCustomersThenTheNumberOfRequestedMandates() { // We can only test this if there are customers - ListResponse customers = await this._customerClient.GetCustomerListAsync(); + ListResponse customers = await _customerClient.GetCustomerListAsync(); if (customers.Count > 0) { // If: Number of customers requested is 5 int numberOfMandates = 5; // When: Retrieve 5 mandates - ListResponse response = await this._mandateClient.GetMandateListAsync(customers.Items.First().Id, null, numberOfMandates); + ListResponse response = await _mandateClient.GetMandateListAsync(customers.Items.First().Id, null, numberOfMandates); // Then numberOfMandates.Should().BeGreaterOrEqualTo(response.Items.Count); @@ -56,7 +56,7 @@ public async Task ListMandatesNeverReturnsMoreCustomersThenTheNumberOfRequestedM [DefaultRetryFact] public async Task CanCreateMandate() { // We can only test this if there are customers - ListResponse customers = await this._customerClient.GetCustomerListAsync(); + ListResponse customers = await _customerClient.GetCustomerListAsync(); if (customers.Count > 0) { // If: We create a new mandate request SepaDirectDebitMandateRequest mandateRequest = new SepaDirectDebitMandateRequest { @@ -66,7 +66,7 @@ public async Task CanCreateMandate() { }; // When: We send the mandate request - MandateResponse mandateResponse = await this._mandateClient.CreateMandateAsync(customers.Items.First().Id, mandateRequest); + MandateResponse mandateResponse = await _mandateClient.CreateMandateAsync(customers.Items.First().Id, mandateRequest); // Then: Make sure we created a new mandate mandateResponse.Details.ConsumerAccount.Should().Be(mandateRequest.ConsumerAccount); @@ -79,4 +79,4 @@ public void Dispose() _mandateClient?.Dispose(); _customerClient?.Dispose(); } -} \ No newline at end of file +} diff --git a/tests/Mollie.Tests.Integration/Api/OrderTests.cs b/tests/Mollie.Tests.Integration/Api/OrderTests.cs index a98e04c4..196a8adb 100644 --- a/tests/Mollie.Tests.Integration/Api/OrderTests.cs +++ b/tests/Mollie.Tests.Integration/Api/OrderTests.cs @@ -14,13 +14,13 @@ using Mollie.Tests.Integration.Framework; using Xunit; -namespace Mollie.Tests.Integration.Api; +namespace Mollie.Tests.Integration.Api; public class OrderTests : BaseMollieApiTestClass, IDisposable { private readonly IOrderClient _orderClient; public OrderTests() { - _orderClient = new OrderClient(this.ApiKey); + _orderClient = new OrderClient(ApiKey); } [DefaultRetryFact] @@ -28,47 +28,47 @@ public async Task GetOrderListAsync_WithoutSortOrder_ReturnsOrdersInDescendingOr { // Act var orders = await _orderClient.GetOrderListAsync(); - + // Assert if (orders.Items.Any()) { orders.Items.Should().BeInDescendingOrder(x => x.CreatedAt); } } - + [DefaultRetryFact] public async Task GetOrderListAsync_InDescendingOrder_ReturnsOrdersInDescendingOrder() { // Act var orders = await _orderClient.GetOrderListAsync(sort: SortDirection.Desc); - + // Assert if (orders.Items.Any()) { orders.Items.Should().BeInDescendingOrder(x => x.CreatedAt); } } - + [DefaultRetryFact] public async Task GetOrderListAsync_InAscendingOrder_ReturnsOrdersInAscendingOrder() { // Act var orders = await _orderClient.GetOrderListAsync(sort: SortDirection.Asc); - + // Assert if (orders.Items.Any()) { orders.Items.Should().BeInAscendingOrder(x => x.CreatedAt); } } - + [DefaultRetryFact] public async Task CreateOrderAsync_OrderWithRequiredFields_OrderIsCreated() { // If: we create a order request with only the required parameters - OrderRequest orderRequest = this.CreateOrder(); + OrderRequest orderRequest = CreateOrder(); // When: We send the order request to Mollie - OrderResponse result = await this._orderClient.CreateOrderAsync(orderRequest); + OrderResponse result = await _orderClient.CreateOrderAsync(orderRequest); // Then: Make sure we get a valid response result.Should().NotBeNull(); @@ -88,7 +88,7 @@ public async Task CreateOrderAsync_OrderWithRequiredFields_OrderIsCreated() { [DefaultRetryFact] public async Task CreateOrderAsync_WithMultiplePaymentMethods_OrderIsCreated() { // When: we create a order request and specify multiple payment methods - OrderRequest orderRequest = this.CreateOrder(); + OrderRequest orderRequest = CreateOrder(); orderRequest.Methods = new List() { PaymentMethod.Ideal, PaymentMethod.CreditCard, @@ -96,7 +96,7 @@ public async Task CreateOrderAsync_WithMultiplePaymentMethods_OrderIsCreated() { }; // When: We send the order request to Mollie - OrderResponse result = await this._orderClient.CreateOrderAsync(orderRequest); + OrderResponse result = await _orderClient.CreateOrderAsync(orderRequest); // Then: Make sure we get a valid response result.Should().NotBeNull(); @@ -107,11 +107,11 @@ public async Task CreateOrderAsync_WithMultiplePaymentMethods_OrderIsCreated() { [DefaultRetryFact] public async Task CreateOrderAsync_WithSinglePaymentMethod_OrderIsCreated() { // When: we create a order request and specify a single payment method - OrderRequest orderRequest = this.CreateOrder(); + OrderRequest orderRequest = CreateOrder(); orderRequest.Method = PaymentMethod.CreditCard; // When: We send the order request to Mollie - OrderResponse result = await this._orderClient.CreateOrderAsync(orderRequest); + OrderResponse result = await _orderClient.CreateOrderAsync(orderRequest); // Then: Make sure we get a valid response orderRequest.Method.Should().Be(PaymentMethod.CreditCard); @@ -124,7 +124,7 @@ public async Task CreateOrderAsync_WithSinglePaymentMethod_OrderIsCreated() { public static IEnumerable PaymentSpecificParameters => new List { - new object[] { + new object[] { new KlarnaSpecificParameters { ExtraMerchantData = new { payment_history_simple = new[] { @@ -136,7 +136,7 @@ public async Task CreateOrderAsync_WithSinglePaymentMethod_OrderIsCreated() { } } }, - new object[] { + new object[] { new BillieSpecificParameters { Company = new CompanyObject { EntityType = CompanyEntityType.LimitedCompany, @@ -144,64 +144,64 @@ public async Task CreateOrderAsync_WithSinglePaymentMethod_OrderIsCreated() { VatNumber = "vat-number" } } - }, - new object[] { + }, + new object[] { new GiftcardSpecificParameters() { Issuer = "boekenbon", VoucherNumber = "voucher-number", VoucherPin = "1234" } }, - new object[] { + new object[] { new IDealSpecificParameters { Issuer = "ideal_INGBNL2A" } }, - new object[] { + new object[] { new KbcSpecificParameters { Issuer = "ideal_INGBNL2A" } }, - new object[] { + new object[] { new PaySafeCardSpecificParameters { CustomerReference = "customer-reference" } }, - new object[] { + new object[] { new SepaDirectDebitSpecificParameters { ConsumerAccount = "Consumer account" } } }; - + [DefaultRetryTheory] [MemberData(nameof(PaymentSpecificParameters))] public async Task CreateOrderAsync_WithPaymentSpecificParameters_OrderIsCreated( PaymentSpecificParameters paymentSpecificParameters) { - + // If: we create a order request with payment specific parameters - OrderRequest orderRequest = this.CreateOrder(); + OrderRequest orderRequest = CreateOrder(); orderRequest.BillingAddress.Country = "DE"; // Billie only works in Germany orderRequest.BillingAddress.OrganizationName = "Mollie"; // Billie requires a organization name orderRequest.Payment = paymentSpecificParameters; // When: We send the order request to Mollie - OrderResponse result = await this._orderClient.CreateOrderAsync(orderRequest); + OrderResponse result = await _orderClient.CreateOrderAsync(orderRequest); // Then: Make sure we get a valid response result.Should().NotBeNull(); result.Amount.Should().Be(orderRequest.Amount); result.OrderNumber.Should().Be(orderRequest.OrderNumber); } - + [DefaultRetryFact] public async Task GetOrderAsync_OrderIsCreated_OrderCanBeRetrieved() { // If: we create a new order - OrderRequest orderRequest = this.CreateOrder(); - OrderResponse createdOrder = await this._orderClient.CreateOrderAsync(orderRequest); + OrderRequest orderRequest = CreateOrder(); + OrderResponse createdOrder = await _orderClient.CreateOrderAsync(orderRequest); // When: We attempt to retrieve the order - OrderResponse retrievedOrder = await this._orderClient.GetOrderAsync(createdOrder.Id); + OrderResponse retrievedOrder = await _orderClient.GetOrderAsync(createdOrder.Id); // Then: Make sure we get a valid response retrievedOrder.Should().NotBeNull(); @@ -211,11 +211,11 @@ public async Task GetOrderAsync_OrderIsCreated_OrderCanBeRetrieved() { [DefaultRetryFact] public async Task GetOrderAsync_WithIncludeParameters_OrderIsRetrievedWithEmbeddedData() { // If: we create a new order - OrderRequest orderRequest = this.CreateOrder(); - OrderResponse createdOrder = await this._orderClient.CreateOrderAsync(orderRequest); + OrderRequest orderRequest = CreateOrder(); + OrderResponse createdOrder = await _orderClient.CreateOrderAsync(orderRequest); // When: We attempt to retrieve the order and add the include parameters - OrderResponse retrievedOrder = await this._orderClient.GetOrderAsync(createdOrder.Id, embedPayments: true, embedShipments: true, embedRefunds: true); + OrderResponse retrievedOrder = await _orderClient.GetOrderAsync(createdOrder.Id, embedPayments: true, embedShipments: true, embedRefunds: true); // Then: Make sure we get a valid response retrievedOrder.Should().NotBeNull(); @@ -229,8 +229,8 @@ public async Task GetOrderAsync_WithIncludeParameters_OrderIsRetrievedWithEmbedd [DefaultRetryFact] public async Task UpdateOrderAsync_OrderIsUpdated_OrderIsUpdated() { // If: we create a new order - OrderRequest orderRequest = this.CreateOrder(); - OrderResponse createdOrder = await this._orderClient.CreateOrderAsync(orderRequest); + OrderRequest orderRequest = CreateOrder(); + OrderResponse createdOrder = await _orderClient.CreateOrderAsync(orderRequest); // When: We attempt to update the order OrderUpdateRequest orderUpdateRequest = new OrderUpdateRequest() { @@ -238,34 +238,34 @@ public async Task UpdateOrderAsync_OrderIsUpdated_OrderIsUpdated() { BillingAddress = createdOrder.BillingAddress }; orderUpdateRequest.BillingAddress.City = "Den Haag"; - OrderResponse updatedOrder = await this._orderClient.UpdateOrderAsync(createdOrder.Id, orderUpdateRequest); + OrderResponse updatedOrder = await _orderClient.UpdateOrderAsync(createdOrder.Id, orderUpdateRequest); // Then: Make sure the order is updated updatedOrder.OrderNumber.Should().Be(orderUpdateRequest.OrderNumber); updatedOrder.BillingAddress.City.Should().Be(orderUpdateRequest.BillingAddress.City); } - + [DefaultRetryFact(Skip = "Broken - Reported to Mollie: https://discordapp.com/channels/1037712581407817839/1180467187677401198/1180467187677401198")] public async Task UpdateOrderLinesAsync_WhenOrderLineIsUpdated_UpdatedPropertiesCanBeRetrieved() { // If: we create a new order - OrderRequest orderRequest = this.CreateOrder(); - OrderResponse createdOrder = await this._orderClient.CreateOrderAsync(orderRequest); + OrderRequest orderRequest = CreateOrder(); + OrderResponse createdOrder = await _orderClient.CreateOrderAsync(orderRequest); // When: We update the order line OrderLineUpdateRequest updateRequest = new OrderLineUpdateRequest() { Name = "A fluffy bear" }; - OrderResponse updatedOrder = await this._orderClient.UpdateOrderLinesAsync(createdOrder.Id, createdOrder.Lines.First().Id, updateRequest); + OrderResponse updatedOrder = await _orderClient.UpdateOrderLinesAsync(createdOrder.Id, createdOrder.Lines.First().Id, updateRequest); // Then: The name of the order line should be updated updatedOrder.Lines.First().Name.Should().Be(updateRequest.Name); } - + [DefaultRetryFact] public async Task ManageOrderLinesAsync_AddOperation_OrderLineIsAdded() { // If: we create a new order - OrderRequest orderRequest = this.CreateOrder(); - OrderResponse createdOrder = await this._orderClient.CreateOrderAsync(orderRequest); + OrderRequest orderRequest = CreateOrder(); + OrderResponse createdOrder = await _orderClient.CreateOrderAsync(orderRequest); // When: We use the manager order lines endpoint to add a order line ManageOrderLinesAddOperationData newOrderLineRequest = new ManageOrderLinesAddOperationData { @@ -288,7 +288,7 @@ public async Task ManageOrderLinesAsync_AddOperation_OrderLineIsAdded() { } } }; - OrderResponse updatedOrder = await this._orderClient.ManageOrderLinesAsync(createdOrder.Id, manageOrderLinesRequest); + OrderResponse updatedOrder = await _orderClient.ManageOrderLinesAsync(createdOrder.Id, manageOrderLinesRequest); // Then: The order line should be added updatedOrder.Lines.Should().HaveCount(2); @@ -305,12 +305,12 @@ public async Task ManageOrderLinesAsync_AddOperation_OrderLineIsAdded() { .Replace(" ", ""); newMetaData.Should().Be(newOrderLineRequest.Metadata); } - + [DefaultRetryFact] public async Task ManageOrderLinesAsync_UpdateOperation_OrderLineIsUpdated() { // If: we create a new order - OrderRequest orderRequest = this.CreateOrder(); - OrderResponse createdOrder = await this._orderClient.CreateOrderAsync(orderRequest); + OrderRequest orderRequest = CreateOrder(); + OrderResponse createdOrder = await _orderClient.CreateOrderAsync(orderRequest); // When: We use the manager order lines endpoint to update a order line ManageOrderLinesUpdateOperationData orderLineUpdateRequest = new ManageOrderLinesUpdateOperationData { @@ -334,7 +334,7 @@ public async Task ManageOrderLinesAsync_UpdateOperation_OrderLineIsUpdated() { } } }; - OrderResponse updatedOrder = await this._orderClient.ManageOrderLinesAsync(createdOrder.Id, manageOrderLinesRequest); + OrderResponse updatedOrder = await _orderClient.ManageOrderLinesAsync(createdOrder.Id, manageOrderLinesRequest); // Then: The order line should be updated updatedOrder.Lines.Should().HaveCount(1); @@ -350,12 +350,12 @@ public async Task ManageOrderLinesAsync_UpdateOperation_OrderLineIsUpdated() { .Replace(" ", "") .Should().Be(orderLineUpdateRequest.Metadata); } - + [DefaultRetryFact] public async Task ManageOrderLinesAsync_CancelOperation_OrderLineIsCanceled() { // If: we create a new order - OrderRequest orderRequest = this.CreateOrder(); - OrderResponse createdOrder = await this._orderClient.CreateOrderAsync(orderRequest); + OrderRequest orderRequest = CreateOrder(); + OrderResponse createdOrder = await _orderClient.CreateOrderAsync(orderRequest); // When: We use the manager order lines endpoint to cancel a order line ManagerOrderLinesCancelOperationData orderLineCancelRequest = new ManagerOrderLinesCancelOperationData { @@ -369,7 +369,7 @@ public async Task ManageOrderLinesAsync_CancelOperation_OrderLineIsCanceled() { } } }; - OrderResponse updatedOrder = await this._orderClient.ManageOrderLinesAsync(createdOrder.Id, manageOrderLinesRequest); + OrderResponse updatedOrder = await _orderClient.ManageOrderLinesAsync(createdOrder.Id, manageOrderLinesRequest); // Then: The order line should be canceled updatedOrder.Lines.Should().HaveCount(1); @@ -380,7 +380,7 @@ public async Task ManageOrderLinesAsync_CancelOperation_OrderLineIsCanceled() { [DefaultRetryFact] public async Task GetOrderListAsync_NoParameters_OrderListIsRetrieved() { // When: Retrieve payment list with default settings - ListResponse response = await this._orderClient.GetOrderListAsync(); + ListResponse response = await _orderClient.GetOrderListAsync(); // Then response.Should().NotBeNull(); @@ -393,7 +393,7 @@ public async Task GetOrderListAsync_WithMaximumNumberOfItems_MaximumNumberOfOrde int numberOfOrders = 5; // When: Retrieve 5 orders - ListResponse response = await this._orderClient.GetOrderListAsync(null, numberOfOrders); + ListResponse response = await _orderClient.GetOrderListAsync(null, numberOfOrders); // Then response.Items.Should().HaveCountLessThanOrEqualTo(numberOfOrders); @@ -437,4 +437,4 @@ public void Dispose() { _orderClient?.Dispose(); } -} \ No newline at end of file +} diff --git a/tests/Mollie.Tests.Integration/Api/PaymentLinkTests.cs b/tests/Mollie.Tests.Integration/Api/PaymentLinkTests.cs index 506de7c7..63efba59 100644 --- a/tests/Mollie.Tests.Integration/Api/PaymentLinkTests.cs +++ b/tests/Mollie.Tests.Integration/Api/PaymentLinkTests.cs @@ -10,19 +10,19 @@ using Mollie.Api.Models.PaymentLink.Response; using Mollie.Tests.Integration.Framework; -namespace Mollie.Tests.Integration.Api; +namespace Mollie.Tests.Integration.Api; public class PaymentLinkTests : BaseMollieApiTestClass, IDisposable { private readonly IPaymentLinkClient _paymentLinkClient; public PaymentLinkTests() { - _paymentLinkClient = new PaymentLinkClient(this.ApiKey); + _paymentLinkClient = new PaymentLinkClient(ApiKey); } - + [DefaultRetryFact] public async Task CanRetrievePaymentlinkList() { // When: Retrieve payment list with default settings - ListResponse response = await this._paymentLinkClient.GetPaymentLinkListAsync(); + ListResponse response = await _paymentLinkClient.GetPaymentLinkListAsync(); // Then response.Should().NotBeNull(); @@ -31,20 +31,20 @@ public async Task CanRetrievePaymentlinkList() { [DefaultRetryFact] public async Task CanCreatePaymentLinkAndRetrieveIt() { - // Given: We create a new payment + // Given: We create a new payment PaymentLinkRequest paymentLinkRequest = new PaymentLinkRequest() { Description = "Test", Amount = new Amount(Currency.EUR, 50), - WebhookUrl = this.DefaultWebhookUrl, - RedirectUrl = this.DefaultRedirectUrl, + WebhookUrl = DefaultWebhookUrl, + RedirectUrl = DefaultRedirectUrl, ExpiresAt = DateTime.Now.AddDays(1) }; - var createdPaymentLinkResponse = await this._paymentLinkClient.CreatePaymentLinkAsync(paymentLinkRequest); + var createdPaymentLinkResponse = await _paymentLinkClient.CreatePaymentLinkAsync(paymentLinkRequest); // When: We retrieve it - var retrievePaymentLinkResponse = await this._paymentLinkClient.GetPaymentLinkAsync(createdPaymentLinkResponse.Id); + var retrievePaymentLinkResponse = await _paymentLinkClient.GetPaymentLinkAsync(createdPaymentLinkResponse.Id); - // Then: We expect a list with a single ideal payment + // Then: We expect a list with a single ideal payment var verifyPaymentLinkResponse = new Action(response => { var expiresAtWithoutMs = paymentLinkRequest.ExpiresAt.Value.Truncate(TimeSpan.FromSeconds(1)); @@ -62,4 +62,4 @@ public void Dispose() { _paymentLinkClient?.Dispose(); } -} \ No newline at end of file +} diff --git a/tests/Mollie.Tests.Integration/Api/PaymentMethodTests.cs b/tests/Mollie.Tests.Integration/Api/PaymentMethodTests.cs index ac5c721a..8c3feef1 100644 --- a/tests/Mollie.Tests.Integration/Api/PaymentMethodTests.cs +++ b/tests/Mollie.Tests.Integration/Api/PaymentMethodTests.cs @@ -11,29 +11,29 @@ using Mollie.Tests.Integration.Framework; using Xunit; -namespace Mollie.Tests.Integration.Api; +namespace Mollie.Tests.Integration.Api; public class PaymentMethodTests : BaseMollieApiTestClass, IDisposable { private readonly IPaymentMethodClient _paymentMethodClient; public PaymentMethodTests() { - _paymentMethodClient = new PaymentMethodClient(this.ApiKey); + _paymentMethodClient = new PaymentMethodClient(ApiKey); } - + [DefaultRetryFact] public async Task CanRetrievePaymentMethodList() { // When: Retrieve payment list with default settings - ListResponse response = await this._paymentMethodClient.GetPaymentMethodListAsync(); + ListResponse response = await _paymentMethodClient.GetPaymentMethodListAsync(); // Then: Make sure it can be retrieved response.Should().NotBeNull(); response.Items.Should().NotBeNull(); } - + [DefaultRetryFact] public async Task CanRetrievePaymentMethodListIncludeWallets() { // When: Retrieve payment list with default settings - ListResponse response = await this._paymentMethodClient.GetPaymentMethodListAsync(includeWallets: "applepay"); + ListResponse response = await _paymentMethodClient.GetPaymentMethodListAsync(includeWallets: "applepay"); // Then: Make sure it can be retrieved response.Should().NotBeNull(); @@ -48,7 +48,7 @@ public async Task CanRetrievePaymentMethodListIncludeWallets() { [InlineData(PaymentMethod.Kbc)] public async Task CanRetrieveSinglePaymentMethod(string method) { // When: retrieving a payment method - PaymentMethodResponse paymentMethod = await this._paymentMethodClient.GetPaymentMethodAsync(method); + PaymentMethodResponse paymentMethod = await _paymentMethodClient.GetPaymentMethodAsync(method); // Then: Make sure it can be retrieved paymentMethod.Should().NotBeNull(); @@ -58,7 +58,7 @@ public async Task CanRetrieveSinglePaymentMethod(string method) { [DefaultRetryFact] public async Task CanRetrieveKbcIssuers() { // When: retrieving the ideal method we can include the issuers - PaymentMethodResponse paymentMethod = await this._paymentMethodClient.GetPaymentMethodAsync(PaymentMethod.Kbc, true); + PaymentMethodResponse paymentMethod = await _paymentMethodClient.GetPaymentMethodAsync(PaymentMethod.Kbc, true); // Then: We should have one or multiple issuers paymentMethod.Should().NotBeNull(); @@ -68,7 +68,7 @@ public async Task CanRetrieveKbcIssuers() { [DefaultRetryFact] public async Task DoNotRetrieveIssuersWhenIncludeIsFalse() { // When: retrieving the ideal method with the include parameter set to false - PaymentMethodResponse paymentMethod = await this._paymentMethodClient.GetPaymentMethodAsync(PaymentMethod.Kbc, false); + PaymentMethodResponse paymentMethod = await _paymentMethodClient.GetPaymentMethodAsync(PaymentMethod.Kbc, false); // Then: Issuers should not be included paymentMethod.Issuers.Should().BeNull(); @@ -77,7 +77,7 @@ public async Task DoNotRetrieveIssuersWhenIncludeIsFalse() { [DefaultRetryFact] public async Task CanRetrievePricing() { // When: retrieving the ideal method we can include the issuers - PaymentMethodResponse paymentMethod = await this._paymentMethodClient.GetPaymentMethodAsync(PaymentMethod.CreditCard, includePricing: true); + PaymentMethodResponse paymentMethod = await _paymentMethodClient.GetPaymentMethodAsync(PaymentMethod.CreditCard, includePricing: true); // Then: We should have one or multiple issuers paymentMethod.Should().NotBeNull(); @@ -87,7 +87,7 @@ public async Task CanRetrievePricing() { [DefaultRetryFact] public async Task DoNotRetrievePricingWhenIncludeIsFalse() { // When: retrieving the ideal method with the include parameter set to false - PaymentMethodResponse paymentMethod = await this._paymentMethodClient.GetPaymentMethodAsync(PaymentMethod.CreditCard, includePricing: false); + PaymentMethodResponse paymentMethod = await _paymentMethodClient.GetPaymentMethodAsync(PaymentMethod.CreditCard, includePricing: false); // Then: Issuers should not be included paymentMethod.Pricing.Should().BeNull(); @@ -96,7 +96,7 @@ public async Task DoNotRetrievePricingWhenIncludeIsFalse() { [DefaultRetryFact] public async Task CanRetrieveAllMethods() { // When: retrieving the all mollie payment methods - ListResponse paymentMethods = await this._paymentMethodClient.GetAllPaymentMethodListAsync(); + ListResponse paymentMethods = await _paymentMethodClient.GetAllPaymentMethodListAsync(); // Then: We should have multiple issuers paymentMethods.Should().NotBeNull(); @@ -106,7 +106,7 @@ public async Task CanRetrieveAllMethods() { [DefaultRetryFact] public async Task CanRetrievePricingForAllMethods() { // When: retrieving the ideal method we can include the issuers - ListResponse paymentMethods = await this._paymentMethodClient.GetAllPaymentMethodListAsync(includePricing: true); + ListResponse paymentMethods = await _paymentMethodClient.GetAllPaymentMethodListAsync(includePricing: true); // Then: We should have prices available paymentMethods.Items.All(x => x.Pricing != null && x.Pricing.Any(y => y.Fixed.Value > 0)).Should().BeTrue(); @@ -115,7 +115,7 @@ public async Task CanRetrievePricingForAllMethods() { [DefaultRetryFact] public async Task CanRetrieveIssuersForAllMethods() { // When: retrieving the all mollie payment methods we can include the issuers - ListResponse paymentMethods = await this._paymentMethodClient.GetAllPaymentMethodListAsync(includeIssuers: true); + ListResponse paymentMethods = await _paymentMethodClient.GetAllPaymentMethodListAsync(includeIssuers: true); // Then: We should have one or multiple issuers paymentMethods.Items.Should().Contain(x => x.Issuers != null); @@ -124,13 +124,13 @@ public async Task CanRetrieveIssuersForAllMethods() { [DefaultRetryFact] public async Task CanRetrieveIssuersAndPricingInformation() { // When: retrieving the all mollie payment methods we can include the issuers - ListResponse paymentMethods = await this._paymentMethodClient.GetAllPaymentMethodListAsync(includeIssuers: true, includePricing: true); - + ListResponse paymentMethods = await _paymentMethodClient.GetAllPaymentMethodListAsync(includeIssuers: true, includePricing: true); + // Then: We should have one or multiple issuers paymentMethods.Items.Should().Contain(x => x.Issuers != null); paymentMethods.Items.Should().Contain(x => x.Pricing != null && x.Pricing.Any(y => y.Fixed.Value > 0)); } - + [DefaultRetryTheory] [InlineData("JPY", 249)] [InlineData("ISK", 50)] @@ -138,8 +138,8 @@ public async Task CanRetrieveIssuersAndPricingInformation() { public async Task GetPaymentMethodListAsync_WithVariousCurrencies_ReturnsAvailablePaymentMethods(string currency, decimal value) { // When: Retrieving the payment methods for a currency and amount var amount = new Amount(currency, value); - var paymentMethods = await this._paymentMethodClient.GetPaymentMethodListAsync(amount: amount); - + var paymentMethods = await _paymentMethodClient.GetPaymentMethodListAsync(amount: amount); + // Then: We should have multiple payment methods paymentMethods.Count.Should().BeGreaterThan(0); } @@ -148,4 +148,4 @@ public void Dispose() { _paymentMethodClient?.Dispose(); } -} \ No newline at end of file +} diff --git a/tests/Mollie.Tests.Integration/Api/PaymentTests.cs b/tests/Mollie.Tests.Integration/Api/PaymentTests.cs index 3379e2ba..2f5422f1 100644 --- a/tests/Mollie.Tests.Integration/Api/PaymentTests.cs +++ b/tests/Mollie.Tests.Integration/Api/PaymentTests.cs @@ -30,29 +30,29 @@ public class PaymentTests : BaseMollieApiTestClass, IDisposable { private readonly ICaptureClient _captureClient; public PaymentTests() { - _paymentClient = new PaymentClient(this.ApiKey); - _customerClient = new CustomerClient(this.ApiKey); - _mandateClient = new MandateClient(this.ApiKey); - _terminalClient = new TerminalClient(this.ApiKey); - _captureClient = new CaptureClient(this.ApiKey); + _paymentClient = new PaymentClient(ApiKey); + _customerClient = new CustomerClient(ApiKey); + _mandateClient = new MandateClient(ApiKey); + _terminalClient = new TerminalClient(ApiKey); + _captureClient = new CaptureClient(ApiKey); } - + [DefaultRetryFact] public async Task CanRetrievePaymentList() { // When: Retrieve payment list with default settings - ListResponse response = await this._paymentClient.GetPaymentListAsync(); + ListResponse response = await _paymentClient.GetPaymentListAsync(); // Then response.Should().NotBeNull(); response.Items.Should().NotBeNull(); response.Items.Should().BeInDescendingOrder(x => x.CreatedAt); } - + [DefaultRetryFact] public async Task CanRetrievePaymentListInDescendingOrder() { // When: Retrieve payment list in ascending order - ListResponse response = await this._paymentClient.GetPaymentListAsync(sort: SortDirection.Desc); + ListResponse response = await _paymentClient.GetPaymentListAsync(sort: SortDirection.Desc); // Then response.Should().NotBeNull(); @@ -64,7 +64,7 @@ public async Task CanRetrievePaymentListInDescendingOrder() public async Task CanRetrievePaymentListInAscendingOrder() { // When: Retrieve payment list in ascending order - ListResponse response = await this._paymentClient.GetPaymentListAsync(sort: SortDirection.Asc); + ListResponse response = await _paymentClient.GetPaymentListAsync(sort: SortDirection.Asc); // Then response.Should().NotBeNull(); @@ -78,7 +78,7 @@ public async Task ListPaymentsNeverReturnsMorePaymentsThenTheNumberOfRequestedPa int numberOfPayments = 5; // When: Retrieve 5 payments - ListResponse response = await this._paymentClient.GetPaymentListAsync(null, numberOfPayments); + ListResponse response = await _paymentClient.GetPaymentListAsync(null, numberOfPayments); // Then response.Items.Count.Should().BeLessOrEqualTo(numberOfPayments); @@ -94,15 +94,15 @@ public async Task CanCreateDefaultPaymentWithOnlyRequiredFields() { }; // When: We send the payment request to Mollie - PaymentResponse result = await this._paymentClient.CreatePaymentAsync(paymentRequest); - + PaymentResponse result = await _paymentClient.CreatePaymentAsync(paymentRequest); + // Then: Make sure we get a valid response result.Should().NotBeNull(); result.Amount.Should().Be(paymentRequest.Amount); result.Description.Should().Be(paymentRequest.Description); result.RedirectUrl.Should().Be(paymentRequest.RedirectUrl); } - + [DefaultRetryFact] public async Task CanCreateDefaultPaymentWithCustomIdempotencyKey() { // Given: we create a payment request with only the required parameters @@ -117,7 +117,7 @@ public async Task CanCreateDefaultPaymentWithCustomIdempotencyKey() { { PaymentResponse firstAttempt = await _paymentClient.CreatePaymentAsync(paymentRequest); PaymentResponse secondAttempt = await _paymentClient.CreatePaymentAsync(paymentRequest); - + // Then: Make sure the responses have the same payment Id firstAttempt.Id.Should().Be(secondAttempt.Id); } @@ -129,15 +129,15 @@ public async Task CanCreateDefaultPaymentWithAllFields() { PaymentRequest paymentRequest = new PaymentRequest() { Amount = new Amount(Currency.EUR, "100.00"), Description = "Description", - RedirectUrl = this.DefaultRedirectUrl, + RedirectUrl = DefaultRedirectUrl, Locale = Locale.nl_NL, Metadata = "{\"firstName\":\"John\",\"lastName\":\"Doe\"}", Method = PaymentMethod.BankTransfer, - WebhookUrl = this.DefaultWebhookUrl + WebhookUrl = DefaultWebhookUrl }; // When: We send the payment request to Mollie - PaymentResponse result = await this._paymentClient.CreatePaymentAsync(paymentRequest); + PaymentResponse result = await _paymentClient.CreatePaymentAsync(paymentRequest); // Then: Make sure all requested parameters match the response parameter values result.Should().NotBeNull(); @@ -146,7 +146,7 @@ public async Task CanCreateDefaultPaymentWithAllFields() { result.RedirectUrl.Should().Be(paymentRequest.RedirectUrl); result.Locale.Should().Be(paymentRequest.Locale); result.WebhookUrl.Should().Be(paymentRequest.WebhookUrl); - this.IsJsonResultEqual(result.Metadata, paymentRequest.Metadata).Should().BeTrue(); + IsJsonResultEqual(result.Metadata, paymentRequest.Metadata).Should().BeTrue(); } [DefaultRetryFact] @@ -155,16 +155,16 @@ public async Task CanUpdatePayment() { PaymentRequest paymentRequest = new PaymentRequest() { Amount = new Amount(Currency.EUR, "100.00"), Description = "Description", - RedirectUrl = this.DefaultRedirectUrl + RedirectUrl = DefaultRedirectUrl }; - PaymentResponse result = await this._paymentClient.CreatePaymentAsync(paymentRequest); + PaymentResponse result = await _paymentClient.CreatePaymentAsync(paymentRequest); // When: We update this payment PaymentUpdateRequest paymentUpdateRequest = new PaymentUpdateRequest() { Description = "Updated description", Metadata = "My metadata" }; - PaymentResponse updatedPayment = await this._paymentClient.UpdatePaymentAsync(result.Id, paymentUpdateRequest); + PaymentResponse updatedPayment = await _paymentClient.UpdatePaymentAsync(result.Id, paymentUpdateRequest); // Then: Make sure the payment is updated updatedPayment.Description.Should().Be(paymentUpdateRequest.Description); @@ -177,12 +177,12 @@ public async Task CanCreatePaymentWithSinglePaymentMethod() { PaymentRequest paymentRequest = new PaymentRequest() { Amount = new Amount(Currency.EUR, "100.00"), Description = "Description", - RedirectUrl = this.DefaultRedirectUrl, + RedirectUrl = DefaultRedirectUrl, Method = PaymentMethod.CreditCard }; // When: We send the payment request to Mollie - PaymentResponse result = await this._paymentClient.CreatePaymentAsync(paymentRequest); + PaymentResponse result = await _paymentClient.CreatePaymentAsync(paymentRequest); // Then: Make sure we get a valid response result.Should().NotBeNull(); @@ -198,7 +198,7 @@ public async Task CanCreatePaymentWithMultiplePaymentMethods() { PaymentRequest paymentRequest = new PaymentRequest() { Amount = new Amount(Currency.EUR, "100.00"), Description = "Description", - RedirectUrl = this.DefaultRedirectUrl, + RedirectUrl = DefaultRedirectUrl, Methods = new List() { PaymentMethod.Ideal, PaymentMethod.CreditCard, @@ -207,7 +207,7 @@ public async Task CanCreatePaymentWithMultiplePaymentMethods() { }; // When: We send the payment request to Mollie - PaymentResponse result = await this._paymentClient.CreatePaymentAsync(paymentRequest); + PaymentResponse result = await _paymentClient.CreatePaymentAsync(paymentRequest); // Then: Make sure we get a valid response result.Should().NotBeNull(); @@ -233,7 +233,7 @@ public async Task CanCreateSpecificPaymentType(Type paymentType, string paymentM PaymentRequest paymentRequest = (PaymentRequest)Activator.CreateInstance(paymentType)!; paymentRequest.GetType().GetProperty(nameof(PaymentRequest.Amount)).SetValue(paymentRequest, new Amount(Currency.EUR, "100.00")); paymentRequest.Description = "Description"; - paymentRequest.RedirectUrl = this.DefaultRedirectUrl; + paymentRequest.RedirectUrl = DefaultRedirectUrl; paymentRequest.Method = paymentMethod; // Set required billing email for Przelewy24 @@ -242,7 +242,7 @@ public async Task CanCreateSpecificPaymentType(Type paymentType, string paymentM } // When: We send the payment request to Mollie - PaymentResponse result = await this._paymentClient.CreatePaymentAsync(paymentRequest); + PaymentResponse result = await _paymentClient.CreatePaymentAsync(paymentRequest); // Then: Make sure all requested parameters match the response parameter values result.Should().NotBeNull(); @@ -259,13 +259,13 @@ public async Task CanCreatePaymentAndRetrieveIt() { PaymentRequest paymentRequest = new PaymentRequest() { Amount = new Amount(Currency.EUR, "100.00"), Description = "Description", - RedirectUrl = this.DefaultRedirectUrl, + RedirectUrl = DefaultRedirectUrl, Locale = Locale.de_DE }; // When: We send the payment request to Mollie and attempt to retrieve it - PaymentResponse paymentResponse = await this._paymentClient.CreatePaymentAsync(paymentRequest); - PaymentResponse result = await this._paymentClient.GetPaymentAsync(paymentResponse.Id); + PaymentResponse paymentResponse = await _paymentClient.CreatePaymentAsync(paymentRequest); + PaymentResponse result = await _paymentClient.GetPaymentAsync(paymentResponse.Id); // Then result.Should().NotBeNull(); @@ -279,20 +279,20 @@ public async Task CanCreatePaymentAndRetrieveIt() { [DefaultRetryFact] public async Task CanCreateRecurringPaymentAndRetrieveIt() { // When: we create a new recurring payment - MandateResponse mandate = await this.GetFirstValidMandate(); + MandateResponse mandate = await GetFirstValidMandate(); if (mandate != null) { - CustomerResponse customer = await this._customerClient.GetCustomerAsync(mandate.Links.Customer); + CustomerResponse customer = await _customerClient.GetCustomerAsync(mandate.Links.Customer); PaymentRequest paymentRequest = new PaymentRequest() { Amount = new Amount(Currency.EUR, "100.00"), Description = "Description", - RedirectUrl = this.DefaultRedirectUrl, + RedirectUrl = DefaultRedirectUrl, SequenceType = SequenceType.First, CustomerId = customer.Id }; // When: We send the payment request to Mollie and attempt to retrieve it - PaymentResponse paymentResponse = await this._paymentClient.CreatePaymentAsync(paymentRequest); - PaymentResponse result = await this._paymentClient.GetPaymentAsync(paymentResponse.Id); + PaymentResponse paymentResponse = await _paymentClient.CreatePaymentAsync(paymentRequest); + PaymentResponse result = await _paymentClient.GetPaymentAsync(paymentResponse.Id); // Then: Make sure the recurringtype parameter is entered result.SequenceType.Should().Be(SequenceType.First); @@ -306,12 +306,12 @@ public async Task CanCreatePaymentWithMetaData() { PaymentRequest paymentRequest = new PaymentRequest() { Amount = new Amount(Currency.EUR, "100.00"), Description = "Description", - RedirectUrl = this.DefaultRedirectUrl, + RedirectUrl = DefaultRedirectUrl, Metadata = metadata }; // When: We send the payment request to Mollie - PaymentResponse result = await this._paymentClient.CreatePaymentAsync(paymentRequest); + PaymentResponse result = await _paymentClient.CreatePaymentAsync(paymentRequest); // Then: Make sure we get the same json result as metadata result.Metadata.Should().Be(metadata); @@ -324,15 +324,15 @@ public async Task CanCreatePaymentWithJsonMetaData() { PaymentRequest paymentRequest = new PaymentRequest() { Amount = new Amount(Currency.EUR, "100.00"), Description = "Description", - RedirectUrl = this.DefaultRedirectUrl, + RedirectUrl = DefaultRedirectUrl, Metadata = json }; // When: We send the payment request to Mollie - PaymentResponse result = await this._paymentClient.CreatePaymentAsync(paymentRequest); + PaymentResponse result = await _paymentClient.CreatePaymentAsync(paymentRequest); // Then: Make sure we get the same json result as metadata - this.IsJsonResultEqual(result.Metadata, json).Should().BeTrue(); + IsJsonResultEqual(result.Metadata, json).Should().BeTrue(); } [DefaultRetryFact] @@ -346,12 +346,12 @@ public async Task CanCreatePaymentWithCustomMetaDataClass() { PaymentRequest paymentRequest = new PaymentRequest() { Amount = new Amount(Currency.EUR, "100.00"), Description = "Description", - RedirectUrl = this.DefaultRedirectUrl, + RedirectUrl = DefaultRedirectUrl, }; paymentRequest.SetMetadata(metadataRequest); // When: We send the payment request to Mollie - PaymentResponse result = await this._paymentClient.CreatePaymentAsync(paymentRequest); + PaymentResponse result = await _paymentClient.CreatePaymentAsync(paymentRequest); CustomMetadataClass metadataResponse = result.GetMetadata(); // Then: Make sure we get the same json result as metadata @@ -363,20 +363,20 @@ public async Task CanCreatePaymentWithCustomMetaDataClass() { [DefaultRetryFact] public async Task CanCreatePaymentWithMandate() { // When: We create a payment with a mandate id - MandateResponse validMandate = await this.GetFirstValidMandate(); + MandateResponse validMandate = await GetFirstValidMandate(); if (validMandate != null) { - CustomerResponse customer = await this._customerClient.GetCustomerAsync(validMandate.Links.Customer); + CustomerResponse customer = await _customerClient.GetCustomerAsync(validMandate.Links.Customer); PaymentRequest paymentRequest = new PaymentRequest() { Amount = new Amount(Currency.EUR, "100.00"), Description = "Description", - RedirectUrl = this.DefaultRedirectUrl, + RedirectUrl = DefaultRedirectUrl, SequenceType = SequenceType.Recurring, CustomerId = customer.Id, MandateId = validMandate.Id }; // When: We send the payment request to Mollie - PaymentResponse result = await this._paymentClient.CreatePaymentAsync(paymentRequest); + PaymentResponse result = await _paymentClient.CreatePaymentAsync(paymentRequest); // Then: Make sure we get the mandate id back in the details result.MandateId.Should().Be(validMandate.Id); @@ -389,11 +389,11 @@ public async Task CanCreatePaymentWithMandate() { public async Task PaymentWithDifferentHttpInstance() { // When: We create a PaymentClient with our own HttpClient instance HttpClient myHttpClientInstance = new HttpClient(); - PaymentClient paymentClient = new PaymentClient(this.ApiKey, myHttpClientInstance); + PaymentClient paymentClient = new PaymentClient(ApiKey, myHttpClientInstance); PaymentRequest paymentRequest = new PaymentRequest() { Amount = new Amount(Currency.EUR, "100.00"), Description = "Description", - RedirectUrl = this.DefaultRedirectUrl + RedirectUrl = DefaultRedirectUrl }; // When: I create a new payment @@ -412,13 +412,13 @@ public async Task CanCreatePaymentWithDecimalAmountAndRetrieveIt() { PaymentRequest paymentRequest = new PaymentRequest() { Amount = new Amount(Currency.EUR, 100.1235m), Description = "Description", - RedirectUrl = this.DefaultRedirectUrl, + RedirectUrl = DefaultRedirectUrl, Locale = Locale.de_DE }; // When: We send the payment request to Mollie and attempt to retrieve it - PaymentResponse paymentResponse = await this._paymentClient.CreatePaymentAsync(paymentRequest); - PaymentResponse result = await this._paymentClient.GetPaymentAsync(paymentResponse.Id); + PaymentResponse paymentResponse = await _paymentClient.CreatePaymentAsync(paymentRequest); + PaymentResponse result = await _paymentClient.GetPaymentAsync(paymentResponse.Id); // Then result.Should().NotBeNull(); @@ -436,13 +436,13 @@ public async Task CanCreatePaymentWithImplicitAmountCastAndRetrieveIt() { PaymentRequest paymentRequest = new PaymentRequest() { Amount = new Amount(Currency.EUR, initialAmount), Description = "Description", - RedirectUrl = this.DefaultRedirectUrl, + RedirectUrl = DefaultRedirectUrl, Locale = Locale.de_DE }; // When: We send the payment request to Mollie and attempt to retrieve it - PaymentResponse paymentResponse = await this._paymentClient.CreatePaymentAsync(paymentRequest); - PaymentResponse result = await this._paymentClient.GetPaymentAsync(paymentResponse.Id); + PaymentResponse paymentResponse = await _paymentClient.CreatePaymentAsync(paymentRequest); + PaymentResponse result = await _paymentClient.GetPaymentAsync(paymentResponse.Id); decimal responseAmount = paymentResponse.Amount; // Implicit cast decimal resultAmount = result.Amount; // Implicit cast @@ -497,11 +497,11 @@ public async Task CanCreatePaymentWithManualCaptureMode() { PaymentRequest paymentRequest = new PaymentRequest() { Amount = new Amount(Currency.EUR, 10m), Description = "Description", - RedirectUrl = this.DefaultRedirectUrl, + RedirectUrl = DefaultRedirectUrl, Method = PaymentMethod.CreditCard, CaptureMode = CaptureMode.Manual }; - + // When PaymentResponse paymentResponse = await _paymentClient.CreatePaymentAsync(paymentRequest); // Perform payment before API call @@ -516,18 +516,18 @@ public async Task CanCreatePaymentWithManualCaptureMode() { paymentRequest.CaptureMode.Should().Be(CaptureMode.Manual); paymentResponse.CaptureBefore.Should().NotBeNull(); } - + [DefaultRetryFact] public async Task CanCreatePaymentWithCaptureDelay() { // Given PaymentRequest paymentRequest = new PaymentRequest() { Amount = new Amount(Currency.EUR, 10m), Description = "Description", - RedirectUrl = this.DefaultRedirectUrl, + RedirectUrl = DefaultRedirectUrl, Method = PaymentMethod.CreditCard, CaptureDelay = "2 days" }; - + // When PaymentResponse paymentResponse = await _paymentClient.CreatePaymentAsync(paymentRequest); @@ -536,10 +536,10 @@ public async Task CanCreatePaymentWithCaptureDelay() { } private async Task GetFirstValidMandate() { - ListResponse customers = await this._customerClient.GetCustomerListAsync(); + ListResponse customers = await _customerClient.GetCustomerListAsync(); foreach (CustomerResponse customer in customers.Items) { - ListResponse customerMandates = await this._mandateClient.GetMandateListAsync(customer.Id); + ListResponse customerMandates = await _mandateClient.GetMandateListAsync(customer.Id); MandateResponse firstValidMandate = customerMandates.Items.FirstOrDefault(x => x.Status == MandateStatus.Valid); if (firstValidMandate != null) { return firstValidMandate; @@ -562,4 +562,4 @@ public void Dispose() public class CustomMetadataClass { public int OrderId { get; set; } public string Description { get; set; } -} \ No newline at end of file +} diff --git a/tests/Mollie.Tests.Integration/Api/ProfileTests.cs b/tests/Mollie.Tests.Integration/Api/ProfileTests.cs index d380dc81..2bac36a4 100644 --- a/tests/Mollie.Tests.Integration/Api/ProfileTests.cs +++ b/tests/Mollie.Tests.Integration/Api/ProfileTests.cs @@ -13,21 +13,21 @@ using Mollie.Api.Models; using Mollie.Api.Models.Profile.Request; -namespace Mollie.Tests.Integration.Api; +namespace Mollie.Tests.Integration.Api; public class ProfileTests : BaseMollieApiTestClass, IDisposable { private readonly IProfileClient _profileClient; public ProfileTests() { - _profileClient = new ProfileClient(this.ApiKey); + _profileClient = new ProfileClient(ApiKey); } - + [DefaultRetryFact] public async Task GetCurrentProfileAsync_ReturnsCurrentProfile() { // Given // When: We retrieve the current profile from the mollie API - ProfileResponse profileResponse = await this._profileClient.GetCurrentProfileAsync(); + ProfileResponse profileResponse = await _profileClient.GetCurrentProfileAsync(); // Then: Make sure we get a valid response profileResponse.Should().NotBeNull(); @@ -41,7 +41,7 @@ public async Task EnablePaymentMethodAsync_WhenEnablingPaymentMethodForCurrentPr // Given // When: We enable a payment method for the current profile - PaymentMethodResponse paymentMethodResponse = await this._profileClient.EnablePaymentMethodAsync(PaymentMethod.CreditCard); + PaymentMethodResponse paymentMethodResponse = await _profileClient.EnablePaymentMethodAsync(PaymentMethod.CreditCard); // Then: Make sure a payment method is returned paymentMethodResponse.Should().NotBeNull(); @@ -64,7 +64,7 @@ public async Task EnablePaymentMethodAsync_WhenEnablingPaymentMethodForProfile_P paymentMethodResponse.Id.Should().NotBeNullOrEmpty(); } } - + [DefaultRetryFact(Skip = "We can only test this in debug mode, because we need to retrieve a oauth access token to test this method")] public async Task CreateProfileAsync_WithDefaultParameters_CreatesProfile() { // Given @@ -90,7 +90,7 @@ public async Task DisablePaymentMethodAsync_WhenDisablingPaymentMethodForCurrent // Given // When: We disable a payment method for the current profile - await this._profileClient.DisablePaymentMethodAsync(PaymentMethod.CreditCard); + await _profileClient.DisablePaymentMethodAsync(PaymentMethod.CreditCard); // Then } @@ -100,7 +100,7 @@ public async Task DisableGiftCardIssuerAsync_WhenDisablingGiftCardIssuerForCurre // Given // When: We disable a issuer method for the current profile - await this._profileClient.DisableGiftCardIssuerAsync("festivalcadeau"); + await _profileClient.DisableGiftCardIssuerAsync("festivalcadeau"); // Then } @@ -109,4 +109,4 @@ public void Dispose() { _profileClient?.Dispose(); } -} \ No newline at end of file +} diff --git a/tests/Mollie.Tests.Integration/Api/RefundTests.cs b/tests/Mollie.Tests.Integration/Api/RefundTests.cs index d16cfb1a..25bd4f8e 100644 --- a/tests/Mollie.Tests.Integration/Api/RefundTests.cs +++ b/tests/Mollie.Tests.Integration/Api/RefundTests.cs @@ -11,32 +11,32 @@ using Mollie.Api.Models.Refund; using Mollie.Tests.Integration.Framework; -namespace Mollie.Tests.Integration.Api; +namespace Mollie.Tests.Integration.Api; public class RefundTests : BaseMollieApiTestClass, IDisposable { private readonly IRefundClient _refundClient; private readonly IPaymentClient _paymentClient; public RefundTests() { - _refundClient = new RefundClient(this.ApiKey); - _paymentClient = new PaymentClient(this.ApiKey); + _refundClient = new RefundClient(ApiKey); + _paymentClient = new PaymentClient(ApiKey); } - + [DefaultRetryFact(Skip = "We can only test this in debug mode, because we actually have to use the PaymentUrl to make the payment, since Mollie can only refund payments that have been paid")] public async Task CanCreateRefund() { // If: We create a payment string amount = "100.00"; - PaymentResponse payment = await this.CreatePayment(amount); + PaymentResponse payment = await CreatePayment(amount); - // We can only test this if you make the payment using the payment.Links.Checkout property. + // We can only test this if you make the payment using the payment.Links.Checkout property. // If you don't do this, this test will fail because we can only refund payments that have been paid - Debugger.Break(); + Debugger.Break(); // When: We attempt to refund this payment RefundRequest refundRequest = new RefundRequest() { Amount = new Amount(Currency.EUR, amount) }; - RefundResponse refundResponse = await this._refundClient.CreateRefundAsync(payment.Id, refundRequest); + RefundResponse refundResponse = await _refundClient.CreateRefundAsync(payment.Id, refundRequest); // Then refundResponse.Should().NotBeNull(); @@ -45,9 +45,9 @@ public async Task CanCreateRefund() { [DefaultRetryFact(Skip = "We can only test this in debug mode, because we actually have to use the PaymentUrl to make the payment, since Mollie can only refund payments that have been paid")] public async Task CanCreatePartialRefund() { // If: We create a payment of 250 euro - PaymentResponse payment = await this.CreatePayment("250.00"); + PaymentResponse payment = await CreatePayment("250.00"); - // We can only test this if you make the payment using the payment.Links.PaymentUrl property. + // We can only test this if you make the payment using the payment.Links.PaymentUrl property. // If you don't do this, this test will fail because we can only refund payments that have been paid Debugger.Break(); @@ -55,7 +55,7 @@ public async Task CanCreatePartialRefund() { RefundRequest refundRequest = new RefundRequest() { Amount = new Amount(Currency.EUR, "50.00") }; - RefundResponse refundResponse = await this._refundClient.CreateRefundAsync(payment.Id, refundRequest); + RefundResponse refundResponse = await _refundClient.CreateRefundAsync(payment.Id, refundRequest); // Then refundResponse.Amount.Should().Be(refundRequest.Amount); @@ -64,18 +64,18 @@ public async Task CanCreatePartialRefund() { [DefaultRetryFact(Skip = "We can only test this in debug mode, because we actually have to use the PaymentUrl to make the payment, since Mollie can only refund payments that have been paid")] public async Task CanRetrieveSingleRefund() { // If: We create a payment - PaymentResponse payment = await this.CreatePayment(); - // We can only test this if you make the payment using the payment.Links.PaymentUrl property. + PaymentResponse payment = await CreatePayment(); + // We can only test this if you make the payment using the payment.Links.PaymentUrl property. // If you don't do this, this test will fail because we can only refund payments that have been paid Debugger.Break(); RefundRequest refundRequest = new RefundRequest() { Amount = new Amount(Currency.EUR, "50.00") }; - RefundResponse refundResponse = await this._refundClient.CreateRefundAsync(payment.Id, refundRequest); + RefundResponse refundResponse = await _refundClient.CreateRefundAsync(payment.Id, refundRequest); // When: We attempt to retrieve this refund - RefundResponse result = await this._refundClient.GetRefundAsync(payment.Id, refundResponse.Id); + RefundResponse result = await _refundClient.GetRefundAsync(payment.Id, refundResponse.Id); // Then result.Should().NotBeNull(); @@ -86,10 +86,10 @@ public async Task CanRetrieveSingleRefund() { [DefaultRetryFact] public async Task CanRetrieveRefundList() { // If: We create a payment - PaymentResponse payment = await this.CreatePayment(); + PaymentResponse payment = await CreatePayment(); // When: Retrieve refund list for this payment - ListResponse refundList = await this._refundClient.GetRefundListAsync(payment.Id); + ListResponse refundList = await _refundClient.GetRefundListAsync(payment.Id); // Then refundList.Should().NotBeNull(); @@ -100,11 +100,11 @@ public async Task CanRetrieveRefundList() { public async Task CanCreateRefundWithMetaData() { // If: We create a payment string amount = "100.00"; - PaymentResponse payment = await this.CreatePayment(amount); + PaymentResponse payment = await CreatePayment(amount); - // We can only test this if you make the payment using the payment.Links.Checkout property. + // We can only test this if you make the payment using the payment.Links.Checkout property. // If you don't do this, this test will fail because we can only refund payments that have been paid - Debugger.Break(); + Debugger.Break(); // When: We attempt to refund this payment with meta data. var metadata = "this is my metadata"; @@ -112,12 +112,12 @@ public async Task CanCreateRefundWithMetaData() { Amount = new Amount(Currency.EUR, amount), Metadata = metadata }; - RefundResponse refundResponse = await this._refundClient.CreateRefundAsync(payment.Id, refundRequest); + RefundResponse refundResponse = await _refundClient.CreateRefundAsync(payment.Id, refundRequest); // Then: Make sure we get the same json result as metadata refundResponse.Metadata.Should().Be(metadata); } - + private async Task CreatePayment(string amount = "100.00") { PaymentRequest paymentRequest = new PayPalPaymentRequest { @@ -126,7 +126,7 @@ private async Task CreatePayment(string amount = "100.00") { RedirectUrl = DefaultRedirectUrl }; - return await this._paymentClient.CreatePaymentAsync(paymentRequest); + return await _paymentClient.CreatePaymentAsync(paymentRequest); } public void Dispose() @@ -134,4 +134,4 @@ public void Dispose() _refundClient?.Dispose(); _paymentClient?.Dispose(); } -} \ No newline at end of file +} diff --git a/tests/Mollie.Tests.Integration/Api/ShipmentTests.cs b/tests/Mollie.Tests.Integration/Api/ShipmentTests.cs index 286d534f..109d3936 100644 --- a/tests/Mollie.Tests.Integration/Api/ShipmentTests.cs +++ b/tests/Mollie.Tests.Integration/Api/ShipmentTests.cs @@ -8,22 +8,22 @@ using Mollie.Api.Models.Shipment; using Mollie.Tests.Integration.Framework; -namespace Mollie.Tests.Integration.Api; +namespace Mollie.Tests.Integration.Api; public class ShipmentTests : BaseMollieApiTestClass, IDisposable { private readonly IShipmentClient _shipmentClient; public ShipmentTests() { - _shipmentClient = new ShipmentClient(this.ApiKey); + _shipmentClient = new ShipmentClient(ApiKey); } - + [DefaultRetryFact(Skip = "For manual testing only")] public async Task CanCreateShipmentWithOnlyRequiredFields() { // the order needs to be autorized to do a shipment on. this can only be done by waiting. string validOrderId = "XXXXX"; - ShipmentRequest shipmentRequest = this.CreateShipmentWithOnlyRequiredFields(); - ShipmentResponse result = await this._shipmentClient.CreateShipmentAsync(validOrderId, shipmentRequest); - + ShipmentRequest shipmentRequest = CreateShipmentWithOnlyRequiredFields(); + ShipmentResponse result = await _shipmentClient.CreateShipmentAsync(validOrderId, shipmentRequest); + // Then: Make sure we get a valid shipment response result.Should().NotBeNull(); result.CreatedAt.Should().BeAfter(DateTime.Now); @@ -32,12 +32,12 @@ public async Task CanCreateShipmentWithOnlyRequiredFields() { [DefaultRetryFact(Skip = "For manual testing only")] public async Task CanListShipmentsForOrder(){ string validOrderId = "XXXXX"; - ListResponse result = await this._shipmentClient.GetShipmentsListAsync(validOrderId); + ListResponse result = await _shipmentClient.GetShipmentsListAsync(validOrderId); result.Should().NotBeNull(); result.Count.Should().BeGreaterThan(0); } - + private ShipmentRequest CreateShipmentWithOnlyRequiredFields() { return new ShipmentRequest() { Lines = new List() @@ -48,4 +48,4 @@ public void Dispose() { _shipmentClient?.Dispose(); } -} \ No newline at end of file +} diff --git a/tests/Mollie.Tests.Integration/Api/SubscriptionTests.cs b/tests/Mollie.Tests.Integration/Api/SubscriptionTests.cs index 03400af7..91e23d9d 100644 --- a/tests/Mollie.Tests.Integration/Api/SubscriptionTests.cs +++ b/tests/Mollie.Tests.Integration/Api/SubscriptionTests.cs @@ -11,7 +11,7 @@ using Mollie.Api.Models.Subscription; using Mollie.Tests.Integration.Framework; -namespace Mollie.Tests.Integration.Api; +namespace Mollie.Tests.Integration.Api; public class SubscriptionTests : BaseMollieApiTestClass, IDisposable { private readonly ISubscriptionClient _subscriptionClient; @@ -19,18 +19,18 @@ public class SubscriptionTests : BaseMollieApiTestClass, IDisposable { private readonly IMandateClient _mandateClient; public SubscriptionTests() { - _subscriptionClient = new SubscriptionClient(this.ApiKey); - _customerClient = new CustomerClient(this.ApiKey); - _mandateClient = new MandateClient(this.ApiKey); + _subscriptionClient = new SubscriptionClient(ApiKey); + _customerClient = new CustomerClient(ApiKey); + _mandateClient = new MandateClient(ApiKey); } - + [DefaultRetryFact] public async Task CanRetrieveSubscriptionList() { // Given - string customerId = await this.GetFirstCustomerWithValidMandate(); + string customerId = await GetFirstCustomerWithValidMandate(); // When: Retrieve subscription list with default settings - ListResponse response = await this._subscriptionClient.GetSubscriptionListAsync(customerId); + ListResponse response = await _subscriptionClient.GetSubscriptionListAsync(customerId); // Then response.Should().NotBeNull(); @@ -42,7 +42,7 @@ public async Task CanRetrieveAllSubscriptionList() { // Given // When: Retrieve subscription list with default settings - ListResponse response = await this._subscriptionClient.GetAllSubscriptionList(); + ListResponse response = await _subscriptionClient.GetAllSubscriptionList(); // Then response.Should().NotBeNull(); @@ -52,11 +52,11 @@ public async Task CanRetrieveAllSubscriptionList() { [DefaultRetryFact] public async Task ListSubscriptionsNeverReturnsMoreCustomersThenTheNumberOfRequestedSubscriptions() { // Given: Number of customers requested is 5 - string customerId = await this.GetFirstCustomerWithValidMandate(); + string customerId = await GetFirstCustomerWithValidMandate(); int numberOfSubscriptions = 5; // When: Retrieve 5 subscriptions - ListResponse response = await this._subscriptionClient.GetSubscriptionListAsync(customerId, null, numberOfSubscriptions); + ListResponse response = await _subscriptionClient.GetSubscriptionListAsync(customerId, null, numberOfSubscriptions); // Then response.Items.Count.Should().BeLessOrEqualTo(numberOfSubscriptions); @@ -65,7 +65,7 @@ public async Task ListSubscriptionsNeverReturnsMoreCustomersThenTheNumberOfReque [DefaultRetryFact] public async Task CanCreateSubscription() { // Given - string customerId = await this.GetFirstCustomerWithValidMandate(); + string customerId = await GetFirstCustomerWithValidMandate(); SubscriptionRequest subscriptionRequest = new SubscriptionRequest { Amount = new Amount(Currency.EUR, "100.00"), Times = 5, @@ -74,7 +74,7 @@ public async Task CanCreateSubscription() { WebhookUrl = "http://www.google.nl", StartDate = DateTime.Now.AddDays(1) }; - + // When SubscriptionResponse subscriptionResponse = await _subscriptionClient.CreateSubscriptionAsync(customerId, subscriptionRequest); @@ -90,15 +90,15 @@ public async Task CanCreateSubscription() { [DefaultRetryFact] public async Task CanCancelSubscription() { // Given - string customerId = await this.GetFirstCustomerWithValidMandate(); - ListResponse subscriptions = await this._subscriptionClient.GetSubscriptionListAsync(customerId); + string customerId = await GetFirstCustomerWithValidMandate(); + ListResponse subscriptions = await _subscriptionClient.GetSubscriptionListAsync(customerId); // When SubscriptionResponse subscriptionToCancel = subscriptions.Items .FirstOrDefault(s => s.Status != SubscriptionStatus.Canceled); if (subscriptionToCancel != null) { - await this._subscriptionClient.CancelSubscriptionAsync(customerId, subscriptionToCancel.Id); - SubscriptionResponse cancelledSubscription = await this._subscriptionClient.GetSubscriptionAsync(customerId, subscriptionToCancel.Id); + await _subscriptionClient.CancelSubscriptionAsync(customerId, subscriptionToCancel.Id); + SubscriptionResponse cancelledSubscription = await _subscriptionClient.GetSubscriptionAsync(customerId, subscriptionToCancel.Id); // Then cancelledSubscription.Status.Should().Be(SubscriptionStatus.Canceled); @@ -107,9 +107,9 @@ public async Task CanCancelSubscription() { [DefaultRetryFact] public async Task CanUpdateSubscription() { - // Given - string customerId = await this.GetFirstCustomerWithValidMandate(); - ListResponse subscriptions = await this._subscriptionClient.GetSubscriptionListAsync(customerId); + // Given + string customerId = await GetFirstCustomerWithValidMandate(); + ListResponse subscriptions = await _subscriptionClient.GetSubscriptionListAsync(customerId); // When SubscriptionResponse subscriptionToUpdate = subscriptions.Items @@ -118,7 +118,7 @@ public async Task CanUpdateSubscription() { SubscriptionUpdateRequest request = new SubscriptionUpdateRequest() { Description = $"Updated subscription {Guid.NewGuid()}" }; - SubscriptionResponse response = await this._subscriptionClient.UpdateSubscriptionAsync(customerId, subscriptionToUpdate.Id, request); + SubscriptionResponse response = await _subscriptionClient.UpdateSubscriptionAsync(customerId, subscriptionToUpdate.Id, request); // Then response.Description.Should().Be(request.Description); @@ -129,7 +129,7 @@ public async Task CanUpdateSubscription() { public async Task CanCreateSubscriptionWithMetaData() { // If: We create a subscription with meta data string json = "{\"order_id\":\"4.40\"}"; - string customerId = await this.GetFirstCustomerWithValidMandate(); + string customerId = await GetFirstCustomerWithValidMandate(); if (customerId != null) { SubscriptionRequest subscriptionRequest = new SubscriptionRequest { Amount = new Amount(Currency.EUR, "100.00"), @@ -150,10 +150,10 @@ public async Task CanCreateSubscriptionWithMetaData() { } private async Task GetFirstCustomerWithValidMandate() { - ListResponse customers = await this._customerClient.GetCustomerListAsync(); - + ListResponse customers = await _customerClient.GetCustomerListAsync(); + foreach (CustomerResponse customer in customers.Items) { - ListResponse mandates = await this._mandateClient.GetMandateListAsync(customer.Id); + ListResponse mandates = await _mandateClient.GetMandateListAsync(customer.Id); if (mandates.Items.Any(x => x.Status == MandateStatus.Valid)) { return customer.Id; } @@ -168,4 +168,4 @@ public void Dispose() _customerClient?.Dispose(); _mandateClient?.Dispose(); } -} \ No newline at end of file +} diff --git a/tests/Mollie.Tests.Integration/Api/TerminalTests.cs b/tests/Mollie.Tests.Integration/Api/TerminalTests.cs index 42773da0..4df93dd0 100644 --- a/tests/Mollie.Tests.Integration/Api/TerminalTests.cs +++ b/tests/Mollie.Tests.Integration/Api/TerminalTests.cs @@ -8,15 +8,15 @@ using Mollie.Api.Models.Terminal; using Mollie.Tests.Integration.Framework; -namespace Mollie.Tests.Integration.Api; +namespace Mollie.Tests.Integration.Api; public class TerminalTests : BaseMollieApiTestClass, IDisposable { private readonly ITerminalClient _terminalClient; public TerminalTests() { - _terminalClient = new TerminalClient(this.ApiKey); + _terminalClient = new TerminalClient(ApiKey); } - + [DefaultRetryFact] public async Task CanRetrieveTerminalList() { // Given @@ -49,4 +49,4 @@ public void Dispose() { _terminalClient?.Dispose(); } -} \ No newline at end of file +} diff --git a/tests/Mollie.Tests.Integration/Framework/BaseMollieApiTestClass.cs b/tests/Mollie.Tests.Integration/Framework/BaseMollieApiTestClass.cs index e672b75b..a2feabe6 100644 --- a/tests/Mollie.Tests.Integration/Framework/BaseMollieApiTestClass.cs +++ b/tests/Mollie.Tests.Integration/Framework/BaseMollieApiTestClass.cs @@ -9,12 +9,12 @@ public abstract class BaseMollieApiTestClass { protected readonly string DefaultRedirectUrl = "http://mysite.com"; protected readonly string DefaultWebhookUrl = "http://mysite.com/webhook"; protected readonly MollieOptions Configuration = ConfigurationFactory.GetConfiguration().GetSection("Mollie").Get(); - protected string ApiKey => this.Configuration.ApiKey; - protected string ClientId => this.Configuration.ClientId ?? "client-id"; - protected string ClientSecret => this.Configuration.ClientSecret ?? "client-secret"; + protected string ApiKey => Configuration.ApiKey; + protected string ClientId => Configuration.ClientId ?? "client-id"; + protected string ClientSecret => Configuration.ClientSecret ?? "client-secret"; protected BaseMollieApiTestClass() { - this.EnsureTestApiKey(this.ApiKey); + EnsureTestApiKey(ApiKey); // Mollie returns a 429 response code (Too many requests) if we send a lot of requests in a short timespan. // In order to avoid hitting their rate limit, we add a small delay between each tests. diff --git a/tests/Mollie.Tests.Unit/Client/BalanceClientTests.cs b/tests/Mollie.Tests.Unit/Client/BalanceClientTests.cs index bd2b5a19..1d142999 100644 --- a/tests/Mollie.Tests.Unit/Client/BalanceClientTests.cs +++ b/tests/Mollie.Tests.Unit/Client/BalanceClientTests.cs @@ -21,7 +21,7 @@ public async Task GetBalanceAsync_DefaultBehaviour_ResponseIsParsed() { var getBalanceResponseFactory = new GetBalanceResponseFactory(); var getBalanceResponse = getBalanceResponseFactory.CreateGetBalanceResponse(); string expectedUrl = $"{BaseMollieClient.ApiEndPoint}balances/{getBalanceResponseFactory.BalanceId}"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, expectedUrl, getBalanceResponse); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, expectedUrl, getBalanceResponse); HttpClient httpClient = mockHttp.ToHttpClient(); BalanceClient balanceClient = new BalanceClient("api-key", httpClient); @@ -53,7 +53,7 @@ public async Task GetBalanceAsync_DefaultBehaviour_ResponseIsParsed() { balanceResponse.Links.Documentation.Href.Should().Be($"https://docs.mollie.com/reference/v2/balances-api/get-balance"); balanceResponse.Links.Documentation.Type.Should().Be("text/html"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -77,7 +77,7 @@ public async Task GetPrimaryBalanceAsync_DefaultBehaviour_ResponseIsParsed() { var getBalanceResponseFactory = new GetBalanceResponseFactory(); var getBalanceResponse = getBalanceResponseFactory.CreateGetBalanceResponse(); string expectedUrl = $"{BaseMollieClient.ApiEndPoint}balances/primary"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, expectedUrl, getBalanceResponse); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, expectedUrl, getBalanceResponse); HttpClient httpClient = mockHttp.ToHttpClient(); BalanceClient balanceClient = new BalanceClient("api-key", httpClient); @@ -110,7 +110,7 @@ public async Task GetPrimaryBalanceAsync_DefaultBehaviour_ResponseIsParsed() { public async Task ListBalancesAsync_DefaultBehaviour_ResponseIsParsed() { // Given: We request a list of balances string expectedUrl = $"{BaseMollieClient.ApiEndPoint}balances"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, expectedUrl, DefaultListBalancesResponse); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, expectedUrl, DefaultListBalancesResponse); HttpClient httpClient = mockHttp.ToHttpClient(); BalanceClient balanceClient = new BalanceClient("api-key", httpClient); @@ -123,7 +123,7 @@ public async Task ListBalancesAsync_DefaultBehaviour_ResponseIsParsed() { balances.Count.Should().Be(2); balances.Items.Should().HaveCount(2); } - + [Fact] public async Task GetBalanceReportAsync_TransactionCategories_ResponseIsParsed() { // Given: We request a balance report @@ -131,10 +131,10 @@ public async Task GetBalanceReportAsync_TransactionCategories_ResponseIsParsed() DateTime from = new DateTime(2022, 11, 1); DateTime until = new DateTime(2022, 11, 30); string grouping = ReportGrouping.TransactionCategories; - + string expectedUrl = $"{BaseMollieClient.ApiEndPoint}balances/{balanceId}/report" + $"?from={from.ToString("yyyy-MM-dd")}&until={until.ToString("yyyy-MM-dd")}&grouping={grouping}"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, expectedUrl, DefaultGetBalanceReportTransactionCategoriesResponse); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, expectedUrl, DefaultGetBalanceReportTransactionCategoriesResponse); HttpClient httpClient = mockHttp.ToHttpClient(); BalanceClient balanceClient = new BalanceClient("api-key", httpClient); @@ -162,7 +162,7 @@ public async Task GetBalanceReportAsync_TransactionCategories_ResponseIsParsed() var childChildSubTotals = childSubTotals.Subtotals.First(); childChildSubTotals.Method.Should().Be("ideal"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -181,7 +181,7 @@ public async Task GetBalanceReportAsync_NoBalanceIdIsGiven_ArgumentExceptionIsTh // Then exception.Message.Should().Be("Required URL argument 'balanceId' is null or empty"); } - + [Fact] public async Task GetBalanceReportAsync_StatusBalances_ResponseIsParsed() { // Given: We request a balance report @@ -189,10 +189,10 @@ public async Task GetBalanceReportAsync_StatusBalances_ResponseIsParsed() { DateTime from = new DateTime(2022, 11, 1); DateTime until = new DateTime(2022, 11, 30); string grouping = ReportGrouping.StatusBalances; - + string expectedUrl = $"{BaseMollieClient.ApiEndPoint}balances/{balanceId}/report" + $"?from={from.ToString("yyyy-MM-dd")}&until={until.ToString("yyyy-MM-dd")}&grouping={grouping}"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, expectedUrl, DefaultGetBalanceReportStatusBalancesResponse); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, expectedUrl, DefaultGetBalanceReportStatusBalancesResponse); HttpClient httpClient = mockHttp.ToHttpClient(); BalanceClient balanceClient = new BalanceClient("api-key", httpClient); @@ -219,13 +219,13 @@ public async Task GetBalanceReportAsync_StatusBalances_ResponseIsParsed() { var childChildSubtotals = childSubTotals.Subtotals.First(); childChildSubtotals.Method.Should().Be("ideal"); } - + [Fact] public async Task ListBalanceTransactionsAsync_StatusBalances_ResponseIsParsed() { // Given string balanceId = "bal_CKjKwQdjCwCSArXFAJNFH"; string expectedUrl = $"{BaseMollieClient.ApiEndPoint}balances/{balanceId}/transactions"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, expectedUrl, DefaultListBalanceTransactionsResponse); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, expectedUrl, DefaultListBalanceTransactionsResponse); HttpClient httpClient = mockHttp.ToHttpClient(); BalanceClient balanceClient = new BalanceClient("api-key", httpClient); @@ -249,7 +249,7 @@ public async Task ListBalanceTransactionsAsync_StatusBalances_ResponseIsParsed() transactionContext.Context.SettlementId.Should().Be("stl_ma2vu8"); transactionContext.Context.TransferId.Should().Be("trf_ma2vu8"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -266,12 +266,12 @@ public async Task ListBalanceTransactionsAsync_NoBalanceIdIsGiven_ArgumentExcept // Then exception.Message.Should().Be("Required URL argument 'balanceId' is null or empty"); } - + [Fact] public async Task ListPrimaryBalanceTransactionsAsync_StatusBalances_ResponseIsParsed() { // Given string expectedUrl = $"{BaseMollieClient.ApiEndPoint}balances/primary/transactions"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, expectedUrl, DefaultListBalanceTransactionsResponse); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, expectedUrl, DefaultListBalanceTransactionsResponse); HttpClient httpClient = mockHttp.ToHttpClient(); BalanceClient balanceClient = new BalanceClient("api-key", httpClient); @@ -340,7 +340,7 @@ public async Task ListPrimaryBalanceTransactionsAsync_StatusBalances_ResponseIsP } } }"; - + private readonly string DefaultListBalancesResponse = $@"{{ ""count"": 2, ""_embedded"": {{ @@ -1244,4 +1244,4 @@ public string CreateGetBalanceResponse() { } } } -} \ No newline at end of file +} diff --git a/tests/Mollie.Tests.Unit/Client/CaptureClientTests.cs b/tests/Mollie.Tests.Unit/Client/CaptureClientTests.cs index 99386d96..e667c5a6 100644 --- a/tests/Mollie.Tests.Unit/Client/CaptureClientTests.cs +++ b/tests/Mollie.Tests.Unit/Client/CaptureClientTests.cs @@ -73,7 +73,7 @@ public async Task GetCaptureAsync_CorrectQueryParametersAreAdded(bool testmode, // Given: We make a request to retrieve a capture const string paymentId = "payment-id"; const string captureId = "capture-id"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}payments/{paymentId}/captures/{captureId}{expectedQueryString}", defaultCaptureJsonResponse); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}payments/{paymentId}/captures/{captureId}{expectedQueryString}", defaultCaptureJsonResponse); HttpClient httpClient = mockHttp.ToHttpClient(); CaptureClient captureClient = new CaptureClient("abcde", httpClient); @@ -83,14 +83,14 @@ public async Task GetCaptureAsync_CorrectQueryParametersAreAdded(bool testmode, // Then mockHttp.VerifyNoOutstandingRequest(); } - + [Theory] [InlineData(true, "?testmode=true")] [InlineData(false, "")] public async Task GetCapturesListAsync_CorrectQueryParametersAreAdded(bool testmode, string expectedQueryString) { // Given: We make a request to retrieve a capture const string paymentId = "payment-id"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}payments/{paymentId}/captures{expectedQueryString}", defaultCaptureJsonResponse); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}payments/{paymentId}/captures{expectedQueryString}", defaultCaptureJsonResponse); HttpClient httpClient = mockHttp.ToHttpClient(); CaptureClient captureClient = new CaptureClient("abcde", httpClient); @@ -100,12 +100,12 @@ public async Task GetCapturesListAsync_CorrectQueryParametersAreAdded(bool testm // Then mockHttp.VerifyNoOutstandingRequest(); } - + [Fact] public async Task GetCaptureAsync_DefaultBehaviour_ResponseIsParsed() { // Given: We request a capture with a payment id and capture id string expectedUrl = $"{BaseMollieClient.ApiEndPoint}payments/{defaultPaymentId}/captures/{defaultCaptureId}"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, expectedUrl, defaultCaptureJsonResponse); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, expectedUrl, defaultCaptureJsonResponse); HttpClient httpClient = mockHttp.ToHttpClient(); CaptureClient captureClient = new CaptureClient("api-key", httpClient); @@ -127,7 +127,7 @@ public async Task GetCaptureAsync_DefaultBehaviour_ResponseIsParsed() { public async Task GetCapturesListAsync_DefaultBehaviour_ResponseIsParsed() { // Given: We request a list of captures string expectedUrl = $"{BaseMollieClient.ApiEndPoint}payments/{defaultPaymentId}/captures"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, expectedUrl, defaultCaptureListJsonResponse); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, expectedUrl, defaultCaptureListJsonResponse); HttpClient httpClient = mockHttp.ToHttpClient(); CaptureClient captureClient = new CaptureClient("api-key", httpClient); @@ -146,7 +146,7 @@ public async Task GetCapturesListAsync_DefaultBehaviour_ResponseIsParsed() { captureResponse.Amount.Currency.Should().Be(defaultAmountCurrency); captureResponse.Status.Should().Be(defaultStatus); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -163,7 +163,7 @@ public async Task GetCaptureAsync_NoPaymentIdIsGiven_ArgumentExceptionIsThrown(s // Then exception.Message.Should().Be("Required URL argument 'paymentId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -180,7 +180,7 @@ public async Task GetCaptureAsync_NoCaptureIdIsGiven_ArgumentExceptionIsThrown(s // Then exception.Message.Should().Be("Required URL argument 'captureId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -197,7 +197,7 @@ public async Task GetCapturesListAsync_NoPaymentIdIsGiven_ArgumentExceptionIsThr // Then exception.Message.Should().Be("Required URL argument 'paymentId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -226,13 +226,13 @@ public async Task CreateCapture_CaptureIsCreated_CaptureIsDeserialized() { Amount = new Amount(defaultAmountCurrency, defaultAmountValue), Description = "capture-description" }; - var mockHttp = this.CreateMockHttpMessageHandler( - HttpMethod.Post, - $"{BaseMollieClient.ApiEndPoint}payments/{defaultPaymentId}/captures", + var mockHttp = CreateMockHttpMessageHandler( + HttpMethod.Post, + $"{BaseMollieClient.ApiEndPoint}payments/{defaultPaymentId}/captures", defaultCaptureJsonResponse); HttpClient httpClient = mockHttp.ToHttpClient(); CaptureClient captureClient = new CaptureClient("abcde", httpClient); - + // When CaptureResponse response = await captureClient.CreateCapture(defaultPaymentId, captureRequest); diff --git a/tests/Mollie.Tests.Unit/Client/CustomerClientTests.cs b/tests/Mollie.Tests.Unit/Client/CustomerClientTests.cs index 0b9fc96e..b881aba1 100644 --- a/tests/Mollie.Tests.Unit/Client/CustomerClientTests.cs +++ b/tests/Mollie.Tests.Unit/Client/CustomerClientTests.cs @@ -17,7 +17,7 @@ public class CustomerClientTests : BaseClientTests { public async Task GetCustomerAsync_TestModeParameterCase_QueryStringOnlyContainsTestModeParameterIfTrue(string expectedUrl, bool testModeParameter) { // Given: We retrieve a customer const string customerId = "customer-id"; - + var mockHttp = new MockHttpMessageHandler(); mockHttp.When($"{BaseMollieClient.ApiEndPoint}{expectedUrl}") .Respond("application/json", DefaultCustomerJsonToReturn); @@ -31,7 +31,7 @@ public async Task GetCustomerAsync_TestModeParameterCase_QueryStringOnlyContains mockHttp.VerifyNoOutstandingExpectation(); customerResponse.Should().NotBeNull(); } - + [Theory] [InlineData(null, null, false, "")] [InlineData("from", null, false, "?from=from")] @@ -52,7 +52,7 @@ public async Task GetCustomerListAsync_TestModeParameterCase_QueryStringOnlyCont mockHttp.VerifyNoOutstandingExpectation(); result.Should().NotBeNull(); } - + [Theory] [InlineData(null, null, null, false, "")] [InlineData("from", null, null, false, "?from=from")] @@ -75,13 +75,13 @@ public async Task GetCustomerPaymentListAsync_TestModeParameterCase_QueryStringO mockHttp.VerifyNoOutstandingExpectation(); result.Should().NotBeNull(); } - + [Fact] public async Task DeleteCustomerAsync_TestmodeIsTrue_RequestContainsTestmodeModel() { // Given: We make a request to retrieve a payment with embedded refunds const string customerId = "customer-id"; string expectedContent = "\"testmode\":true"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Delete, $"{BaseMollieClient.ApiEndPoint}customers/{customerId}", DefaultCustomerJsonToReturn, expectedContent); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Delete, $"{BaseMollieClient.ApiEndPoint}customers/{customerId}", DefaultCustomerJsonToReturn, expectedContent); HttpClient httpClient = mockHttp.ToHttpClient(); CustomerClient customerClient = new CustomerClient("abcde", httpClient); @@ -91,7 +91,7 @@ public async Task DeleteCustomerAsync_TestmodeIsTrue_RequestContainsTestmodeMode // Then mockHttp.VerifyNoOutstandingExpectation(); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -108,7 +108,7 @@ public async Task UpdateCustomerAsync_NoCustomerIdIsGiven_ArgumentExceptionIsThr // Then exception.Message.Should().Be("Required URL argument 'customerId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -125,7 +125,7 @@ public async Task DeleteCustomerAsync_NoCustomerIdIsGiven_ArgumentExceptionIsThr // Then exception.Message.Should().Be("Required URL argument 'customerId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -142,7 +142,7 @@ public async Task GetCustomerAsync_NoCustomerIdIsGiven_ArgumentExceptionIsThrown // Then exception.Message.Should().Be("Required URL argument 'customerId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -159,7 +159,7 @@ public async Task GetCustomerPaymentListAsync_NoCustomerIdIsGiven_ArgumentExcept // Then exception.Message.Should().Be("Required URL argument 'customerId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -190,7 +190,7 @@ public async Task CreateCustomerPayment_NoCustomerIdIsGiven_ArgumentExceptionIsT ""email"": ""customer@example.org"", ""locale"": ""nl_NL"", ""metadata"": null, - ""createdAt"": ""2018-04-06T13:23:21.0Z"" + ""createdAt"": ""2018-04-06T13:23:21.0Z"" }"; } -} \ No newline at end of file +} diff --git a/tests/Mollie.Tests.Unit/Client/MandateClientTests.cs b/tests/Mollie.Tests.Unit/Client/MandateClientTests.cs index 9d114a01..f4abc958 100644 --- a/tests/Mollie.Tests.Unit/Client/MandateClientTests.cs +++ b/tests/Mollie.Tests.Unit/Client/MandateClientTests.cs @@ -17,7 +17,7 @@ public async Task GetMandateAsync_TestModeParameterCase_QueryStringOnlyContainsT // Given: We retrieve a mandate const string customerId = "customer-id"; const string mandateId = "mandate-id"; - + var mockHttp = new MockHttpMessageHandler(); mockHttp.When($"{BaseMollieClient.ApiEndPoint}{expectedUrl}") .Respond("application/json", DefaultMandateJsonToReturn); @@ -31,7 +31,7 @@ public async Task GetMandateAsync_TestModeParameterCase_QueryStringOnlyContainsT mockHttp.VerifyNoOutstandingExpectation(); result.Should().NotBeNull(); } - + [Theory] [InlineData(null, null, false, "")] [InlineData("from", null, false, "?from=from")] @@ -53,17 +53,17 @@ public async Task GetMandateListAsync_TestModeParameterCase_QueryStringOnlyConta mockHttp.VerifyNoOutstandingExpectation(); result.Should().NotBeNull(); } - + [Fact] public async Task RevokeMandate_TestmodeIsTrue_RequestContainsTestmodeModel() { // Given: We make a request to retrieve a payment with embedded refunds const string customerId = "customer-id"; const string mandateId = "mandate-id"; string expectedContent = "\"testmode\":true"; - var mockHttp = this.CreateMockHttpMessageHandler( - HttpMethod.Delete, - $"{BaseMollieClient.ApiEndPoint}customers/{customerId}/mandates/{mandateId}", - DefaultMandateJsonToReturn, + var mockHttp = CreateMockHttpMessageHandler( + HttpMethod.Delete, + $"{BaseMollieClient.ApiEndPoint}customers/{customerId}/mandates/{mandateId}", + DefaultMandateJsonToReturn, expectedContent); HttpClient httpClient = mockHttp.ToHttpClient(); MandateClient mandateClient = new MandateClient("abcde", httpClient); @@ -74,7 +74,7 @@ public async Task RevokeMandate_TestmodeIsTrue_RequestContainsTestmodeModel() { // Then mockHttp.VerifyNoOutstandingExpectation(); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -91,7 +91,7 @@ public async Task GetMandateAsync_NoCustomerIdIsGiven_ArgumentExceptionIsThrown( // Then exception.Message.Should().Be("Required URL argument 'customerId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -108,7 +108,7 @@ public async Task GetMandateAsync_NoMandateIdIsGiven_ArgumentExceptionIsThrown(s // Then exception.Message.Should().Be("Required URL argument 'mandateId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -125,7 +125,7 @@ public async Task GetMandateListAsync_NoCustomerIdIsGiven_ArgumentExceptionIsThr // Then exception.Message.Should().Be("Required URL argument 'customerId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -160,7 +160,7 @@ public async Task CreateMandateAsync_NoCustomerIdIsGiven_ArgumentExceptionIsThro }, ""mandateReference"": ""YOUR-COMPANY-MD1380"", ""signatureDate"": ""2018-05-07"", - ""createdAt"": ""2018-05-07T10:49:08+00:00"" + ""createdAt"": ""2018-05-07T10:49:08+00:00"" }"; } -} \ No newline at end of file +} diff --git a/tests/Mollie.Tests.Unit/Client/OnboardingClientTests.cs b/tests/Mollie.Tests.Unit/Client/OnboardingClientTests.cs index 4bbf6b93..97ccc106 100644 --- a/tests/Mollie.Tests.Unit/Client/OnboardingClientTests.cs +++ b/tests/Mollie.Tests.Unit/Client/OnboardingClientTests.cs @@ -28,7 +28,7 @@ public class OnboardingClientTests : BaseClientTests { public async Task GetOnboardingStatusAsync_DefaultBehaviour_ResponseIsParsed() { // Given: We request the onboarding status string expectedUrl = $"{BaseMollieClient.ApiEndPoint}onboarding/me"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, expectedUrl, defaultOnboardingStatusJsonResponse); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, expectedUrl, defaultOnboardingStatusJsonResponse); HttpClient httpClient = mockHttp.ToHttpClient(); OnboardingClient onboardingClient = new OnboardingClient("api-key", httpClient); @@ -59,7 +59,7 @@ public async Task SubmitOnboardingDataAsync_DefaultBehaviour_RequestIsParsed() { Name = defaultName } }; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Post, expectedUrl, string.Empty); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Post, expectedUrl, string.Empty); HttpClient httpClient = mockHttp.ToHttpClient(); OnboardingClient onboardingClient = new OnboardingClient("api-key", httpClient); @@ -70,4 +70,4 @@ public async Task SubmitOnboardingDataAsync_DefaultBehaviour_RequestIsParsed() { mockHttp.VerifyNoOutstandingExpectation(); } } -} \ No newline at end of file +} diff --git a/tests/Mollie.Tests.Unit/Client/OrderClientTests.cs b/tests/Mollie.Tests.Unit/Client/OrderClientTests.cs index d4551e44..2ec76bfd 100644 --- a/tests/Mollie.Tests.Unit/Client/OrderClientTests.cs +++ b/tests/Mollie.Tests.Unit/Client/OrderClientTests.cs @@ -18,7 +18,7 @@ public class OrderClientTests : BaseClientTests { public async Task GetOrderAsync_NoEmbedParameters_QueryStringIsEmpty() { // Given: We make a request to retrieve a order without wanting any extra data const string orderId = "abcde"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}orders/{orderId}", defaultOrderJsonResponse); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}orders/{orderId}", defaultOrderJsonResponse); HttpClient httpClient = mockHttp.ToHttpClient(); OrderClient orderClient = new OrderClient("abcde", httpClient); @@ -33,7 +33,7 @@ public async Task GetOrderAsync_NoEmbedParameters_QueryStringIsEmpty() { public async Task GetOrderAsync_SingleEmbedParameters_QueryStringContainsEmbedParameter() { // Given: We make a request to retrieve a order with a single embed parameter const string orderId = "abcde"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}orders/{orderId}?embed=payments", defaultOrderJsonResponse); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}orders/{orderId}?embed=payments", defaultOrderJsonResponse); HttpClient httpClient = mockHttp.ToHttpClient(); OrderClient orderClient = new OrderClient("abcde", httpClient); @@ -48,7 +48,7 @@ public async Task GetOrderAsync_SingleEmbedParameters_QueryStringContainsEmbedPa public async Task GetOrderAsync_MultipleEmbedParameters_QueryStringContainsMultipleParameters() { // Given: We make a request to retrieve a order with a single embed parameter const string orderId = "abcde"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}orders/{orderId}?embed=payments,refunds,shipments", defaultOrderJsonResponse); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}orders/{orderId}?embed=payments,refunds,shipments", defaultOrderJsonResponse); HttpClient httpClient = mockHttp.ToHttpClient(); OrderClient orderClient = new OrderClient("abcde", httpClient); @@ -58,12 +58,12 @@ public async Task GetOrderAsync_MultipleEmbedParameters_QueryStringContainsMulti // Then mockHttp.VerifyNoOutstandingExpectation(); } - + [Fact] public async Task GetOrderAsync_WithTestModeParameter_QueryStringContainsTestModeParameter() { // Given: We make a request to retrieve a order with a single embed parameter const string orderId = "abcde"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}orders/{orderId}?testmode=true", defaultOrderJsonResponse); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}orders/{orderId}?testmode=true", defaultOrderJsonResponse); HttpClient httpClient = mockHttp.ToHttpClient(); OrderClient orderClient = new OrderClient("abcde", httpClient); @@ -73,7 +73,7 @@ public async Task GetOrderAsync_WithTestModeParameter_QueryStringContainsTestMod // Then mockHttp.VerifyNoOutstandingExpectation(); } - + [Theory] [InlineData(null, null, null, false, null, "")] [InlineData("from", null, null, false, null, "?from=from")] @@ -83,14 +83,14 @@ public async Task GetOrderAsync_WithTestModeParameter_QueryStringContainsTestMod [InlineData(null, null, "profile-id", true, SortDirection.Desc, "?profileId=profile-id&testmode=true&sort=desc")] [InlineData(null, null, "profile-id", true, SortDirection.Asc, "?profileId=profile-id&testmode=true&sort=asc")] public async Task GetOrderListAsync_QueryParameterOptions_CorrectParametersAreAdded( - string from, - int? limit, - string profileId, - bool testmode, + string from, + int? limit, + string profileId, + bool testmode, SortDirection? sortDirection, string expectedQueryString) { // Given: We make a request to retrieve the list of orders - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}orders{expectedQueryString}", defaultOrderJsonResponse); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}orders{expectedQueryString}", defaultOrderJsonResponse); HttpClient httpClient = mockHttp.ToHttpClient(); OrderClient orderClient = new OrderClient("abcde", httpClient); @@ -100,7 +100,7 @@ public async Task GetOrderListAsync_QueryParameterOptions_CorrectParametersAreAd // Then mockHttp.VerifyNoOutstandingRequest(); } - + [Theory] [InlineData(null, null, false, "")] [InlineData("from", null, false, "?from=from")] @@ -109,7 +109,7 @@ public async Task GetOrderListAsync_QueryParameterOptions_CorrectParametersAreAd public async Task GetOrderRefundListAsync_QueryParameterOptions_CorrectParametersAreAdded(string from, int? limit, bool testmode, string expectedQueryString) { // Given: We make a request to retrieve the list of orders const string orderId = "abcde"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}orders/{orderId}/refunds{expectedQueryString}", defaultOrderJsonResponse); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}orders/{orderId}/refunds{expectedQueryString}", defaultOrderJsonResponse); HttpClient httpClient = mockHttp.ToHttpClient(); OrderClient orderClient = new OrderClient("abcde", httpClient); @@ -123,18 +123,18 @@ public async Task GetOrderRefundListAsync_QueryParameterOptions_CorrectParameter [Fact] public async Task CreateOrderAsync_SinglePaymentMethod_RequestIsSerializedInExpectedFormat() { // Given: we create a order with a single payment method - OrderRequest orderRequest = this.CreateOrderRequestWithOnlyRequiredFields(); + OrderRequest orderRequest = CreateOrderRequestWithOnlyRequiredFields(); orderRequest.Method = PaymentMethod.Ideal; string expectedPaymentMethodJson = $"\"method\":[\"{PaymentMethod.Ideal}"; const string jsonResponse = defaultOrderJsonResponse; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Post, $"{BaseMollieClient.ApiEndPoint}orders", jsonResponse, expectedPaymentMethodJson); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Post, $"{BaseMollieClient.ApiEndPoint}orders", jsonResponse, expectedPaymentMethodJson); HttpClient httpClient = mockHttp.ToHttpClient(); OrderClient orderClient = new OrderClient("abcde", httpClient); // When: We send the request OrderResponse orderResponse = await orderClient.CreateOrderAsync(orderRequest); - // Then + // Then mockHttp.VerifyNoOutstandingExpectation(); orderResponse.Method.Should().Be(orderRequest.Method); } @@ -142,7 +142,7 @@ public async Task CreateOrderAsync_SinglePaymentMethod_RequestIsSerializedInExpe [Fact] public async Task CreateOrderAsync_MultiplePaymentMethods_RequestIsSerializedInExpectedFormat() { // Given: we create a order with a single payment method - OrderRequest orderRequest = this.CreateOrderRequestWithOnlyRequiredFields(); + OrderRequest orderRequest = CreateOrderRequestWithOnlyRequiredFields(); orderRequest.Methods = new List() { PaymentMethod.Ideal, PaymentMethod.CreditCard, @@ -150,17 +150,17 @@ public async Task CreateOrderAsync_MultiplePaymentMethods_RequestIsSerializedInE }; string expectedPaymentMethodJson = $"\"method\":[\"{PaymentMethod.Ideal}\",\"{PaymentMethod.CreditCard}\",\"{PaymentMethod.DirectDebit}\"]"; const string jsonResponse = defaultOrderJsonResponse; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Post, $"{BaseMollieClient.ApiEndPoint}orders", jsonResponse, expectedPaymentMethodJson); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Post, $"{BaseMollieClient.ApiEndPoint}orders", jsonResponse, expectedPaymentMethodJson); HttpClient httpClient = mockHttp.ToHttpClient(); OrderClient orderClient = new OrderClient("abcde", httpClient); // When: We send the request await orderClient.CreateOrderAsync(orderRequest); - // Then + // Then mockHttp.VerifyNoOutstandingExpectation(); } - + [Fact] public async Task CreateOrderPaymentAsync_PaymentWithSinglePaymentMethod_RequestIsSerializedInExpectedFormat() { // Given: We create a payment request with multiple payment methods @@ -175,7 +175,7 @@ public async Task CreateOrderPaymentAsync_PaymentWithSinglePaymentMethod_Request const string orderId = "order-id"; string url = $"{BaseMollieClient.ApiEndPoint}orders/{orderId}/payments"; string expectedPaymentMethodJson = $"\"method\":[\"{PaymentMethod.Ideal}\"]"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Post, url, defaultPaymentJsonResponse, expectedPaymentMethodJson); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Post, url, defaultPaymentJsonResponse, expectedPaymentMethodJson); HttpClient httpClient = mockHttp.ToHttpClient(); OrderClient orderClient = new OrderClient("abcde", httpClient); @@ -185,7 +185,7 @@ public async Task CreateOrderPaymentAsync_PaymentWithSinglePaymentMethod_Request // Then mockHttp.VerifyNoOutstandingExpectation(); } - + [Fact] public async Task CreateOrderPaymentAsync_PaymentWithMultiplePaymentMethods_RequestIsSerializedInExpectedFormat() { // Given: We create a payment request with multiple payment methods @@ -202,7 +202,7 @@ public async Task CreateOrderPaymentAsync_PaymentWithMultiplePaymentMethods_Requ const string orderId = "order-id"; string url = $"{BaseMollieClient.ApiEndPoint}orders/{orderId}/payments"; string expectedPaymentMethodJson = $"\"method\":[\"{PaymentMethod.Ideal}\",\"{PaymentMethod.CreditCard}\",\"{PaymentMethod.DirectDebit}\"]"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Post, url, defaultPaymentJsonResponse, expectedPaymentMethodJson); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Post, url, defaultPaymentJsonResponse, expectedPaymentMethodJson); HttpClient httpClient = mockHttp.ToHttpClient(); OrderClient orderClient = new OrderClient("abcde", httpClient); @@ -233,13 +233,13 @@ public async Task CreateOrderRefundAsync_WithRequiredParameters_ResponseIsDeseri Metadata = "my-metadata" }; string url = $"{BaseMollieClient.ApiEndPoint}orders/{orderId}/refunds"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Post, url, defaultOrderRefundJsonResponse); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Post, url, defaultOrderRefundJsonResponse); HttpClient httpClient = mockHttp.ToHttpClient(); OrderClient orderClient = new OrderClient("abcde", httpClient); - + // When: We send the request var response = await orderClient.CreateOrderRefundAsync(orderId, orderRefundRequest); - + // Then mockHttp.VerifyNoOutstandingExpectation(); response.Resource.Should().Be("refund"); @@ -251,7 +251,7 @@ public async Task CreateOrderRefundAsync_WithRequiredParameters_ResponseIsDeseri response.OrderId.Should().Be(orderId); response.Lines.Should().HaveCount(1); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -268,7 +268,7 @@ public async Task GetOrderAsync_NoOrderIdIsGiven_ArgumentExceptionIsThrown(strin // Then exception.Message.Should().Be("Required URL argument 'orderId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -285,7 +285,7 @@ public async Task UpdateOrderAsync_NoOrderIdIsGiven_ArgumentExceptionIsThrown(st // Then exception.Message.Should().Be("Required URL argument 'orderId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -302,7 +302,7 @@ public async Task UpdateOrderLinesAsync_NoOrderIdIsGiven_ArgumentExceptionIsThro // Then exception.Message.Should().Be("Required URL argument 'orderId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -319,7 +319,7 @@ public async Task UpdateOrderLinesAsync_NoOrderLineIdIsGiven_ArgumentExceptionIs // Then exception.Message.Should().Be("Required URL argument 'orderLineId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -341,13 +341,13 @@ public async Task ManageOrderLinesAsync_NoOrderIdIsGiven_ArgumentExceptionIsThro }; // When: We send the request - var exception = await Assert.ThrowsAsync(async () => + var exception = await Assert.ThrowsAsync(async () => await orderClient.ManageOrderLinesAsync(orderId, request)); // Then exception.Message.Should().Be("Required URL argument 'orderId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -364,7 +364,7 @@ public async Task CancelOrderAsync_NoOrderIdIsGiven_ArgumentExceptionIsThrown(st // Then exception.Message.Should().Be("Required URL argument 'orderId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -381,7 +381,7 @@ public async Task CreateOrderPaymentAsync_NoOrderIdIsGiven_ArgumentExceptionIsTh // Then exception.Message.Should().Be("Required URL argument 'orderId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -402,7 +402,7 @@ public async Task CreateOrderRefundAsync_NoOrderIdIsGiven_ArgumentExceptionIsThr // Then exception.Message.Should().Be("Required URL argument 'orderId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -524,7 +524,7 @@ private OrderRequest CreateOrderRequestWithOnlyRequiredFields() { } } }"; - + private const string defaultOrderJsonResponse = @"{ ""resource"": ""order"", ""id"": ""ord_kEn1PlbGa"", @@ -535,7 +535,7 @@ private OrderRequest CreateOrderRequestWithOnlyRequiredFields() { ""currency"": ""EUR"" }, }"; - + private const string defaultPaymentJsonResponse = @"{ ""amount"":{ ""currency"":""EUR"", @@ -545,4 +545,4 @@ private OrderRequest CreateOrderRequestWithOnlyRequiredFields() { ""redirectUrl"":""http://www.mollie.com""}"; } -} \ No newline at end of file +} diff --git a/tests/Mollie.Tests.Unit/Client/PaymentClientTests.cs b/tests/Mollie.Tests.Unit/Client/PaymentClientTests.cs index 561530c4..384715af 100644 --- a/tests/Mollie.Tests.Unit/Client/PaymentClientTests.cs +++ b/tests/Mollie.Tests.Unit/Client/PaymentClientTests.cs @@ -53,7 +53,7 @@ public async Task CreatePaymentAsync_WithCustomIdempotencyKey_CustomIdemPotencyK // Assert mockHttp.VerifyNoOutstandingExpectation(); } - + [Fact] public async Task CreatePaymentAsync_PaymentWithRequiredParameters_ResponseIsDeserializedInExpectedFormat() { // Given: we create a payment request with only the required parameters @@ -75,7 +75,7 @@ public async Task CreatePaymentAsync_PaymentWithRequiredParameters_ResponseIsDes PaymentResponse paymentResponse = await paymentClient.CreatePaymentAsync(paymentRequest); // Then - this.AssertPaymentIsEqual(paymentRequest, paymentResponse); + AssertPaymentIsEqual(paymentRequest, paymentResponse); paymentResponse.AuthorizedAt!.Value.ToUniversalTime().Should().Be(DateTime.SpecifyKind(19.March(2018).At(13, 28, 37), DateTimeKind.Utc)); paymentResponse.CreatedAt!.ToUniversalTime().Should().Be(DateTime.SpecifyKind(20.March(2018).At(13, 13, 37), DateTimeKind.Utc)); paymentResponse.PaidAt!.Value.ToUniversalTime().Should().Be(DateTime.SpecifyKind(21.March(2018).At(13, 28, 37), DateTimeKind.Utc)); @@ -117,7 +117,7 @@ public async Task CreatePaymentAsync_PaymentWithSinglePaymentMethod_RequestIsSer ""description"":""Description"", ""method"":""ideal"", ""redirectUrl"":""http://www.mollie.com""}"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Post, $"{BaseMollieClient.ApiEndPoint}payments", jsonResponse, expectedPaymentMethodJson); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Post, $"{BaseMollieClient.ApiEndPoint}payments", jsonResponse, expectedPaymentMethodJson); HttpClient httpClient = mockHttp.ToHttpClient(); PaymentClient paymentClient = new PaymentClient("abcde", httpClient); @@ -126,7 +126,7 @@ public async Task CreatePaymentAsync_PaymentWithSinglePaymentMethod_RequestIsSer // Then mockHttp.VerifyNoOutstandingExpectation(); - this.AssertPaymentIsEqual(paymentRequest, paymentResponse); + AssertPaymentIsEqual(paymentRequest, paymentResponse); paymentResponse.Method.Should().Be(paymentRequest.Method); } @@ -152,7 +152,7 @@ public async Task CreatePaymentAsync_PaymentWithMultiplePaymentMethods_RequestIs ""description"":""Description"", ""method"": null, ""redirectUrl"":""http://www.mollie.com""}"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Post, $"{BaseMollieClient.ApiEndPoint}payments", expectedJsonResponse, expectedPaymentMethodJson); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Post, $"{BaseMollieClient.ApiEndPoint}payments", expectedJsonResponse, expectedPaymentMethodJson); HttpClient httpClient = mockHttp.ToHttpClient(); PaymentClient paymentClient = new PaymentClient("abcde", httpClient); @@ -161,10 +161,10 @@ public async Task CreatePaymentAsync_PaymentWithMultiplePaymentMethods_RequestIs // Then mockHttp.VerifyNoOutstandingExpectation(); - this.AssertPaymentIsEqual(paymentRequest, paymentResponse); + AssertPaymentIsEqual(paymentRequest, paymentResponse); paymentResponse.Method.Should().BeNull(); } - + [Fact] public async Task CreatePayment_WithRoutingInformation_RequestIsSerializedInExpectedFormat() { // Given: We create a payment request with the routing request @@ -205,16 +205,16 @@ public async Task CreatePayment_WithRoutingInformation_RequestIsSerializedInExpe ""releaseDate"": ""2022-01-14"" } ]}"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Post, $"{BaseMollieClient.ApiEndPoint}payments", expectedJsonResponse, expectedRoutingInformation); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Post, $"{BaseMollieClient.ApiEndPoint}payments", expectedJsonResponse, expectedRoutingInformation); HttpClient httpClient = mockHttp.ToHttpClient(); PaymentClient paymentClient = new PaymentClient("abcde", httpClient); - + // When: We send the request PaymentResponse paymentResponse = await paymentClient.CreatePaymentAsync(paymentRequest); // Then mockHttp.VerifyNoOutstandingExpectation(); - this.AssertPaymentIsEqual(paymentRequest, paymentResponse); + AssertPaymentIsEqual(paymentRequest, paymentResponse); paymentResponse.Method.Should().BeNull(); } @@ -227,7 +227,7 @@ public async Task CreatePaymentAsync_IncludeQrCode_QueryStringContainsIncludeQrC RedirectUrl = "http://www.mollie.com", Method = PaymentMethod.Ideal }; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Post, $"{BaseMollieClient.ApiEndPoint}payments?include=details.qrCode", defaultPaymentJsonResponse); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Post, $"{BaseMollieClient.ApiEndPoint}payments?include=details.qrCode", defaultPaymentJsonResponse); HttpClient httpClient = mockHttp.ToHttpClient(); PaymentClient paymentClient = new PaymentClient("abcde", httpClient); @@ -242,7 +242,7 @@ public async Task CreatePaymentAsync_IncludeQrCode_QueryStringContainsIncludeQrC public async Task GetPaymentAsync_NoIncludeParameters_RequestIsDeserializedInExpectedFormat() { // Given: We make a request to retrieve a payment without wanting any extra data const string paymentId = "tr_WDqYK6vllg"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}payments/{paymentId}", defaultPaymentJsonResponse); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}payments/{paymentId}", defaultPaymentJsonResponse); HttpClient httpClient = mockHttp.ToHttpClient(); PaymentClient paymentClient = new PaymentClient("abcde", httpClient); @@ -306,9 +306,9 @@ public async Task GetPaymentAsync_ForBankTransferPayment_DetailsAreDeserialized( ""height"": 5, ""width"": 10, ""src"": ""https://www.mollie.com/qr/12345678.png"" - } + } }, - ""_links"": { + ""_links"": { ""status"": { ""href"": ""https://api.mollie.com/v2/payments/tr_WDqYK6vllg"", ""type"": ""application/hal+json"" @@ -319,14 +319,14 @@ public async Task GetPaymentAsync_ForBankTransferPayment_DetailsAreDeserialized( } } }"; - - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}payments/{paymentId}", jsonResponse); + + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}payments/{paymentId}", jsonResponse); HttpClient httpClient = mockHttp.ToHttpClient(); PaymentClient paymentClient = new PaymentClient("abcde", httpClient); // When: We send the request var payment = await paymentClient.GetPaymentAsync(paymentId); - + // Then payment.Should().BeOfType(); var bankTransferPayment = payment as BankTransferPaymentResponse; @@ -350,7 +350,7 @@ public async Task GetPaymentAsync_ForBankTransferPayment_DetailsAreDeserialized( bankTransferPayment.Links.PayOnline.Href.Should().Be("https://www.mollie.com/payscreen/select-method/WDqYK6vllg"); bankTransferPayment.Links.PayOnline.Type.Should().Be("text/html"); } - + [Fact] public async Task GetPaymentAsync_ForBanContactPayment_DetailsAreDeserialized() { @@ -382,13 +382,13 @@ public async Task GetPaymentAsync_ForBanContactPayment_DetailsAreDeserialized() ""failureReason"": ""failure-reason"" } }"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}payments/{paymentId}", jsonResponse); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}payments/{paymentId}", jsonResponse); HttpClient httpClient = mockHttp.ToHttpClient(); PaymentClient paymentClient = new PaymentClient("abcde", httpClient); - + // When: We send the request var result = await paymentClient.GetPaymentAsync(paymentId); - + // Then result.Should().BeOfType(); var banContactPayment = result as BancontactPaymentResponse; @@ -402,7 +402,7 @@ public async Task GetPaymentAsync_ForBanContactPayment_DetailsAreDeserialized() banContactPayment.Details.ConsumerBic.Should().Be("consumer-bic"); banContactPayment.Details.FailureReason.Should().Be("failure-reason"); } - + [Fact] public async Task CreatePaymentAsync_SepaDirectDebit_RequestAndResponseAreConvertedToExpectedJsonFormat() { @@ -457,16 +457,16 @@ public async Task CreatePaymentAsync_SepaDirectDebit_RequestAndResponseAreConver ""signatureDate"": ""2018-03-20"", ""endToEndIdentifier"": ""end-to-end-identifier"", ""batchReference"": ""batch-reference"", - ""fileReference"": ""file-reference"" + ""fileReference"": ""file-reference"" } }"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Post, $"{BaseMollieClient.ApiEndPoint}payments", jsonResponse, jsonRequest); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Post, $"{BaseMollieClient.ApiEndPoint}payments", jsonResponse, jsonRequest); HttpClient httpClient = mockHttp.ToHttpClient(); PaymentClient paymentClient = new PaymentClient("abcde", httpClient); - + // When: We send the request var result = await paymentClient.CreatePaymentAsync(paymentRequest); - + // Then mockHttp.VerifyNoOutstandingExpectation(); var specificPaymentResponse = result as SepaDirectDebitResponse; @@ -486,7 +486,7 @@ public async Task CreatePaymentAsync_SepaDirectDebit_RequestAndResponseAreConver specificPaymentResponse.Details.BatchReference.Should().Be("batch-reference"); specificPaymentResponse.Details.FileReference.Should().Be("file-reference"); } - + [Fact] public async Task GetPaymentAsync_ForPayPalPayment_DetailsAreDeserialized() { @@ -521,10 +521,10 @@ public async Task GetPaymentAsync_ForPayPalPayment_DetailsAreDeserialized() ""paypalFee"": { ""currency"": ""EUR"", ""value"": ""100.00"" - } + } } }"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}payments/{paymentId}", jsonResponse); HttpClient httpClient = mockHttp.ToHttpClient(); PaymentClient paymentClient = new PaymentClient("abcde", httpClient); @@ -551,7 +551,7 @@ public async Task GetPaymentAsync_ForPayPalPayment_DetailsAreDeserialized() payPalPayment.Details.PaypalFee.Currency.Should().Be("EUR"); payPalPayment.Details.PaypalFee.Value.Should().Be("100.00"); } - + [Fact] public async Task CreatePaymentAsync_CreditcardPayment_RequestAndResponseAreConvertedToExpectedJsonFormat() { @@ -634,13 +634,13 @@ public async Task CreatePaymentAsync_CreditcardPayment_RequestAndResponseAreConv ""wallet"": ""applepay"" } }"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Post, $"{BaseMollieClient.ApiEndPoint}payments", jsonResponse, jsonRequest); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Post, $"{BaseMollieClient.ApiEndPoint}payments", jsonResponse, jsonRequest); HttpClient httpClient = mockHttp.ToHttpClient(); PaymentClient paymentClient = new PaymentClient("abcde", httpClient); - + // When: We send the request var result = await paymentClient.CreatePaymentAsync(paymentRequest); - + // Then mockHttp.VerifyNoOutstandingExpectation(); var specificPaymentResponse = result as CreditCardPaymentResponse; @@ -657,7 +657,7 @@ public async Task CreatePaymentAsync_CreditcardPayment_RequestAndResponseAreConv specificPaymentResponse.Details.FailureMessage.Should().Be("faulure-message"); specificPaymentResponse.Details.Wallet.Should().Be("applepay"); } - + [Fact] public async Task CreatePaymentAsync_GiftcardPayment_RequestAndResponseAreConvertedToExpectedJsonFormat() { @@ -719,13 +719,13 @@ public async Task CreatePaymentAsync_GiftcardPayment_RequestAndResponseAreConver ""RemainderMethod"": ""ideal"" } }"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Post, $"{BaseMollieClient.ApiEndPoint}payments", jsonResponse, jsonRequest); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Post, $"{BaseMollieClient.ApiEndPoint}payments", jsonResponse, jsonRequest); HttpClient httpClient = mockHttp.ToHttpClient(); PaymentClient paymentClient = new PaymentClient("abcde", httpClient); - + // When: We send the request var result = await paymentClient.CreatePaymentAsync(paymentRequest); - + // Then mockHttp.VerifyNoOutstandingExpectation(); var specificPaymentResponse = result as GiftcardPaymentResponse; @@ -767,13 +767,13 @@ public async Task GetPaymentAsync_ForBelfiusPayment_DetailsAreDeserialized() ""consumerBic"": ""consumer-bic"" } }"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}payments/{paymentId}", jsonResponse); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}payments/{paymentId}", jsonResponse); HttpClient httpClient = mockHttp.ToHttpClient(); PaymentClient paymentClient = new PaymentClient("abcde", httpClient); - + // When: We send the request var result = await paymentClient.GetPaymentAsync(paymentId); - + // Then result.Should().BeOfType(); var belfiusPayment = result as BelfiusPaymentResponse; @@ -805,14 +805,14 @@ public async Task GetPaymentAsync_ForIngHomePay_DetailsAreDeserialized() ""consumerBic"": ""consumer-bic"" } }"; - - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}payments/{paymentId}", jsonResponse); + + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}payments/{paymentId}", jsonResponse); HttpClient httpClient = mockHttp.ToHttpClient(); PaymentClient paymentClient = new PaymentClient("abcde", httpClient); - + // When: We send the request var result = await paymentClient.GetPaymentAsync(paymentId); - + // Then result.Should().BeOfType(); var ingHomePayPayment = result as IngHomePayPaymentResponse; @@ -820,7 +820,7 @@ public async Task GetPaymentAsync_ForIngHomePay_DetailsAreDeserialized() ingHomePayPayment.Details.ConsumerAccount.Should().Be("consumer-account"); ingHomePayPayment.Details.ConsumerBic.Should().Be("consumer-bic"); } - + [Fact] public async Task GetPaymentAsync_ForKbcPayment_DetailsAreDeserialized() { @@ -844,14 +844,14 @@ public async Task GetPaymentAsync_ForKbcPayment_DetailsAreDeserialized() ""consumerBic"": ""consumer-bic"" } }"; - - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}payments/{paymentId}", jsonResponse); + + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}payments/{paymentId}", jsonResponse); HttpClient httpClient = mockHttp.ToHttpClient(); PaymentClient paymentClient = new PaymentClient("abcde", httpClient); - + // When: We send the request var result = await paymentClient.GetPaymentAsync(paymentId); - + // Then result.Should().BeOfType(); var kbcPayment = result as KbcPaymentResponse; @@ -909,13 +909,13 @@ public async Task CreatePaymentAsync_IdealPayment_RequestAndResponseAreConverted } } }"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Post, $"{BaseMollieClient.ApiEndPoint}payments", jsonResponse, jsonRequest); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Post, $"{BaseMollieClient.ApiEndPoint}payments", jsonResponse, jsonRequest); HttpClient httpClient = mockHttp.ToHttpClient(); PaymentClient paymentClient = new PaymentClient("abcde", httpClient); - + // When: We send the request var result = await paymentClient.CreatePaymentAsync(paymentRequest); - + // Then mockHttp.VerifyNoOutstandingExpectation(); var specificPaymentResponse = result as IdealPaymentResponse; @@ -927,7 +927,7 @@ public async Task CreatePaymentAsync_IdealPayment_RequestAndResponseAreConverted specificPaymentResponse.Details.QrCode.Width.Should().Be(10); specificPaymentResponse.Details.QrCode.Src.Should().Be("https://www.mollie.com/qr/12345678.png"); } - + [Fact] public async Task GetPaymentAsync_ForSofortPayment_DetailsAreDeserialized() { @@ -951,14 +951,14 @@ public async Task GetPaymentAsync_ForSofortPayment_DetailsAreDeserialized() ""consumerBic"": ""consumer-bic"" } }"; - - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}payments/{paymentId}", jsonResponse); + + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}payments/{paymentId}", jsonResponse); HttpClient httpClient = mockHttp.ToHttpClient(); PaymentClient paymentClient = new PaymentClient("abcde", httpClient); - + // When: We send the request var result = await paymentClient.GetPaymentAsync(paymentId); - + // Then result.Should().BeOfType(); var sofortPayment = result as SofortPaymentResponse; @@ -966,7 +966,7 @@ public async Task GetPaymentAsync_ForSofortPayment_DetailsAreDeserialized() sofortPayment.Details.ConsumerAccount.Should().Be("consumer-account"); sofortPayment.Details.ConsumerBic.Should().Be("consumer-bic"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -1005,7 +1005,7 @@ public async Task GetPaymentAsync_IncludeQrCode_QueryStringContainsIncludeQrCode } } }"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}payments/{paymentId}?include=details.qrCode", jsonResponse); HttpClient httpClient = mockHttp.ToHttpClient(); @@ -1028,7 +1028,7 @@ public async Task GetPaymentAsync_IncludeQrCode_QueryStringContainsIncludeQrCode public async Task GetPaymentAsync_IncludeRemainderDetails_QueryStringContainsIncludeRemainderDetailsParameter() { // Given: We make a request to retrieve a payment without wanting any extra data const string paymentId = "abcde"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}payments/{paymentId}?include=details.remainderDetails", defaultPaymentJsonResponse); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}payments/{paymentId}?include=details.remainderDetails", defaultPaymentJsonResponse); HttpClient httpClient = mockHttp.ToHttpClient(); PaymentClient paymentClient = new PaymentClient("abcde", httpClient); @@ -1042,7 +1042,7 @@ public async Task GetPaymentAsync_IncludeRemainderDetails_QueryStringContainsInc [Fact] public async Task GetPaymentListAsync_IncludeQrCode_QueryStringContainsIncludeQrCodeParameter() { // Given: We make a request to retrieve a payment without wanting any extra data - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}payments?include=details.qrCode", defaultPaymentJsonResponse); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}payments?include=details.qrCode", defaultPaymentJsonResponse); HttpClient httpClient = mockHttp.ToHttpClient(); PaymentClient paymentClient = new PaymentClient("abcde", httpClient); @@ -1058,7 +1058,7 @@ public async Task GetPaymentAsync_EmbedRefunds_QueryStringContainsEmbedRefundsPa { // Given: We make a request to retrieve a payment with embedded refunds const string paymentId = "abcde"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}payments/{paymentId}?embed=refunds", defaultPaymentJsonResponse); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}payments/{paymentId}?embed=refunds", defaultPaymentJsonResponse); HttpClient httpClient = mockHttp.ToHttpClient(); PaymentClient paymentClient = new PaymentClient("abcde", httpClient); @@ -1073,7 +1073,7 @@ public async Task GetPaymentAsync_EmbedRefunds_QueryStringContainsEmbedRefundsPa public async Task GetPaymentListAsync_EmbedRefunds_QueryStringContainsEmbedRefundsParameter() { // Given: We make a request to retrieve a payment with embedded refunds - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}payments?embed=refunds", defaultPaymentJsonResponse); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}payments?embed=refunds", defaultPaymentJsonResponse); HttpClient httpClient = mockHttp.ToHttpClient(); PaymentClient paymentClient = new PaymentClient("abcde", httpClient); @@ -1089,7 +1089,7 @@ public async Task GetPaymentAsync_EmbedChargebacks_QueryStringContainsEmbedCharg { // Given: We make a request to retrieve a payment with embedded refunds const string paymentId = "abcde"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}payments/{paymentId}?embed=chargebacks", defaultPaymentJsonResponse); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}payments/{paymentId}?embed=chargebacks", defaultPaymentJsonResponse); HttpClient httpClient = mockHttp.ToHttpClient(); PaymentClient paymentClient = new PaymentClient("abcde", httpClient); @@ -1104,7 +1104,7 @@ public async Task GetPaymentAsync_EmbedChargebacks_QueryStringContainsEmbedCharg public async Task GetPaymentListAsync_EmbedChargebacks_QueryStringContainsEmbedChargebacksParameter() { // Given: We make a request to retrieve a payment with embedded refunds - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}payments?embed=chargebacks", defaultPaymentJsonResponse); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}payments?embed=chargebacks", defaultPaymentJsonResponse); HttpClient httpClient = mockHttp.ToHttpClient(); PaymentClient paymentClient = new PaymentClient("abcde", httpClient); @@ -1114,7 +1114,7 @@ public async Task GetPaymentListAsync_EmbedChargebacks_QueryStringContainsEmbedC // Then mockHttp.VerifyNoOutstandingExpectation(); } - + [Theory] [InlineData(null, "")] [InlineData(SortDirection.Desc, "?sort=desc")] @@ -1122,7 +1122,7 @@ public async Task GetPaymentListAsync_EmbedChargebacks_QueryStringContainsEmbedC public async Task GetPaymentListAsync_AddSortDirection_QueryStringContainsSortDirection(SortDirection? sortDirection, string expectedQueryString) { // Given: We make a request to retrieve a payment with embedded refunds - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}payments{expectedQueryString}", defaultPaymentJsonResponse); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}payments{expectedQueryString}", defaultPaymentJsonResponse); HttpClient httpClient = mockHttp.ToHttpClient(); PaymentClient paymentClient = new PaymentClient("abcde", httpClient); @@ -1138,7 +1138,7 @@ public async Task DeletePaymentAsync_TestmodeIsTrue_RequestContainsTestmodeModel // Given: We make a request to retrieve a payment with embedded refunds const string paymentId = "payment-id"; string expectedContent = "\"testmode\":true"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Delete, $"{BaseMollieClient.ApiEndPoint}payments/{paymentId}", defaultPaymentJsonResponse, expectedContent); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Delete, $"{BaseMollieClient.ApiEndPoint}payments/{paymentId}", defaultPaymentJsonResponse, expectedContent); HttpClient httpClient = mockHttp.ToHttpClient(); PaymentClient paymentClient = new PaymentClient("abcde", httpClient); @@ -1148,7 +1148,7 @@ public async Task DeletePaymentAsync_TestmodeIsTrue_RequestContainsTestmodeModel // Then mockHttp.VerifyNoOutstandingExpectation(); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -1165,7 +1165,7 @@ public async Task DeletePaymentAsync_NoPaymentIdIsGiven_ArgumentExceptionIsThrow // Then exception.Message.Should().Be("Required URL argument 'paymentId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -1199,7 +1199,7 @@ private void AssertPaymentIsEqual(PaymentRequest paymentRequest, PaymentResponse } } } - + private const string defaultPaymentJsonResponse = @" { ""resource"": ""payment"", @@ -1224,7 +1224,7 @@ private void AssertPaymentIsEqual(PaymentRequest paymentRequest, PaymentResponse ""profileId"": ""pfl_QkEhN94Ba"", ""sequenceType"": ""oneoff"", ""redirectUrl"": ""https://webshop.example.org/order/12345/"", - ""webhookUrl"": ""https://webshop.example.org/payments/webhook/"", + ""webhookUrl"": ""https://webshop.example.org/payments/webhook/"", ""authorizedAt"": ""2018-03-19T13:28:37+00:00"", ""paidAt"": ""2018-03-21T13:28:37+00:00"", ""canceledAt"": ""2018-03-22T13:28:37+00:00"", @@ -1273,4 +1273,4 @@ private void AssertPaymentIsEqual(PaymentRequest paymentRequest, PaymentResponse } } }"; -} \ No newline at end of file +} diff --git a/tests/Mollie.Tests.Unit/Client/PaymentMethodClientTests.cs b/tests/Mollie.Tests.Unit/Client/PaymentMethodClientTests.cs index b1d46a69..94e99770 100644 --- a/tests/Mollie.Tests.Unit/Client/PaymentMethodClientTests.cs +++ b/tests/Mollie.Tests.Unit/Client/PaymentMethodClientTests.cs @@ -25,7 +25,7 @@ public class PaymentMethodClientTests : BaseClientTests { [Fact] public async Task GetAllPaymentMethodListAsync_NoAmountParameter_QueryStringIsEmpty() { // Given: We make a request to retrieve all payment methods without any parameters - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}methods/all", defaultPaymentMethodJsonResponse); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}methods/all", defaultPaymentMethodJsonResponse); HttpClient httpClient = mockHttp.ToHttpClient(); PaymentMethodClient paymentMethodClient = new PaymentMethodClient("abcde", httpClient); @@ -39,7 +39,7 @@ public async Task GetAllPaymentMethodListAsync_NoAmountParameter_QueryStringIsEm [Fact] public async Task GetAllPaymentMethodListAsync_AmountParameterIsAdded_QueryStringContainsAmount() { // Given: We make a request to retrieve all payment methods with a amount parameter - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}methods/all?amount[value]=100.00&amount[currency]=EUR", defaultPaymentMethodJsonResponse); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}methods/all?amount[value]=100.00&amount[currency]=EUR", defaultPaymentMethodJsonResponse); HttpClient httpClient = mockHttp.ToHttpClient(); PaymentMethodClient paymentMethodClient = new PaymentMethodClient("abcde", httpClient); @@ -54,7 +54,7 @@ public async Task GetAllPaymentMethodListAsync_AmountParameterIsAdded_QueryStrin public async Task GetAllPaymentMethodListAsync_ProfileIdParameterIsSpecified_QueryStringContainsProfileIdParameter() { // Given: We make a request to retrieve all payment methods with a profile id parameter var profileId = "myProfileId"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}methods/all?profileId={profileId}", defaultPaymentMethodJsonResponse); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}methods/all?profileId={profileId}", defaultPaymentMethodJsonResponse); HttpClient httpClient = mockHttp.ToHttpClient(); PaymentMethodClient paymentMethodClient = new PaymentMethodClient("abcde", httpClient); @@ -64,12 +64,12 @@ public async Task GetAllPaymentMethodListAsync_ProfileIdParameterIsSpecified_Que // Then mockHttp.VerifyNoOutstandingExpectation(); } - + [Fact] public async Task GetPaymentMethodListAsync_IncludeWalletsParameterIsSpecified_QueryStringContainsIncludeWalletsParameter() { // Given: We make a request to retrieve the payment methods with a includeWallets parameter var includeWalletsValue = "includeWalletsValue"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}methods?includeWallets={includeWalletsValue}", defaultPaymentMethodJsonResponse); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}methods?includeWallets={includeWalletsValue}", defaultPaymentMethodJsonResponse); HttpClient httpClient = mockHttp.ToHttpClient(); PaymentMethodClient paymentMethodClient = new PaymentMethodClient("abcde", httpClient); @@ -79,7 +79,7 @@ public async Task GetPaymentMethodListAsync_IncludeWalletsParameterIsSpecified_Q // Then mockHttp.VerifyNoOutstandingExpectation(); } - + [Theory] [InlineData("")] [InlineData(" ")] diff --git a/tests/Mollie.Tests.Unit/Client/RefundClientTests.cs b/tests/Mollie.Tests.Unit/Client/RefundClientTests.cs index 2ea4d5b7..a9927bda 100644 --- a/tests/Mollie.Tests.Unit/Client/RefundClientTests.cs +++ b/tests/Mollie.Tests.Unit/Client/RefundClientTests.cs @@ -49,7 +49,7 @@ public class RefundClientTests : BaseClientTests { public async Task GetRefundAsync_TestModeParameterCase_QueryStringOnlyContainsTestModeParameterIfTrue(string expectedUrl, bool? testModeParameter) { // Given: We make a request to retrieve a payment without wanting any extra data bool testMode = testModeParameter ?? false; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}{expectedUrl}", defaultGetRefundResponse); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}{expectedUrl}", defaultGetRefundResponse); HttpClient httpClient = mockHttp.ToHttpClient(); RefundClient refundClient = new RefundClient("abcde", httpClient); @@ -60,7 +60,7 @@ public async Task GetRefundAsync_TestModeParameterCase_QueryStringOnlyContainsTe mockHttp.VerifyNoOutstandingExpectation(); refundResponse.Should().NotBeNull(); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -80,7 +80,7 @@ public async Task CreateRefundAsync_NoPaymentIdIsGiven_ArgumentExceptionIsThrown // Then exception.Message.Should().Be("Required URL argument 'paymentId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -97,7 +97,7 @@ public async Task GetRefundListAsync_NoPaymentIdIsGiven_ArgumentExceptionIsThrow // Then exception.Message.Should().Be("Required URL argument 'paymentId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -114,7 +114,7 @@ public async Task GetRefundAsync_NoPaymentIdIsGiven_ArgumentExceptionIsThrown(st // Then exception.Message.Should().Be("Required URL argument 'paymentId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -131,7 +131,7 @@ public async Task GetRefundAsync_NoRefundIsGiven_ArgumentExceptionIsThrown(strin // Then exception.Message.Should().Be("Required URL argument 'refundId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -148,7 +148,7 @@ public async Task CancelRefundAsync_NoPaymentIdIsGiven_ArgumentExceptionIsThrown // Then exception.Message.Should().Be("Required URL argument 'paymentId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] diff --git a/tests/Mollie.Tests.Unit/Client/SettlementClientTests.cs b/tests/Mollie.Tests.Unit/Client/SettlementClientTests.cs index fa7106e6..ff9a4ea0 100644 --- a/tests/Mollie.Tests.Unit/Client/SettlementClientTests.cs +++ b/tests/Mollie.Tests.Unit/Client/SettlementClientTests.cs @@ -16,7 +16,7 @@ public class SettlementClientTests : BaseClientTests { public async Task ListSettlementCaptures_DefaultBehaviour_ResponseIsParsed() { // Given: We request a list of captures string expectedUrl = $"{BaseMollieClient.ApiEndPoint}settlements/{defaultSettlementId}/captures"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, expectedUrl, defaultCaptureListJsonResponse); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, expectedUrl, defaultCaptureListJsonResponse); HttpClient httpClient = mockHttp.ToHttpClient(); SettlementsClient settlementsClient = new SettlementsClient("api-key", httpClient); @@ -54,7 +54,7 @@ public async Task ListSettlementCaptures_DefaultBehaviour_ResponseIsParsed() { public async Task GetOpenSettlement_DefaultBehaviour_ResponseIsParsed() { // Given: We request a list of captures string expectedUrl = $"{BaseMollieClient.ApiEndPoint}settlements/open"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, expectedUrl, defaultGetSettlementResponse); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, expectedUrl, defaultGetSettlementResponse); HttpClient httpClient = mockHttp.ToHttpClient(); SettlementsClient settlementsClient = new SettlementsClient("api-key", httpClient); @@ -121,7 +121,7 @@ public async Task GetOpenSettlement_DefaultBehaviour_ResponseIsParsed() { public async Task GetOpenSettlement_ResponseWithEmptyPeriods_ResponseIsParsed() { // Given: We request a list of captures string expectedUrl = $"{BaseMollieClient.ApiEndPoint}settlements/open"; - var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, expectedUrl, emptyPeriodsSettlementResponse); + var mockHttp = CreateMockHttpMessageHandler(HttpMethod.Get, expectedUrl, emptyPeriodsSettlementResponse); HttpClient httpClient = mockHttp.ToHttpClient(); SettlementsClient settlementsClient = new SettlementsClient("api-key", httpClient); @@ -133,7 +133,7 @@ public async Task GetOpenSettlement_ResponseWithEmptyPeriods_ResponseIsParsed() settlementResponse.Should().NotBeNull(); settlementResponse.Periods.Count.Should().Be(0); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -150,7 +150,7 @@ public async Task GetSettlementAsync_NoSettlementIdIsGiven_ArgumentExceptionIsTh // Then exception.Message.Should().Be("Required URL argument 'settlementId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -167,7 +167,7 @@ public async Task GetSettlementPaymentsListAsync_NoSettlementIdIsGiven_ArgumentE // Then exception.Message.Should().Be("Required URL argument 'settlementId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -184,7 +184,7 @@ public async Task GetSettlementRefundsListAsync_NoSettlementIdIsGiven_ArgumentEx // Then exception.Message.Should().Be("Required URL argument 'settlementId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -201,7 +201,7 @@ public async Task GetSettlementChargebacksListAsync_NoSettlementIdIsGiven_Argume // Then exception.Message.Should().Be("Required URL argument 'settlementId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -218,8 +218,8 @@ public async Task GetSettlementCapturesListAsync_NoSettlementIdIsGiven_ArgumentE // Then exception.Message.Should().Be("Required URL argument 'settlementId' is null or empty"); } - - + + private const string defaultSettlementId = "tr_Agfg241g"; private const string defaultPaymentId = "tr_WDqYK6vllg"; private const string defaultShipmentId = "shp_3wmsgCJN4U"; @@ -403,7 +403,7 @@ public async Task GetSettlementCapturesListAsync_NoSettlementIdIsGiven_ArgumentE ""currency"":""EUR"" }}, ""periods"":[ - + ], ""_links"":{{ ""self"":{{ @@ -416,5 +416,5 @@ public async Task GetSettlementCapturesListAsync_NoSettlementIdIsGiven_ArgumentE }} }} }}"; - } + } } diff --git a/tests/Mollie.Tests.Unit/Client/ShipmentClientTests.cs b/tests/Mollie.Tests.Unit/Client/ShipmentClientTests.cs index be4e6d72..7249ce62 100644 --- a/tests/Mollie.Tests.Unit/Client/ShipmentClientTests.cs +++ b/tests/Mollie.Tests.Unit/Client/ShipmentClientTests.cs @@ -31,14 +31,14 @@ public async Task CreateShipmentAsync_ValidShipment_ResponseIsDeserializedInExpe }; const string orderId = "order-id"; const string expectedPartialRequest = @"{""tracking"":{""carrier"":""tracking-carrier"",""code"":""tracking-code"",""url"":""tracking-url""},""lines"":[{""id"":""shipment-line-id"",""quantity"":1,""amount"":{""currency"":""EUR"",""value"":""50.00""}}],""testmode"":true}"; - var mockHttp = this.CreateMockHttpMessageHandler( - HttpMethod.Post, - $"{BaseMollieClient.ApiEndPoint}orders/{orderId}/shipments", - DefaultShipmentJsonToReturn, + var mockHttp = CreateMockHttpMessageHandler( + HttpMethod.Post, + $"{BaseMollieClient.ApiEndPoint}orders/{orderId}/shipments", + DefaultShipmentJsonToReturn, expectedPartialRequest); HttpClient httpClient = mockHttp.ToHttpClient(); ShipmentClient shipmentClient = new ShipmentClient("abcde", httpClient); - + // When: We send the request ShipmentResponse shipmentResponse = await shipmentClient.CreateShipmentAsync(orderId, shipmentRequest); @@ -50,7 +50,7 @@ public async Task CreateShipmentAsync_ValidShipment_ResponseIsDeserializedInExpe shipmentResponse.Tracking.Code.Should().Be(shipmentRequest.Tracking.Code); shipmentResponse.Tracking.Url.Should().Be(shipmentRequest.Tracking.Url); } - + [Theory] [InlineData("orders/order-id/shipments/shipment-id", false)] [InlineData("orders/order-id/shipments/shipment-id?testmode=true", true)] @@ -58,7 +58,7 @@ public async Task GetShipmentAsync_TestModeParameterCase_QueryStringOnlyContains // Given: We retrieve a shipment const string orderId = "order-id"; const string shipmentId = "shipment-id"; - + var mockHttp = new MockHttpMessageHandler(); mockHttp.When($"{BaseMollieClient.ApiEndPoint}{expectedUrl}") .Respond("application/json", DefaultShipmentJsonToReturn); @@ -72,14 +72,14 @@ public async Task GetShipmentAsync_TestModeParameterCase_QueryStringOnlyContains mockHttp.VerifyNoOutstandingExpectation(); shipmentResponse.Should().NotBeNull(); } - + [Theory] [InlineData("orders/order-id/shipments", false)] [InlineData("orders/order-id/shipments?testmode=true", true)] public async Task GetShipmentsListAsync_TestModeParameterCase_QueryStringOnlyContainsTestModeParameterIfTrue(string expectedUrl, bool testModeParameter) { // Given: We retrieve the list of shipments const string orderId = "order-id"; - + var mockHttp = new MockHttpMessageHandler(); mockHttp.When($"{BaseMollieClient.ApiEndPoint}{expectedUrl}") .Respond("application/json", DefaultShipmentJsonToReturn); @@ -93,7 +93,7 @@ public async Task GetShipmentsListAsync_TestModeParameterCase_QueryStringOnlyCon mockHttp.VerifyNoOutstandingExpectation(); shipmentListResponse.Should().NotBeNull(); } - + [Fact] public async Task UpdateShipmentAsync_ValidUpdateShipmentRequest_ResponseIsDeserializedInExpectedFormat() { // Given: We create a shipment @@ -108,14 +108,14 @@ public async Task UpdateShipmentAsync_ValidUpdateShipmentRequest_ResponseIsDeser const string orderId = "order-id"; const string shipmentId = "shipment-id"; const string expectedPartialRequest = @"{""tracking"":{""carrier"":""tracking-carrier"",""code"":""tracking-code"",""url"":""tracking-url""},""testmode"":true}"; - var mockHttp = this.CreateMockHttpMessageHandler( - HttpMethod.Patch, - $"{BaseMollieClient.ApiEndPoint}orders/{orderId}/shipments/{shipmentId}", - DefaultShipmentJsonToReturn, + var mockHttp = CreateMockHttpMessageHandler( + HttpMethod.Patch, + $"{BaseMollieClient.ApiEndPoint}orders/{orderId}/shipments/{shipmentId}", + DefaultShipmentJsonToReturn, expectedPartialRequest); HttpClient httpClient = mockHttp.ToHttpClient(); ShipmentClient shipmentClient = new ShipmentClient("abcde", httpClient); - + // When: We send the request ShipmentResponse shipmentResponse = await shipmentClient.UpdateShipmentAsync(orderId, shipmentId, updateShipmentRequest); @@ -127,7 +127,7 @@ public async Task UpdateShipmentAsync_ValidUpdateShipmentRequest_ResponseIsDeser shipmentResponse.Tracking.Code.Should().Be(updateShipmentRequest.Tracking.Code); shipmentResponse.Tracking.Url.Should().Be(updateShipmentRequest.Tracking.Url); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -144,7 +144,7 @@ public async Task CreateShipmentAsync_NoOrderIdIsGiven_ArgumentExceptionIsThrown // Then exception.Message.Should().Be("Required URL argument 'orderId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -161,7 +161,7 @@ public async Task GetShipmentAsync_NoOrderIdIsGiven_ArgumentExceptionIsThrown(st // Then exception.Message.Should().Be("Required URL argument 'orderId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -178,7 +178,7 @@ public async Task GetShipmentAsync_NoShipmentIdIsGiven_ArgumentExceptionIsThrown // Then exception.Message.Should().Be("Required URL argument 'shipmentId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -195,7 +195,7 @@ public async Task GetShipmentsListAsync_NoOrderIdIsGiven_ArgumentExceptionIsThro // Then exception.Message.Should().Be("Required URL argument 'orderId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -219,7 +219,7 @@ public async Task UpdateShipmentAsync_NoOrderIdIsGiven_ArgumentExceptionIsThrown // Then exception.Message.Should().Be("Required URL argument 'orderId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -348,4 +348,4 @@ public async Task UpdateShipmentAsync_NoShipmentIdIsGiven_ArgumentExceptionIsThr } }"; } -} \ No newline at end of file +} diff --git a/tests/Mollie.Tests.Unit/Client/SubscriptionClientTests.cs b/tests/Mollie.Tests.Unit/Client/SubscriptionClientTests.cs index 5612232a..6d54415b 100644 --- a/tests/Mollie.Tests.Unit/Client/SubscriptionClientTests.cs +++ b/tests/Mollie.Tests.Unit/Client/SubscriptionClientTests.cs @@ -19,7 +19,7 @@ public class SubscriptionClientTests : BaseClientTests { public async Task GetSubscriptionListAsync_TestModeParameterCase_QueryStringOnlyContainsTestModeParameterIfTrue(string from, int? limit, string profileId, bool testmode, string expectedQueryString) { // Given: We retrieve a list of subscriptions const string customerId = "customer-id"; - + var mockHttp = new MockHttpMessageHandler(); mockHttp.When($"{BaseMollieClient.ApiEndPoint}customers/customer-id/subscriptions{expectedQueryString}") .Respond("application/json", DefaultSubscriptionJsonToReturn); @@ -33,7 +33,7 @@ public async Task GetSubscriptionListAsync_TestModeParameterCase_QueryStringOnly mockHttp.VerifyNoOutstandingExpectation(); result.Should().NotBeNull(); } - + [Theory] [InlineData(null, null, null,false, "")] [InlineData("from", null, null, false, "?from=from")] @@ -55,7 +55,7 @@ public async Task GetAllSubscriptionList_TestModeParameterCase_QueryStringOnlyCo mockHttp.VerifyNoOutstandingExpectation(); result.Should().NotBeNull(); } - + [Theory] [InlineData("customers/customer-id/subscriptions/subscription-id", false)] [InlineData("customers/customer-id/subscriptions/subscription-id?testmode=true", true)] @@ -63,7 +63,7 @@ public async Task GetSubscriptionAsync_TestModeParameterCase_QueryStringOnlyCont // Given: We retrieve a subscriptions const string customerId = "customer-id"; const string subscriptionId = "subscription-id"; - + var mockHttp = new MockHttpMessageHandler(); mockHttp.When($"{BaseMollieClient.ApiEndPoint}{expectedUrl}") .Respond("application/json", DefaultSubscriptionJsonToReturn); @@ -77,18 +77,18 @@ public async Task GetSubscriptionAsync_TestModeParameterCase_QueryStringOnlyCont mockHttp.VerifyNoOutstandingExpectation(); result.Should().NotBeNull(); } - + [Fact] public async Task RevokeMandate_TestmodeIsTrue_RequestContainsTestmodeModel() { // Given: We make a request to retrieve a payment with embedded refunds const string customerId = "customer-id"; const string subscriptionId = "subscription-id"; - + string expectedContent = "\"testmode\":true"; - var mockHttp = this.CreateMockHttpMessageHandler( - HttpMethod.Delete, - $"{BaseMollieClient.ApiEndPoint}customers/{customerId}/subscriptions/{subscriptionId}", - DefaultSubscriptionJsonToReturn, + var mockHttp = CreateMockHttpMessageHandler( + HttpMethod.Delete, + $"{BaseMollieClient.ApiEndPoint}customers/{customerId}/subscriptions/{subscriptionId}", + DefaultSubscriptionJsonToReturn, expectedContent); HttpClient httpClient = mockHttp.ToHttpClient(); SubscriptionClient subscriptionClient = new SubscriptionClient("abcde", httpClient); @@ -99,7 +99,7 @@ public async Task RevokeMandate_TestmodeIsTrue_RequestContainsTestmodeModel() { // Then mockHttp.VerifyNoOutstandingExpectation(); } - + [Theory] [InlineData(null, null, false, "")] [InlineData("from", null, false, "?from=from")] @@ -122,7 +122,7 @@ public async Task GetSubscriptionPaymentListAsync_TestModeParameterCase_QueryStr mockHttp.VerifyNoOutstandingExpectation(); result.Should().NotBeNull(); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -139,7 +139,7 @@ public async Task GetSubscriptionListAsync_NoCustomerIdIsGiven_ArgumentException // Then exception.Message.Should().Be("Required URL argument 'customerId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -156,7 +156,7 @@ public async Task GetSubscriptionAsync_NoCustomerIdIsGiven_ArgumentExceptionIsTh // Then exception.Message.Should().Be("Required URL argument 'customerId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -173,7 +173,7 @@ public async Task GetSubscriptionAsync_NoSubscriptionIdIsGiven_ArgumentException // Then exception.Message.Should().Be("Required URL argument 'subscriptionId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -193,13 +193,13 @@ public async Task CreateSubscriptionAsync_NoCustomerIdIsGiven_ArgumentExceptionI }; // When: We send the request - var exception = await Assert.ThrowsAsync(async () => + var exception = await Assert.ThrowsAsync(async () => await subscriptionClient.CreateSubscriptionAsync(customerId, subscriptionRequest)); // Then exception.Message.Should().Be("Required URL argument 'customerId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -216,7 +216,7 @@ public async Task CancelSubscriptionAsync_NoCustomerIdIsGiven_ArgumentExceptionI // Then exception.Message.Should().Be("Required URL argument 'customerId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -233,7 +233,7 @@ public async Task CancelSubscriptionAsync_NoSubscriptionIdIsGiven_ArgumentExcept // Then exception.Message.Should().Be("Required URL argument 'subscriptionId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -250,7 +250,7 @@ public async Task UpdateSubscriptionAsync_NoCustomerIdIsGiven_ArgumentExceptionI // Then exception.Message.Should().Be("Required URL argument 'customerId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -267,7 +267,7 @@ public async Task UpdateSubscriptionAsync_NoSubscriptionIdIsGiven_ArgumentExcept // Then exception.Message.Should().Be("Required URL argument 'subscriptionId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -284,7 +284,7 @@ public async Task GetSubscriptionPaymentListAsync_NoCustomerIdIsGiven_ArgumentEx // Then exception.Message.Should().Be("Required URL argument 'customerId' is null or empty"); } - + [Theory] [InlineData("")] [InlineData(" ")] @@ -301,7 +301,7 @@ public async Task GetSubscriptionPaymentListAsync_NoSubscriptionIdIsGiven_Argume // Then exception.Message.Should().Be("Required URL argument 'subscriptionId' is null or empty"); } - + private const string DefaultSubscriptionJsonToReturn = @"{ ""resource"": ""subscription"", ""id"": ""subscription-id"", @@ -323,7 +323,7 @@ public async Task GetSubscriptionPaymentListAsync_NoSubscriptionIdIsGiven_Argume ""webhookUrl"": ""https://webshop.example.org/payments/webhook"", ""metadata"": { ""plan"": ""small"" - } + } }"; } -} \ No newline at end of file +} diff --git a/tests/Mollie.Tests.Unit/Client/TerminalClientTests.cs b/tests/Mollie.Tests.Unit/Client/TerminalClientTests.cs index 8637367c..5c266d59 100644 --- a/tests/Mollie.Tests.Unit/Client/TerminalClientTests.cs +++ b/tests/Mollie.Tests.Unit/Client/TerminalClientTests.cs @@ -8,7 +8,7 @@ using RichardSzalay.MockHttp; using Xunit; -namespace Mollie.Tests.Unit.Client; +namespace Mollie.Tests.Unit.Client; public class TerminalClientTests : BaseClientTests { [Theory] @@ -43,10 +43,10 @@ public async Task GetTerminalAsync_WithTerminalId_ResponseIsDeserializedInExpect .Respond("application/json", jsonToReturnInMockResponse); HttpClient httpClient = mockHttp.ToHttpClient(); var terminalClient = new TerminalClient("abcde", httpClient); - + // When TerminalResponse response = await terminalClient.GetTerminalAsync(terminalId); - + // Then mockHttp.VerifyNoOutstandingExpectation(); response.Id.Should().Be(terminalId); @@ -59,7 +59,7 @@ public async Task GetTerminalAsync_WithTerminalId_ResponseIsDeserializedInExpect response.Links.Self.Href.Should().Be($"https://api.mollie.com/v2/terminals/{terminalId}"); response.Links.Documentation.Should().NotBeNull(); } - + [Theory] [InlineData(null, null, null, false, "")] [InlineData("from", null, null, false, "?from=from")] @@ -69,8 +69,8 @@ public async Task GetTerminalAsync_WithTerminalId_ResponseIsDeserializedInExpect public async Task GetTerminalListAsync_QueryParameterOptions_CorrectParametersAreAdded(string from, int? limit, string profileId, bool testmode, string expectedQueryString) { // Given string jsonToReturnInMockResponse = CreateTerminalListJsonResponse(); - var mockHttp = this.CreateMockHttpMessageHandler( - HttpMethod.Get, + var mockHttp = CreateMockHttpMessageHandler( + HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}terminals{expectedQueryString}", jsonToReturnInMockResponse); HttpClient httpClient = mockHttp.ToHttpClient(); @@ -87,16 +87,16 @@ public async Task GetTerminalListAsync_QueryParameterOptions_CorrectParametersAr public async Task GetTerminalListAsync_ResponseIsDeserializedInExpectedFormat() { // Given string jsonToReturnInMockResponse = CreateTerminalListJsonResponse(); - var mockHttp = this.CreateMockHttpMessageHandler( - HttpMethod.Get, + var mockHttp = CreateMockHttpMessageHandler( + HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}terminals", jsonToReturnInMockResponse); HttpClient httpClient = mockHttp.ToHttpClient(); var terminalClient = new TerminalClient("abcde", httpClient); - + // When ListResponse response = await terminalClient.GetTerminalListAsync(); - + // Then response.Count.Should().Be(1); response.Items.Count.Should().Be(response.Count); @@ -106,7 +106,7 @@ public async Task GetTerminalListAsync_ResponseIsDeserializedInExpectedFormat() private string CreateTerminalListJsonResponse() { string terminalJson = CreateTerminalJsonResponse("terminal-id", "description", "serial", "brand", "model"); - + return @$"{{ ""count"": 1, ""_embedded"": {{ @@ -157,4 +157,4 @@ private string CreateTerminalJsonResponse(string terminalId, string description, }} }}"; } -} \ No newline at end of file +} diff --git a/tests/Mollie.Tests.Unit/Client/WalletClientTest.cs b/tests/Mollie.Tests.Unit/Client/WalletClientTest.cs index ba771f06..bf5073ad 100644 --- a/tests/Mollie.Tests.Unit/Client/WalletClientTest.cs +++ b/tests/Mollie.Tests.Unit/Client/WalletClientTest.cs @@ -6,7 +6,7 @@ using Mollie.Api.Models.Wallet.Request; using Xunit; -namespace Mollie.Tests.Unit.Client; +namespace Mollie.Tests.Unit.Client; public class WalletClientTest : BaseClientTests { private const string defaultApplePayPaymentSessionResponse = @"{ @@ -19,7 +19,7 @@ public class WalletClientTest : BaseClientTests { ""displayName"": ""Chuck Norris's Store"", ""signature"": ""308006092a864886f7...8cc030ad3000000000000"" }"; - + [Fact] public async Task RequestApplePayPaymentSessionAsync_ResponseIsDeserializedInExpectedFormat() { // Arrange @@ -27,9 +27,9 @@ public async Task RequestApplePayPaymentSessionAsync_ResponseIsDeserializedInExp Domain = "pay.mywebshop.com", ValidationUrl = "https://apple-pay-gateway-cert.apple.com/paymentservices/paymentSession" }; - var mockHttp = this.CreateMockHttpMessageHandler( - HttpMethod.Post, - $"{BaseMollieClient.ApiEndPoint}wallets/applepay/sessions", + var mockHttp = CreateMockHttpMessageHandler( + HttpMethod.Post, + $"{BaseMollieClient.ApiEndPoint}wallets/applepay/sessions", defaultApplePayPaymentSessionResponse); using var walletClient = new WalletClient("abcde", mockHttp.ToHttpClient()); @@ -46,4 +46,4 @@ public async Task RequestApplePayPaymentSessionAsync_ResponseIsDeserializedInExp response.DisplayName.Should().Be("Chuck Norris's Store"); response.Signature.Should().Be("308006092a864886f7...8cc030ad3000000000000"); } -} \ No newline at end of file +}