From 104e56084cd6d2d5c77623ae1d4ae265c1ed1054 Mon Sep 17 00:00:00 2001 From: Vincent Kok Date: Tue, 14 May 2024 16:03:20 +0200 Subject: [PATCH] Fix editorconfig warnings (#358) * Fix editorconfig errors * Fix build warnings * Remove "this." from codebase * Fixing build editor suggestions * Enable nullable references in Blazor project * Fix more editor config issues * WIP: Use ModelName -> Request/Response namespaces everywhere * Use ModelName -> Request/Response namespaces everywhere * Remove unused using statements * Fix null reference issues * 11 warnings to go * Add more XML comments and fix all editorconfig warnings * Fix unit test --- .../Framework/StaticStringListBuilder.cs | 10 +- .../Validators/DecimalPlacesAttribute.cs | 18 +- .../Validators/StaticStringListAttribute.cs | 12 +- .../Models/Customer/CreateCustomerModel.cs | 4 +- .../Models/Mandate/CreateMandateModel.cs | 10 +- .../Order/CreateOrderBillingAddressModel.cs | 30 ++-- .../Models/Order/CreateOrderLineModel.cs | 12 +- .../Models/Order/CreateOrderModel.cs | 28 +-- .../Models/Payment/CreatePaymentModel.cs | 14 +- .../Subscription/CreateSubscriptionModel.cs | 13 +- .../Mollie.WebApplication.Blazor.csproj | 2 +- .../Pages/Customer/Create.razor | 11 +- .../Pages/Customer/Overview.razor | 14 +- .../Pages/Error.cshtml.cs | 10 +- .../Pages/Mandate/Create.razor | 13 +- .../Pages/Mandate/Overview.razor | 18 +- .../Order/Components/OrderAddressEditor.razor | 4 +- .../Order/Components/OrderLineEditor.razor | 8 +- .../Pages/Order/Create.razor | 32 ++-- .../Pages/Order/Overview.razor | 16 +- .../Pages/Payment/Create.razor | 30 ++-- .../Pages/Payment/Overview.razor | 15 +- .../Pages/PaymentMethod/Overview.razor | 6 +- .../Pages/Subscription/Create.razor | 45 ++--- .../Pages/Subscription/Overview.razor | 30 ++-- .../Pages/Terminal/Overview.razor | 12 +- .../Pages/_Host.cshtml | 2 +- .../Mollie.WebApplication.Blazor/Program.cs | 4 +- .../Shared/ApiExceptionDisplay.razor | 4 +- .../Shared/NavMenu.razor | 12 +- .../Shared/OverviewNavigation.razor | 10 +- .../Client/Abstract/IBalanceClient.cs | 85 ++++++++- .../Client/Abstract/ICaptureClient.cs | 6 +- .../Client/Abstract/IChargebacksClient.cs | 6 +- .../Client/Abstract/IConnectClient.cs | 9 +- .../Client/Abstract/ICustomerClient.cs | 7 +- .../Client/Abstract/IInvoicesClient.cs | 7 +- .../Client/Abstract/IMandateClient.cs | 7 +- .../Client/Abstract/IOrderClient.cs | 9 +- .../Client/Abstract/IOrganizationsClient.cs | 4 +- .../Client/Abstract/IPaymentClient.cs | 77 ++++++--- .../Client/Abstract/IPaymentLinkClient.cs | 40 ++++- .../Client/Abstract/IPaymentMethodClient.cs | 50 +++--- .../Client/Abstract/IPermissionsClient.cs | 6 +- .../Client/Abstract/IProfileClient.cs | 6 +- .../Client/Abstract/IRefundClient.cs | 7 +- .../Client/Abstract/ISettlementsClient.cs | 12 +- .../Client/Abstract/IShipmentClient.cs | 7 +- .../Client/Abstract/ISubscriptionClient.cs | 7 +- .../Client/Abstract/ITerminalClient.cs | 4 +- src/Mollie.Api/Client/BalanceClient.cs | 44 ++--- src/Mollie.Api/Client/BaseMollieClient.cs | 18 +- src/Mollie.Api/Client/CaptureClient.cs | 30 ++-- src/Mollie.Api/Client/ChargebacksClient.cs | 30 ++-- src/Mollie.Api/Client/ClientLinkClient.cs | 8 +- src/Mollie.Api/Client/ConnectClient.cs | 33 ++-- src/Mollie.Api/Client/CustomerClient.cs | 41 ++--- src/Mollie.Api/Client/InvoicesClient.cs | 18 +- src/Mollie.Api/Client/MandateClient.cs | 33 ++-- src/Mollie.Api/Client/MollieApiException.cs | 4 +- .../Client/OauthBaseMollieClient.cs | 4 +- src/Mollie.Api/Client/OnboardingClient.cs | 4 +- src/Mollie.Api/Client/OrderClient.cs | 59 +++---- src/Mollie.Api/Client/OrganizationsClient.cs | 18 +- src/Mollie.Api/Client/PaymentClient.cs | 80 ++++----- src/Mollie.Api/Client/PaymentLinkClient.cs | 34 ++-- src/Mollie.Api/Client/PaymentMethodClient.cs | 96 +++++------ src/Mollie.Api/Client/PermissionsClient.cs | 15 +- src/Mollie.Api/Client/ProfileClient.cs | 72 ++++---- src/Mollie.Api/Client/RefundClient.cs | 51 +++--- src/Mollie.Api/Client/SettlementsClient.cs | 48 +++--- src/Mollie.Api/Client/ShipmentClient.cs | 41 ++--- src/Mollie.Api/Client/SubscriptionClient.cs | 55 +++--- src/Mollie.Api/Client/TerminalClient.cs | 18 +- src/Mollie.Api/Client/WalletClient.cs | 6 +- src/Mollie.Api/DependencyInjection.cs | 56 +++--- .../Factories/PaymentResponseFactory.cs | 2 +- .../Framework/JsonConverterService.cs | 4 +- .../BalanceTransactionJsonConverter.cs | 6 +- .../PaymentResponseConverter.cs | 8 +- .../JsonConverters/RawJsonConverter.cs | 6 +- .../SettlementPeriodConverter.cs | 6 +- src/Mollie.Api/Models/Amount.cs | 8 +- .../Capture/Response/CaptureResponse.cs | 8 +- .../Capture/Response/CaptureResponseLinks.cs | 12 +- .../{ => Response}/ChargebackResponse.cs | 8 +- .../{ => Response}/ChargebackResponseLinks.cs | 6 +- .../ChargebackResponseReason.cs | 2 +- .../Connect/{ => Request}/AppPermissions.cs | 2 +- .../{ => Request}/RevokeTokenRequest.cs | 2 +- .../Connect/{ => Request}/TokenRequest.cs | 4 +- .../Models/Connect/{ => Request}/TokenType.cs | 2 +- .../Connect/{ => Response}/TokenResponse.cs | 4 +- .../Customer/{ => Request}/CustomerRequest.cs | 10 +- .../{ => Response}/CustomerResponse.cs | 6 +- .../{ => Response}/CustomerResponseLinks.cs | 8 +- .../Invoice/{ => Response}/InvoiceLine.cs | 4 +- .../Invoice/{ => Response}/InvoiceResponse.cs | 8 +- .../{ => Response}/InvoiceResponseLinks.cs | 4 +- .../Invoice/{ => Response}/InvoiceStatus.cs | 4 +- .../Issuer/{ => Response}/IssuerResponse.cs | 4 +- .../{ => Response}/IssuerResponseImage.cs | 4 +- .../List/{ => Response}/ListResponse.cs | 4 +- .../List/{ => Response}/ListResponseLinks.cs | 4 +- .../Mandate/{ => Request}/MandateRequest.cs | 6 +- .../{ => Request}/PayPalMandateRequest.cs | 2 +- .../SepaDirectDebitMandateRequest.cs | 4 +- .../Mandate/{ => Response}/MandateResponse.cs | 6 +- .../{ => Response}/MandateResponseLinks.cs | 6 +- .../Mandate/{ => Response}/MandateStatus.cs | 4 +- .../ManageOrderLinesAddOperationData.cs | 5 +- .../ManageOrderLinesUpdateOperation.cs | 6 +- .../ManagerOrderLinesCancelOperationData.cs | 5 +- .../Request/OrderLineCancellationRequest.cs | 4 +- .../Models/Order/Request/OrderLineDetails.cs | 2 +- .../Order/Request/OrderLineDetailsCategory.cs | 4 +- .../Order/Request/OrderLineDetailsType.cs | 4 +- .../Models/Order/Request/OrderLineRequest.cs | 6 +- .../Order/Request/OrderLineUpdateRequest.cs | 18 +- .../Order/Request/OrderPaymentRequest.cs | 20 +-- .../Order/Request/OrderRefundRequest.cs | 4 +- .../Models/Order/Request/OrderRequest.cs | 35 ++-- .../Order/Request/OrderUpdateRequest.cs | 12 +- .../Order/Response/OrderEmbeddedResponse.cs | 6 +- .../Order/Response/OrderLineResponse.cs | 30 ++-- .../Order/Response/OrderLineResponseLinks.cs | 6 +- .../Models/Order/Response/OrderLineStatus.cs | 2 +- .../Order/Response/OrderRefundResponse.cs | 4 +- .../Models/Order/Response/OrderResponse.cs | 17 +- .../Order/Response/OrderResponseLinks.cs | 4 +- .../Models/Order/Response/OrderStatus.cs | 4 +- .../Organization/OrganizationResponseLinks.cs | 14 +- .../Models/Payment/Request/PaymentRequest.cs | 50 +++--- .../ApplePayPaymentRequest.cs | 6 +- .../BankTransferPaymentRequest.cs | 6 +- .../CreditCardPaymentRequest.cs | 10 +- .../GiftcardPaymentRequest.cs | 8 +- .../IDealPaymentRequest.cs | 6 +- .../KbcIssuer.cs | 4 +- .../KbcPaymentRequest.cs | 10 +- .../PayPalPaymentRequest.cs | 10 +- .../PaySafeCardPaymentRequest.cs | 6 +- .../Przelewy24PaymentRequest.cs | 6 +- .../SepaDirectDebitRequest.cs | 6 +- .../Payment/Request/PaymentUpdateRequest.cs | 12 +- .../Response/PaymentEmbeddedResponse.cs | 6 +- .../Payment/Response/PaymentResponseLinks.cs | 22 +-- .../BancontactPaymentResponse.cs | 18 +- .../BankTransferPaymentResponse.cs | 8 +- .../BelfiusPaymentResponse.cs | 4 +- .../CreditCardPaymentResponse.cs | 18 +- .../EpsPaymentResponse.cs | 4 +- .../GiftcardPaymentResponse.cs | 10 +- .../GiropayPaymentResponse.cs | 4 +- .../IdealPaymentResponse.cs | 4 +- .../IngHomePayPaymentResponse.cs | 4 +- .../KbcPaymentResponse.cs | 4 +- .../PayPalPaymentResponse.cs | 10 +- .../PaySafeCardPaymentResponse.cs | 4 +- .../PointOfSalePaymentResponse.cs | 16 +- .../SepaDirectDebitResponse.cs | 4 +- .../SofortPaymentResponse.cs | 4 +- .../PaymentLink/Request/PaymentLinkRequest.cs | 6 +- .../FixedPricingResponse.cs | 4 +- .../{ => Response}/PaymentMethodResponse.cs | 11 +- .../PaymentMethodResponseImage.cs | 4 +- .../PaymentMethodResponseLinks.cs | 4 +- .../{Pricing => Response}/PricingResponse.cs | 8 +- .../{ => Response}/PermissionResponse.cs | 4 +- .../{ => Response}/PermissionResponseLInks.cs | 4 +- .../Profile/Response/ProfileResponseLinks.cs | 10 +- .../Refund/{ => Request}/RefundRequest.cs | 6 +- .../Refund/{ => Response}/RefundResponse.cs | 16 +- .../{ => Response}/RefundResponseLinks.cs | 6 +- .../Refund/{ => Response}/RefundStatus.cs | 4 +- .../{ => Response}/SettlementPeriod.cs | 6 +- .../{ => Response}/SettlementPeriodCosts.cs | 6 +- .../SettlementPeriodCostsRate.cs | 2 +- .../{ => Response}/SettlementPeriodRevenue.cs | 6 +- .../{ => Response}/SettlementResponse.cs | 6 +- .../{ => Response}/SettlementResponseLinks.cs | 11 +- .../{ => Response}/SettlementStatus.cs | 4 +- .../Shipment/Request/ShipmentLineRequest.cs | 4 +- .../Shipment/Request/ShipmentRequest.cs | 5 +- .../Shipment/Request/ShipmentUpdateRequest.cs | 6 +- .../Shipment/Response/ShipmentResponse.cs | 6 +- .../Response/ShipmentResponseLinks.cs | 4 +- .../Models/Shipment/TrackingObject.cs | 2 +- .../{ => Request}/SubscriptionRequest.cs | 20 +-- .../SubscriptionUpdateRequest.cs | 8 +- .../{ => Response}/SubscriptionResponse.cs | 8 +- .../SubscriptionResponseLinks.cs | 10 +- .../{ => Response}/SubscriptionStatus.cs | 4 +- .../{ => Response}/TerminalResponse.cs | 28 +-- .../{ => Response}/TerminalResponseLinks.cs | 2 +- src/Mollie.Api/Models/Url/UrlObjectLink.cs | 5 +- .../Api/ApiExceptionTests.cs | 8 +- .../Api/BalanceTests.cs | 40 ++--- .../Api/CaptureTests.cs | 22 +-- .../Api/ConnectTests.cs | 31 ++-- .../Api/CustomerTests.cs | 47 ++--- .../Api/MandateTests.cs | 31 ++-- .../Api/OrderTests.cs | 142 +++++++-------- .../Api/PaymentLinkTests.cs | 26 +-- .../Api/PaymentMethodTests.cs | 44 ++--- .../Api/PaymentTests.cs | 144 ++++++++-------- .../Api/ProfileTests.cs | 22 +-- .../Api/RefundTests.cs | 54 +++--- .../Api/ShipmentTests.cs | 23 +-- .../Api/SubscriptionTests.cs | 59 +++---- .../Api/TerminalTests.cs | 12 +- .../Framework/BaseMollieApiTestClass.cs | 20 +-- .../Client/BalanceClientTests.cs | 36 ++-- .../Client/BaseClientTests.cs | 4 +- .../Client/CaptureClientTests.cs | 32 ++-- .../Client/ChargebacksClientTests.cs | 30 ++-- .../Client/ClientLinkClientTests.cs | 3 +- .../Client/ConnectClientTests.cs | 11 +- .../Client/CustomerClientTests.cs | 27 +-- .../Client/MandateClientTests.cs | 28 +-- .../Client/OnboardingClientTests.cs | 6 +- .../Client/OrderClientTests.cs | 80 ++++----- .../Client/PaymentClientTests.cs | 162 +++++++++--------- .../Client/PaymentLinkClientTests.cs | 27 ++- .../Client/PaymentMethodClientTests.cs | 12 +- .../Client/PermissionClientTests.cs | 5 +- .../Client/ProfileClientTests.cs | 55 +++--- .../Client/RefundClientTests.cs | 16 +- .../Client/SettlementClientTests.cs | 30 ++-- .../Client/ShipmentClientTests.cs | 46 ++--- .../Client/SubscriptionClientTests.cs | 52 +++--- .../Client/TerminalClientTests.cs | 28 +-- .../Client/WalletClientTest.cs | 12 +- .../Framework/AmountConversionTests.cs | 1 + .../Factories/PaymentResponseFactoryTests.cs | 2 +- 235 files changed, 2121 insertions(+), 1944 deletions(-) rename src/Mollie.Api/Models/Chargeback/{ => Response}/ChargebackResponse.cs (93%) rename src/Mollie.Api/Models/Chargeback/{ => Response}/ChargebackResponseLinks.cs (90%) rename src/Mollie.Api/Models/Chargeback/{ => Response}/ChargebackResponseReason.cs (90%) rename src/Mollie.Api/Models/Connect/{ => Request}/AppPermissions.cs (96%) rename src/Mollie.Api/Models/Connect/{ => Request}/RevokeTokenRequest.cs (89%) rename src/Mollie.Api/Models/Connect/{ => Request}/TokenRequest.cs (97%) rename src/Mollie.Api/Models/Connect/{ => Request}/TokenType.cs (76%) rename src/Mollie.Api/Models/Connect/{ => Response}/TokenResponse.cs (96%) rename src/Mollie.Api/Models/Customer/{ => Request}/CustomerRequest.cs (90%) rename src/Mollie.Api/Models/Customer/{ => Response}/CustomerResponse.cs (97%) rename src/Mollie.Api/Models/Customer/{ => Response}/CustomerResponseLinks.cs (87%) rename src/Mollie.Api/Models/Invoice/{ => Response}/InvoiceLine.cs (93%) rename src/Mollie.Api/Models/Invoice/{ => Response}/InvoiceResponse.cs (94%) rename src/Mollie.Api/Models/Invoice/{ => Response}/InvoiceResponseLinks.cs (92%) rename src/Mollie.Api/Models/Invoice/{ => Response}/InvoiceStatus.cs (75%) rename src/Mollie.Api/Models/Issuer/{ => Response}/IssuerResponse.cs (94%) rename src/Mollie.Api/Models/Issuer/{ => Response}/IssuerResponseImage.cs (86%) rename src/Mollie.Api/Models/List/{ => Response}/ListResponse.cs (90%) rename src/Mollie.Api/Models/List/{ => Response}/ListResponseLinks.cs (95%) rename src/Mollie.Api/Models/Mandate/{ => Request}/MandateRequest.cs (94%) rename src/Mollie.Api/Models/Mandate/{ => Request}/PayPalMandateRequest.cs (92%) rename src/Mollie.Api/Models/Mandate/{ => Request}/SepaDirectDebitMandateRequest.cs (87%) rename src/Mollie.Api/Models/Mandate/{ => Response}/MandateResponse.cs (97%) rename src/Mollie.Api/Models/Mandate/{ => Response}/MandateResponseLinks.cs (86%) rename src/Mollie.Api/Models/Mandate/{ => Response}/MandateStatus.cs (78%) rename src/Mollie.Api/Models/Payment/Request/{ => PaymentSpecificParameters}/ApplePayPaymentRequest.cs (78%) rename src/Mollie.Api/Models/Payment/Request/{ => PaymentSpecificParameters}/BankTransferPaymentRequest.cs (87%) rename src/Mollie.Api/Models/Payment/Request/{ => PaymentSpecificParameters}/CreditCardPaymentRequest.cs (80%) rename src/Mollie.Api/Models/Payment/Request/{ => PaymentSpecificParameters}/GiftcardPaymentRequest.cs (82%) rename src/Mollie.Api/Models/Payment/Request/{ => PaymentSpecificParameters}/IDealPaymentRequest.cs (76%) rename src/Mollie.Api/Models/Payment/Request/{ => PaymentSpecificParameters}/KbcIssuer.cs (61%) rename src/Mollie.Api/Models/Payment/Request/{ => PaymentSpecificParameters}/KbcPaymentRequest.cs (70%) rename src/Mollie.Api/Models/Payment/Request/{ => PaymentSpecificParameters}/PayPalPaymentRequest.cs (82%) rename src/Mollie.Api/Models/Payment/Request/{ => PaymentSpecificParameters}/PaySafeCardPaymentRequest.cs (72%) rename src/Mollie.Api/Models/Payment/Request/{ => PaymentSpecificParameters}/Przelewy24PaymentRequest.cs (72%) rename src/Mollie.Api/Models/Payment/Request/{ => PaymentSpecificParameters}/SepaDirectDebitRequest.cs (77%) rename src/Mollie.Api/Models/Payment/Response/{Specific => PaymentSpecificParameters}/BancontactPaymentResponse.cs (86%) rename src/Mollie.Api/Models/Payment/Response/{Specific => PaymentSpecificParameters}/BankTransferPaymentResponse.cs (95%) rename src/Mollie.Api/Models/Payment/Response/{Specific => PaymentSpecificParameters}/BelfiusPaymentResponse.cs (90%) rename src/Mollie.Api/Models/Payment/Response/{Specific => PaymentSpecificParameters}/CreditCardPaymentResponse.cs (95%) rename src/Mollie.Api/Models/Payment/Response/{Specific => PaymentSpecificParameters}/EpsPaymentResponse.cs (91%) rename src/Mollie.Api/Models/Payment/Response/{Specific => PaymentSpecificParameters}/GiftcardPaymentResponse.cs (90%) rename src/Mollie.Api/Models/Payment/Response/{Specific => PaymentSpecificParameters}/GiropayPaymentResponse.cs (91%) rename src/Mollie.Api/Models/Payment/Response/{Specific => PaymentSpecificParameters}/IdealPaymentResponse.cs (93%) rename src/Mollie.Api/Models/Payment/Response/{Specific => PaymentSpecificParameters}/IngHomePayPaymentResponse.cs (91%) rename src/Mollie.Api/Models/Payment/Response/{Specific => PaymentSpecificParameters}/KbcPaymentResponse.cs (90%) rename src/Mollie.Api/Models/Payment/Response/{Specific => PaymentSpecificParameters}/PayPalPaymentResponse.cs (91%) rename src/Mollie.Api/Models/Payment/Response/{Specific => PaymentSpecificParameters}/PaySafeCardPaymentResponse.cs (83%) rename src/Mollie.Api/Models/Payment/Response/{Specific => PaymentSpecificParameters}/PointOfSalePaymentResponse.cs (94%) rename src/Mollie.Api/Models/Payment/Response/{Specific => PaymentSpecificParameters}/SepaDirectDebitResponse.cs (97%) rename src/Mollie.Api/Models/Payment/Response/{Specific => PaymentSpecificParameters}/SofortPaymentResponse.cs (90%) rename src/Mollie.Api/Models/PaymentMethod/{Pricing => Response}/FixedPricingResponse.cs (86%) rename src/Mollie.Api/Models/PaymentMethod/{ => Response}/PaymentMethodResponse.cs (90%) rename src/Mollie.Api/Models/PaymentMethod/{ => Response}/PaymentMethodResponseImage.cs (93%) rename src/Mollie.Api/Models/PaymentMethod/{ => Response}/PaymentMethodResponseLinks.cs (89%) rename src/Mollie.Api/Models/PaymentMethod/{Pricing => Response}/PricingResponse.cs (84%) rename src/Mollie.Api/Models/Permission/{ => Response}/PermissionResponse.cs (95%) rename src/Mollie.Api/Models/Permission/{ => Response}/PermissionResponseLInks.cs (89%) rename src/Mollie.Api/Models/Refund/{ => Request}/RefundRequest.cs (96%) rename src/Mollie.Api/Models/Refund/{ => Response}/RefundResponse.cs (92%) rename src/Mollie.Api/Models/Refund/{ => Response}/RefundResponseLinks.cs (90%) rename src/Mollie.Api/Models/Refund/{ => Response}/RefundStatus.cs (85%) rename src/Mollie.Api/Models/Settlement/{ => Response}/SettlementPeriod.cs (93%) rename src/Mollie.Api/Models/Settlement/{ => Response}/SettlementPeriodCosts.cs (93%) rename src/Mollie.Api/Models/Settlement/{ => Response}/SettlementPeriodCostsRate.cs (87%) rename src/Mollie.Api/Models/Settlement/{ => Response}/SettlementPeriodRevenue.cs (92%) rename src/Mollie.Api/Models/Settlement/{ => Response}/SettlementResponse.cs (96%) rename src/Mollie.Api/Models/Settlement/{ => Response}/SettlementResponseLinks.cs (86%) rename src/Mollie.Api/Models/Settlement/{ => Response}/SettlementStatus.cs (79%) rename src/Mollie.Api/Models/Subscription/{ => Request}/SubscriptionRequest.cs (95%) rename src/Mollie.Api/Models/Subscription/{ => Request}/SubscriptionUpdateRequest.cs (94%) rename src/Mollie.Api/Models/Subscription/{ => Response}/SubscriptionResponse.cs (97%) rename src/Mollie.Api/Models/Subscription/{ => Response}/SubscriptionResponseLinks.cs (87%) rename src/Mollie.Api/Models/Subscription/{ => Response}/SubscriptionStatus.cs (84%) rename src/Mollie.Api/Models/Terminal/{ => Response}/TerminalResponse.cs (90%) rename src/Mollie.Api/Models/Terminal/{ => Response}/TerminalResponseLinks.cs (93%) diff --git a/samples/Mollie.WebApplication.Blazor/Framework/StaticStringListBuilder.cs b/samples/Mollie.WebApplication.Blazor/Framework/StaticStringListBuilder.cs index caebd758..8caf81c7 100644 --- a/samples/Mollie.WebApplication.Blazor/Framework/StaticStringListBuilder.cs +++ b/samples/Mollie.WebApplication.Blazor/Framework/StaticStringListBuilder.cs @@ -1,12 +1,14 @@ using System.Reflection; -namespace Mollie.WebApplication.Blazor.Framework; +namespace Mollie.WebApplication.Blazor.Framework; public static class StaticStringListBuilder { public static IEnumerable GetStaticStringList(Type type) { foreach (FieldInfo fieldInfo in type.GetFields(BindingFlags.Static | BindingFlags.Public)) { - string value = fieldInfo.GetValue(null).ToString(); - yield return value; + string? value = fieldInfo.GetValue(null)?.ToString(); + if (value != null) { + yield return value; + } } } -} \ No newline at end of file +} diff --git a/samples/Mollie.WebApplication.Blazor/Framework/Validators/DecimalPlacesAttribute.cs b/samples/Mollie.WebApplication.Blazor/Framework/Validators/DecimalPlacesAttribute.cs index 1ce3abfc..38a1ec80 100644 --- a/samples/Mollie.WebApplication.Blazor/Framework/Validators/DecimalPlacesAttribute.cs +++ b/samples/Mollie.WebApplication.Blazor/Framework/Validators/DecimalPlacesAttribute.cs @@ -1,27 +1,31 @@ using System.ComponentModel.DataAnnotations; using System.Globalization; -namespace Mollie.WebApplication.Blazor.Framework.Validators; +namespace Mollie.WebApplication.Blazor.Framework.Validators; public class DecimalPlacesAttribute : ValidationAttribute { - public int DecimalPlaces { get; } + private int _decimalPlaces { get; } public DecimalPlacesAttribute(int decimalPlaces) { - DecimalPlaces = decimalPlaces; + _decimalPlaces = decimalPlaces; } - protected override ValidationResult IsValid(object value, ValidationContext validationContext) { + protected override ValidationResult? IsValid(object? value, ValidationContext validationContext) { + if (value == null) { + return new ValidationResult("Value is null"); + } + decimal amount = (decimal)value; string text = amount.ToString(CultureInfo.InvariantCulture); int dotIndex = text.IndexOf('.'); var decimals = text.Length - dotIndex - 1; - var places = DecimalPlaces switch + var places = _decimalPlaces switch { 0 => "without decimal places", 1 => "with one decimal place", - _ => $"with {DecimalPlaces} decimal places" + _ => $"with {_decimalPlaces} decimal places" }; - return dotIndex < 0 || dotIndex != text.LastIndexOf('.') || decimals != DecimalPlaces + return dotIndex < 0 || dotIndex != text.LastIndexOf('.') || decimals != _decimalPlaces ? new ValidationResult(ErrorMessage ?? $"Please enter an amount {places}") : ValidationResult.Success; } diff --git a/samples/Mollie.WebApplication.Blazor/Framework/Validators/StaticStringListAttribute.cs b/samples/Mollie.WebApplication.Blazor/Framework/Validators/StaticStringListAttribute.cs index c0eebf77..6adce01a 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 + protected override ValidationResult? IsValid(object? value, ValidationContext validationContext) { + IEnumerable validValues = _staticClass .GetFields(BindingFlags.Static | BindingFlags.Public) - .Select(x => x.GetValue(null).ToString()); + .Select(x => x.GetValue(null)?.ToString()); if (validValues.Contains(value)) { return ValidationResult.Success; } - + return new ValidationResult($"The value \"{value}\" is invalid"); } } diff --git a/samples/Mollie.WebApplication.Blazor/Models/Customer/CreateCustomerModel.cs b/samples/Mollie.WebApplication.Blazor/Models/Customer/CreateCustomerModel.cs index 135f9db5..1f037fc1 100644 --- a/samples/Mollie.WebApplication.Blazor/Models/Customer/CreateCustomerModel.cs +++ b/samples/Mollie.WebApplication.Blazor/Models/Customer/CreateCustomerModel.cs @@ -4,8 +4,8 @@ namespace Mollie.WebApplication.Blazor.Models.Customer; public class CreateCustomerModel { [Required] - public string Name { get; set; } + public required string Name { get; set; } [EmailAddress] - public string Email { get; set; } + public required string Email { get; set; } } diff --git a/samples/Mollie.WebApplication.Blazor/Models/Mandate/CreateMandateModel.cs b/samples/Mollie.WebApplication.Blazor/Models/Mandate/CreateMandateModel.cs index f93ca90b..c897bedd 100644 --- a/samples/Mollie.WebApplication.Blazor/Models/Mandate/CreateMandateModel.cs +++ b/samples/Mollie.WebApplication.Blazor/Models/Mandate/CreateMandateModel.cs @@ -1,11 +1,11 @@ using System.ComponentModel.DataAnnotations; -namespace Mollie.WebApplication.Blazor.Models.Mandate; +namespace Mollie.WebApplication.Blazor.Models.Mandate; public class CreateMandateModel { [Required] - public string ConsumerName { get; set; } - + public required string ConsumerName { get; set; } + [Required] - public string ConsumerAccount { get; set; } -} \ No newline at end of file + public required string ConsumerAccount { get; set; } +} diff --git a/samples/Mollie.WebApplication.Blazor/Models/Order/CreateOrderBillingAddressModel.cs b/samples/Mollie.WebApplication.Blazor/Models/Order/CreateOrderBillingAddressModel.cs index 716c2ad7..a882e15c 100644 --- a/samples/Mollie.WebApplication.Blazor/Models/Order/CreateOrderBillingAddressModel.cs +++ b/samples/Mollie.WebApplication.Blazor/Models/Order/CreateOrderBillingAddressModel.cs @@ -1,28 +1,28 @@ using System.ComponentModel.DataAnnotations; -namespace Mollie.WebApplication.Blazor.Models.Order; +namespace Mollie.WebApplication.Blazor.Models.Order; public class CreateOrderBillingAddressModel { [Required] - public string GivenName { get; set; } - + public required string GivenName { get; set; } + [Required] - public string FamilyName { get; set; } - + public required string FamilyName { get; set; } + [Required] [EmailAddress] - public string Email { get; set; } - + public required string Email { get; set; } + [Required] - public string StreetAndNumber { get; set; } - + public required string StreetAndNumber { get; set; } + [Required] - public string City { get; set; } - + public required string City { get; set; } + [Required] [MaxLength(2)] - public string Country { get; set; } - + public required string Country { get; set; } + [Required] - public string PostalCode { get; set; } -} \ No newline at end of file + public required string PostalCode { get; set; } +} diff --git a/samples/Mollie.WebApplication.Blazor/Models/Order/CreateOrderLineModel.cs b/samples/Mollie.WebApplication.Blazor/Models/Order/CreateOrderLineModel.cs index 4dcf8170..309c1630 100644 --- a/samples/Mollie.WebApplication.Blazor/Models/Order/CreateOrderLineModel.cs +++ b/samples/Mollie.WebApplication.Blazor/Models/Order/CreateOrderLineModel.cs @@ -1,25 +1,25 @@ using System.ComponentModel.DataAnnotations; using Mollie.WebApplication.Blazor.Framework.Validators; -namespace Mollie.WebApplication.Blazor.Models.Order; +namespace Mollie.WebApplication.Blazor.Models.Order; public class CreateOrderLineModel { [Required] - public string Name { get; set; } + public string Name { get; set; } = string.Empty; [Required] [Range(1, 100, ErrorMessage = "Please enter a quantity between 0.01 and 1000")] public int Quantity { get; set; } - + [Required] [Range(0.01, 10000, ErrorMessage = "Please enter a unit price between 0.01 and 10000")] [DecimalPlaces(2)] public decimal UnitPrice { get; set; } - + public decimal TotalAmount { get; set; } - + [Range(0.01, 100, ErrorMessage = "Please enter a vat rate between 0.01 and 100")] [DecimalPlaces(2)] public decimal VatRate { get; set; } public decimal VatAmount { get; set; } -} \ No newline at end of file +} diff --git a/samples/Mollie.WebApplication.Blazor/Models/Order/CreateOrderModel.cs b/samples/Mollie.WebApplication.Blazor/Models/Order/CreateOrderModel.cs index 16d36cf7..6ea22639 100644 --- a/samples/Mollie.WebApplication.Blazor/Models/Order/CreateOrderModel.cs +++ b/samples/Mollie.WebApplication.Blazor/Models/Order/CreateOrderModel.cs @@ -2,25 +2,27 @@ using Mollie.Api.Models; using Mollie.WebApplication.Blazor.Framework.Validators; -namespace Mollie.WebApplication.Blazor.Models.Order; +namespace Mollie.WebApplication.Blazor.Models.Order; public class CreateOrderModel { [Required] - public string OrderNumber { get; set; } - + public string? OrderNumber { get; set; } + + [Required] + public string? Locale { get; set; } + [Required] - public string Locale { get; set; } - public decimal Amount { get; set; } + public decimal? Amount { get; set; } [Required] [StaticStringList(typeof(Currency))] - public string Currency { get; set; } - + public required string Currency { get; set; } + [Required] [Url] - public string RedirectUrl { get; set; } - - public List Lines { get; set; } - - public CreateOrderBillingAddressModel BillingAddress { get; set; } -} \ No newline at end of file + public required string RedirectUrl { get; set; } + + public List? Lines { get; set; } = new(); + + public required CreateOrderBillingAddressModel BillingAddress { get; set; } +} diff --git a/samples/Mollie.WebApplication.Blazor/Models/Payment/CreatePaymentModel.cs b/samples/Mollie.WebApplication.Blazor/Models/Payment/CreatePaymentModel.cs index 272b2c7d..5ec687ef 100644 --- a/samples/Mollie.WebApplication.Blazor/Models/Payment/CreatePaymentModel.cs +++ b/samples/Mollie.WebApplication.Blazor/Models/Payment/CreatePaymentModel.cs @@ -2,22 +2,22 @@ using Mollie.Api.Models; using Mollie.WebApplication.Blazor.Framework.Validators; -namespace Mollie.WebApplication.Blazor.Models.Payment; +namespace Mollie.WebApplication.Blazor.Models.Payment; public class CreatePaymentModel { [Required] [Range(0.01, 1000, ErrorMessage = "Please enter an amount between 0.01 and 1000")] [DecimalPlaces(2)] - public decimal Amount { get; set; } + public required decimal Amount { get; set; } [Required] [StaticStringList(typeof(Currency))] - public string Currency { get; set; } - + public required string Currency { get; set; } + [Required] [Url] - public string RedirectUrl { get; set; } + public required string RedirectUrl { get; set; } [Required] - public string Description { get; set; } -} \ No newline at end of file + public required string Description { get; set; } +} diff --git a/samples/Mollie.WebApplication.Blazor/Models/Subscription/CreateSubscriptionModel.cs b/samples/Mollie.WebApplication.Blazor/Models/Subscription/CreateSubscriptionModel.cs index 43fab675..e16f4a8a 100644 --- a/samples/Mollie.WebApplication.Blazor/Models/Subscription/CreateSubscriptionModel.cs +++ b/samples/Mollie.WebApplication.Blazor/Models/Subscription/CreateSubscriptionModel.cs @@ -2,18 +2,17 @@ using Mollie.Api.Models; using Mollie.WebApplication.Blazor.Framework.Validators; -namespace Mollie.WebApplication.Blazor.Models.Subscription; - +namespace Mollie.WebApplication.Blazor.Models.Subscription; public class CreateSubscriptionModel { [Required] [Range(0.01, 1000, ErrorMessage = "Please enter an amount between 0.01 and 1000")] [DecimalPlaces(2)] - public decimal Amount { get; set; } = default!; + public required decimal Amount { get; set; } [Required] [StaticStringList(typeof(Currency))] - public string Currency { get; set; } + public required string Currency { get; set; } [Range(1, 10)] public int? Times { get; set; } @@ -25,8 +24,8 @@ public class CreateSubscriptionModel { [Required] [Display(Name = "Interval period")] - public IntervalPeriod IntervalPeriod { get; set; } + public required IntervalPeriod IntervalPeriod { get; set; } [Required] - public string Description { get; set; } -} \ No newline at end of file + public required string Description { get; set; } +} diff --git a/samples/Mollie.WebApplication.Blazor/Mollie.WebApplication.Blazor.csproj b/samples/Mollie.WebApplication.Blazor/Mollie.WebApplication.Blazor.csproj index 30f359cb..3f922832 100644 --- a/samples/Mollie.WebApplication.Blazor/Mollie.WebApplication.Blazor.csproj +++ b/samples/Mollie.WebApplication.Blazor/Mollie.WebApplication.Blazor.csproj @@ -2,7 +2,7 @@ net8.0 - disable + enable enable 51758f49-d7ec-4044-8cd9-95cf49d0f3cf diff --git a/samples/Mollie.WebApplication.Blazor/Pages/Customer/Create.razor b/samples/Mollie.WebApplication.Blazor/Pages/Customer/Create.razor index b5ebdbf1..1c63a118 100644 --- a/samples/Mollie.WebApplication.Blazor/Pages/Customer/Create.razor +++ b/samples/Mollie.WebApplication.Blazor/Pages/Customer/Create.razor @@ -2,6 +2,7 @@ @using Mollie.WebApplication.Blazor.Models.Customer @using Mollie.Api.Client +@using Mollie.Api.Models.Customer.Request @inject ICustomerClient CustomerClient @inject NavigationManager NavigationManager @@ -36,17 +37,17 @@ @code { - private MollieApiException _apiException = null; - + private MollieApiException? _apiException; + private CreateCustomerModel _customer = new() { Name = "Customer name", Email = "customer@customer.customer" }; - + private async Task OnSave() { try { _apiException = null; - + await CustomerClient.CreateCustomerAsync(new CustomerRequest() { Name = _customer.Name, Email = _customer.Email @@ -58,4 +59,4 @@ _apiException = e; } } -} \ No newline at end of file +} diff --git a/samples/Mollie.WebApplication.Blazor/Pages/Customer/Overview.razor b/samples/Mollie.WebApplication.Blazor/Pages/Customer/Overview.razor index d8e9cb37..41247f07 100644 --- a/samples/Mollie.WebApplication.Blazor/Pages/Customer/Overview.razor +++ b/samples/Mollie.WebApplication.Blazor/Pages/Customer/Overview.razor @@ -1,4 +1,6 @@ @page "/customer/overview" +@using Mollie.Api.Models.Customer.Response +@using Mollie.Api.Models.List.Response @inject ICustomerClient CustomerClient @@ -11,7 +13,7 @@ else { - + @@ -39,7 +41,7 @@ else { }
- + @@ -49,9 +51,9 @@ else { @code { [Parameter] [SupplyParameterFromQuery] - public string Url { get; set; } - - private ListResponse _customers = null; + public string? Url { get; set; } + + private ListResponse? _customers; protected override async Task OnParametersSetAsync() { await LoadData(); @@ -68,4 +70,4 @@ else { }); } } -} \ No newline at end of file +} diff --git a/samples/Mollie.WebApplication.Blazor/Pages/Error.cshtml.cs b/samples/Mollie.WebApplication.Blazor/Pages/Error.cshtml.cs index 46aa84c7..b9d9c3ee 100644 --- a/samples/Mollie.WebApplication.Blazor/Pages/Error.cshtml.cs +++ b/samples/Mollie.WebApplication.Blazor/Pages/Error.cshtml.cs @@ -7,17 +7,11 @@ namespace Mollie.WebApplication.Blazor.Pages; [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] [IgnoreAntiforgeryToken] public class ErrorModel : PageModel { - public string RequestId { get; set; } + public string? RequestId { get; set; } public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); - private readonly ILogger _logger; - - public ErrorModel(ILogger logger) { - _logger = logger; - } - public void OnGet() { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; } -} \ No newline at end of file +} diff --git a/samples/Mollie.WebApplication.Blazor/Pages/Mandate/Create.razor b/samples/Mollie.WebApplication.Blazor/Pages/Mandate/Create.razor index ce543b6d..38a2af73 100644 --- a/samples/Mollie.WebApplication.Blazor/Pages/Mandate/Create.razor +++ b/samples/Mollie.WebApplication.Blazor/Pages/Mandate/Create.razor @@ -1,6 +1,7 @@ @page "/customer/{customerId}/mandate/create" @using Mollie.WebApplication.Blazor.Models.Mandate @using Mollie.Api.Client +@using Mollie.Api.Models.Mandate.Request @inject IMandateClient MandateClient @inject NavigationManager NavigationManager @@ -45,11 +46,11 @@ @code { - private MollieApiException _apiException = null; - + private MollieApiException? _apiException; + [Parameter] - public string CustomerId { get; set; } - + public required string CustomerId { get; set; } + private CreateMandateModel _mandate = new() { ConsumerName = "Consumer name", ConsumerAccount = "" @@ -58,7 +59,7 @@ private async Task OnSave() { try { _apiException = null; - + await MandateClient.CreateMandateAsync(CustomerId, new SepaDirectDebitMandateRequest { Method = PaymentMethod.DirectDebit, ConsumerName = _mandate.ConsumerName, @@ -71,4 +72,4 @@ _apiException = e; } } -} \ No newline at end of file +} diff --git a/samples/Mollie.WebApplication.Blazor/Pages/Mandate/Overview.razor b/samples/Mollie.WebApplication.Blazor/Pages/Mandate/Overview.razor index 15e8fa24..53c11715 100644 --- a/samples/Mollie.WebApplication.Blazor/Pages/Mandate/Overview.razor +++ b/samples/Mollie.WebApplication.Blazor/Pages/Mandate/Overview.razor @@ -1,4 +1,6 @@ @page "/customer/{customerId}/mandate/overview" +@using Mollie.Api.Models.List.Response +@using Mollie.Api.Models.Mandate.Response @inject IMandateClient MandateClient @@ -11,7 +13,7 @@ else { - + @@ -32,7 +34,7 @@ else { }
- + @@ -41,13 +43,13 @@ else { @code { [Parameter] - public string CustomerId { get; set; } - + public required string CustomerId { get; set; } + [Parameter] [SupplyParameterFromQuery] - public string Url { get; set; } - - private ListResponse _mandates = null; + public string? Url { get; set; } + + private ListResponse? _mandates; protected override async Task OnParametersSetAsync() { await LoadData(); @@ -64,4 +66,4 @@ else { }); } } -} \ No newline at end of file +} diff --git a/samples/Mollie.WebApplication.Blazor/Pages/Order/Components/OrderAddressEditor.razor b/samples/Mollie.WebApplication.Blazor/Pages/Order/Components/OrderAddressEditor.razor index d6d02993..31407025 100644 --- a/samples/Mollie.WebApplication.Blazor/Pages/Order/Components/OrderAddressEditor.razor +++ b/samples/Mollie.WebApplication.Blazor/Pages/Order/Components/OrderAddressEditor.razor @@ -66,5 +66,5 @@ @code { [Parameter, EditorRequired] - public CreateOrderBillingAddressModel Address { get; set; } -} \ No newline at end of file + public required CreateOrderBillingAddressModel Address { get; set; } +} diff --git a/samples/Mollie.WebApplication.Blazor/Pages/Order/Components/OrderLineEditor.razor b/samples/Mollie.WebApplication.Blazor/Pages/Order/Components/OrderLineEditor.razor index c50dde41..52363324 100644 --- a/samples/Mollie.WebApplication.Blazor/Pages/Order/Components/OrderLineEditor.razor +++ b/samples/Mollie.WebApplication.Blazor/Pages/Order/Components/OrderLineEditor.razor @@ -3,7 +3,7 @@ - + @@ -81,9 +81,9 @@ @code { [Parameter, EditorRequired] - public IList OrderLines { get; set; } + public required IList OrderLines { get; set; } - private CreateOrderLineModel _newOrderLineModel = new CreateOrderLineModel(); + private CreateOrderLineModel _newOrderLineModel = new (); private void OnAddOrderLine() { decimal totalAmount = _newOrderLineModel.Quantity * _newOrderLineModel.UnitPrice; @@ -98,4 +98,4 @@ private void OnRemoveOrderLine(CreateOrderLineModel orderLine) { OrderLines.Remove(orderLine); } -} \ No newline at end of file +} diff --git a/samples/Mollie.WebApplication.Blazor/Pages/Order/Create.razor b/samples/Mollie.WebApplication.Blazor/Pages/Order/Create.razor index 7aafee89..aa8d9910 100644 --- a/samples/Mollie.WebApplication.Blazor/Pages/Order/Create.razor +++ b/samples/Mollie.WebApplication.Blazor/Pages/Order/Create.razor @@ -4,6 +4,7 @@ @using Mollie.WebApplication.Blazor.Models.Order @using System.Globalization @using Mollie.Api.Client +@using Mollie.Api.Models.Order.Request @inject IOrderClient OrderClient @inject NavigationManager NavigationManager @@ -15,7 +16,7 @@ - +
- +
- +
Billing address
- +
Order lines
@@ -68,15 +69,16 @@
@code { - private MollieApiException _apiException = null; - - private CreateOrderModel _order = new() { + private MollieApiException? _apiException; + + private readonly CreateOrderModel _order = new() { OrderNumber = "Order number", Locale = Locale.nl_NL, + Amount = 100m, Currency = "EUR", RedirectUrl = "https://www.mollie.com/", Lines = new List { - new CreateOrderLineModel { + new() { Name = "Chocolates", UnitPrice = 100.00m, Quantity = 1, @@ -95,15 +97,15 @@ StreetAndNumber = "Keizersgracht 126" } }; - + private async Task OnSave() { try { _apiException = null; - + await OrderClient.CreateOrderAsync(new OrderRequest { - OrderNumber = _order.OrderNumber, - Locale = _order.Locale, - Amount = new Amount(_order.Currency, _order.Lines.Sum(lines => lines.TotalAmount)), + OrderNumber = _order.OrderNumber!, + Locale = _order.Locale!, + Amount = new Amount(_order.Currency, _order.Lines!.Sum(lines => lines.TotalAmount)), RedirectUrl = _order.RedirectUrl, BillingAddress = new OrderAddressDetails { GivenName = _order.BillingAddress.GivenName, @@ -114,7 +116,7 @@ City = _order.BillingAddress.City, Country = _order.BillingAddress.Country }, - Lines = _order.Lines.Select(line => new OrderLineRequest { + Lines = _order.Lines!.Select(line => new OrderLineRequest { Name = line.Name, Quantity = line.Quantity, UnitPrice = new Amount(_order.Currency, line.UnitPrice), @@ -130,4 +132,4 @@ _apiException = e; } } -} \ No newline at end of file +} diff --git a/samples/Mollie.WebApplication.Blazor/Pages/Order/Overview.razor b/samples/Mollie.WebApplication.Blazor/Pages/Order/Overview.razor index 6b26c9a9..0ce7fad5 100644 --- a/samples/Mollie.WebApplication.Blazor/Pages/Order/Overview.razor +++ b/samples/Mollie.WebApplication.Blazor/Pages/Order/Overview.razor @@ -1,4 +1,6 @@ @page "/order/overview" +@using Mollie.Api.Models.Order.Response +@using Mollie.Api.Models.List.Response @inject IOrderClient OrderClient @@ -11,7 +13,7 @@ else { - +
@@ -34,7 +36,7 @@ else { @@ -42,7 +44,7 @@ else { }
@order.Method @order.Metadata - @if (order.Status == OrderStatus.Created) { + @if (order.Status == OrderStatus.Created && order.Links.Checkout != null) { Pay }
- + @@ -52,9 +54,9 @@ else { @code { [Parameter] [SupplyParameterFromQuery] - public string Url { get; set; } - - private ListResponse _orders = null; + public string? Url { get; set; } + + private ListResponse? _orders; protected override async Task OnParametersSetAsync() { await LoadData(); @@ -71,4 +73,4 @@ else { }); } } -} \ No newline at end of file +} diff --git a/samples/Mollie.WebApplication.Blazor/Pages/Payment/Create.razor b/samples/Mollie.WebApplication.Blazor/Pages/Payment/Create.razor index 2be18417..42e00b6c 100644 --- a/samples/Mollie.WebApplication.Blazor/Pages/Payment/Create.razor +++ b/samples/Mollie.WebApplication.Blazor/Pages/Payment/Create.razor @@ -11,16 +11,16 @@ - + - +
+ @bind-Value="_model.Amount">
@@ -29,7 +29,7 @@ + @bind-Value="_model.Currency"> @foreach (string currency in StaticStringListBuilder.GetStaticStringList(typeof(Currency))) { } @@ -41,7 +41,7 @@ + @bind-Value="_model.RedirectUrl"> @@ -50,7 +50,7 @@ + @bind-Value="_model.Description"> @@ -58,23 +58,23 @@
@code { - private MollieApiException _apiException = null; - - private CreatePaymentModel model = new() { + private MollieApiException? _apiException; + + private CreatePaymentModel _model = new() { Amount = 10.00m, Currency = "EUR", RedirectUrl = "https://www.mollie.com/", Description = "A payment from the example application" }; - + private async Task OnSave() { try { _apiException = null; - + await PaymentClient.CreatePaymentAsync(new PaymentRequest { - Amount = new Amount(model.Currency, model.Amount), - RedirectUrl = model.RedirectUrl, - Description = model.Description + Amount = new Amount(_model.Currency, _model.Amount), + RedirectUrl = _model.RedirectUrl, + Description = _model.Description }); NavigationManager.NavigateTo("/payment/overview"); @@ -83,4 +83,4 @@ _apiException = e; } } -} \ No newline at end of file +} diff --git a/samples/Mollie.WebApplication.Blazor/Pages/Payment/Overview.razor b/samples/Mollie.WebApplication.Blazor/Pages/Payment/Overview.razor index e7ed2b4c..8c08ac75 100644 --- a/samples/Mollie.WebApplication.Blazor/Pages/Payment/Overview.razor +++ b/samples/Mollie.WebApplication.Blazor/Pages/Payment/Overview.razor @@ -1,4 +1,5 @@ @page "/payment/overview" +@using Mollie.Api.Models.List.Response @inject IPaymentClient PaymentClient @@ -11,7 +12,7 @@ else { - + @@ -34,7 +35,7 @@ else { @@ -42,7 +43,7 @@ else { }
@payment.Method @payment.Metadata - @if (payment.Status == PaymentStatus.Open && @payment.Links?.Checkout != null) { + @if (payment.Status == PaymentStatus.Open && @payment.Links.Checkout != null) { Pay }
- + @@ -52,9 +53,9 @@ else { @code { [Parameter] [SupplyParameterFromQuery] - public string Url { get; set; } - - private ListResponse _payments = null; + public string? Url { get; set; } + + private ListResponse? _payments; protected override async Task OnParametersSetAsync() { await LoadData(); @@ -71,4 +72,4 @@ else { }); } } -} \ No newline at end of file +} diff --git a/samples/Mollie.WebApplication.Blazor/Pages/PaymentMethod/Overview.razor b/samples/Mollie.WebApplication.Blazor/Pages/PaymentMethod/Overview.razor index 225777b1..2e6652b8 100644 --- a/samples/Mollie.WebApplication.Blazor/Pages/PaymentMethod/Overview.razor +++ b/samples/Mollie.WebApplication.Blazor/Pages/PaymentMethod/Overview.razor @@ -1,4 +1,6 @@ @page "/payment-method/overview" +@using Mollie.Api.Models.List.Response +@using Mollie.Api.Models.PaymentMethod.Response @inject IPaymentMethodClient PaymentMethodClient @@ -32,9 +34,9 @@ else { @code { - private ListResponse _paymentMethods = null; + private ListResponse? _paymentMethods; protected override async Task OnInitializedAsync() { _paymentMethods = await PaymentMethodClient.GetPaymentMethodListAsync(); } -} \ No newline at end of file +} diff --git a/samples/Mollie.WebApplication.Blazor/Pages/Subscription/Create.razor b/samples/Mollie.WebApplication.Blazor/Pages/Subscription/Create.razor index 2235900b..975c061a 100644 --- a/samples/Mollie.WebApplication.Blazor/Pages/Subscription/Create.razor +++ b/samples/Mollie.WebApplication.Blazor/Pages/Subscription/Create.razor @@ -2,6 +2,7 @@ @using Mollie.WebApplication.Blazor.Models.Subscription @using Mollie.Api.Client +@using Mollie.Api.Models.Subscription.Request @inject ISubscriptionClient SubscriptionClient @inject NavigationManager NavigationManager @@ -10,7 +11,7 @@ - + @@ -19,7 +20,7 @@ + @bind-Value="_model.Amount"> @@ -28,53 +29,53 @@ + @bind-Value="_model.Currency"> @foreach (string currency in StaticStringListBuilder.GetStaticStringList(typeof(Currency))) { } - +
+ @bind-Value="_model.Times">
- +
+ @bind-Value="_model.IntervalAmount">
- +
+ @bind-Value="_model.IntervalPeriod"> @foreach (string intervalPeriod in Enum.GetNames(typeof(IntervalPeriod))) { }
- +
@code { - private MollieApiException _apiException = null; - + private MollieApiException? _apiException; + [Parameter] - public string CustomerId { get; set; } - - private CreateSubscriptionModel model = new() { + public required string CustomerId { get; set; } + + private CreateSubscriptionModel _model = new() { Amount = 10.00m, Currency = Currency.EUR, IntervalPeriod = IntervalPeriod.Days, @@ -82,16 +83,16 @@ IntervalAmount = 2, Description = "A subscription created by the example application" }; - + private async Task OnSave() { try { _apiException = null; - + await SubscriptionClient.CreateSubscriptionAsync(CustomerId, new SubscriptionRequest { - Amount = new Amount(model.Currency, model.Amount), - Interval = $"{model.IntervalAmount} {model.IntervalPeriod.ToString().ToLower()}", - Times = model.Times, - Description = model.Description + Amount = new Amount(_model.Currency, _model.Amount), + Interval = $"{_model.IntervalAmount} {_model.IntervalPeriod.ToString().ToLower()}", + Times = _model.Times, + Description = _model.Description }); NavigationManager.NavigateTo($"/customer/{CustomerId}/subscription/overview"); @@ -100,4 +101,4 @@ _apiException = e; } } -} \ No newline at end of file +} diff --git a/samples/Mollie.WebApplication.Blazor/Pages/Subscription/Overview.razor b/samples/Mollie.WebApplication.Blazor/Pages/Subscription/Overview.razor index a05ed8d2..18831712 100644 --- a/samples/Mollie.WebApplication.Blazor/Pages/Subscription/Overview.razor +++ b/samples/Mollie.WebApplication.Blazor/Pages/Subscription/Overview.razor @@ -1,17 +1,19 @@ @page "/customer/{customerId}/subscription/overview" +@using Mollie.Api.Models.List.Response +@using Mollie.Api.Models.Subscription.Response @inject ISubscriptionClient SubscriptionClient

Subscriptions

-@if (subscriptions == null) { +@if (_subscriptions == null) {

Loading...

} else { - + @@ -23,7 +25,7 @@ else { - @foreach (SubscriptionResponse subscription in subscriptions.Items) { + @foreach (SubscriptionResponse subscription in _subscriptions.Items) { @@ -34,22 +36,22 @@ else { }
@subscription.Id @subscription.CreatedAt
- + + Previous="_subscriptions.Links.Previous" + Next="_subscriptions.Links.Next"> } @code { [Parameter] - public string CustomerId { get; set; } - + public required string CustomerId { get; set; } + [Parameter] [SupplyParameterFromQuery] - public string Url { get; set; } - - private ListResponse subscriptions = null; + public string? Url { get; set; } + + private ListResponse? _subscriptions; protected override async Task OnParametersSetAsync() { await LoadData(); @@ -57,13 +59,13 @@ else { private async Task LoadData() { if (string.IsNullOrEmpty(Url)) { - subscriptions = await SubscriptionClient.GetSubscriptionListAsync(CustomerId); + _subscriptions = await SubscriptionClient.GetSubscriptionListAsync(CustomerId); } else { - subscriptions = await SubscriptionClient.GetSubscriptionListAsync(new UrlObjectLink>() { + _subscriptions = await SubscriptionClient.GetSubscriptionListAsync(new UrlObjectLink>() { Href = Url, Type = "application/json" }); } } -} \ No newline at end of file +} diff --git a/samples/Mollie.WebApplication.Blazor/Pages/Terminal/Overview.razor b/samples/Mollie.WebApplication.Blazor/Pages/Terminal/Overview.razor index 9b9cbc7d..9b187db9 100644 --- a/samples/Mollie.WebApplication.Blazor/Pages/Terminal/Overview.razor +++ b/samples/Mollie.WebApplication.Blazor/Pages/Terminal/Overview.razor @@ -1,4 +1,6 @@ @page "/terminal/overview" +@using Mollie.Api.Models.List.Response +@using Mollie.Api.Models.Terminal.Response @inject ITerminalClient TerminalClient @@ -34,7 +36,7 @@ else { } - + @@ -44,9 +46,9 @@ else { @code { [Parameter] [SupplyParameterFromQuery] - public string Url { get; set; } - - private ListResponse _terminals = null; + public string? Url { get; set; } + + private ListResponse? _terminals; protected override async Task OnParametersSetAsync() { await LoadData(); @@ -63,4 +65,4 @@ else { }); } } -} \ No newline at end of file +} diff --git a/samples/Mollie.WebApplication.Blazor/Pages/_Host.cshtml b/samples/Mollie.WebApplication.Blazor/Pages/_Host.cshtml index 4a2f28f3..6857d582 100644 --- a/samples/Mollie.WebApplication.Blazor/Pages/_Host.cshtml +++ b/samples/Mollie.WebApplication.Blazor/Pages/_Host.cshtml @@ -31,4 +31,4 @@ - \ No newline at end of file + diff --git a/samples/Mollie.WebApplication.Blazor/Program.cs b/samples/Mollie.WebApplication.Blazor/Program.cs index 39c587b6..0f336766 100644 --- a/samples/Mollie.WebApplication.Blazor/Program.cs +++ b/samples/Mollie.WebApplication.Blazor/Program.cs @@ -7,7 +7,7 @@ builder.Services.AddRazorPages(); builder.Services.AddServerSideBlazor(); builder.Services.AddMollieApi(options => { - options.ApiKey = builder.Configuration["Mollie:ApiKey"]; + options.ApiKey = builder.Configuration["Mollie:ApiKey"]!; options.RetryPolicy = MollieHttpRetryPolicies.TransientHttpErrorRetryPolicy(); }); @@ -29,4 +29,4 @@ app.MapBlazorHub(); app.MapFallbackToPage("/_Host"); -app.Run(); \ No newline at end of file +app.Run(); diff --git a/samples/Mollie.WebApplication.Blazor/Shared/ApiExceptionDisplay.razor b/samples/Mollie.WebApplication.Blazor/Shared/ApiExceptionDisplay.razor index 6619b4a7..d7b0d54e 100644 --- a/samples/Mollie.WebApplication.Blazor/Shared/ApiExceptionDisplay.razor +++ b/samples/Mollie.WebApplication.Blazor/Shared/ApiExceptionDisplay.razor @@ -8,5 +8,5 @@ @code { [Parameter, EditorRequired] - public MollieApiException Exception { get; set; } -} \ No newline at end of file + public MollieApiException? Exception { get; set; } +} diff --git a/samples/Mollie.WebApplication.Blazor/Shared/NavMenu.razor b/samples/Mollie.WebApplication.Blazor/Shared/NavMenu.razor index e9b4e9e6..79c3c2cc 100644 --- a/samples/Mollie.WebApplication.Blazor/Shared/NavMenu.razor +++ b/samples/Mollie.WebApplication.Blazor/Shared/NavMenu.razor @@ -19,25 +19,25 @@ Payments - + - + - + - +