From 5997c2b47a166823150c1e8a8170e3515ad56067 Mon Sep 17 00:00:00 2001 From: Vincent Kok Date: Sun, 24 Mar 2024 20:33:29 +0100 Subject: [PATCH] 309 nullability warnings to go --- .../Models/ClientLink/Request/ClientLinkOwner.cs | 8 ++++---- .../Models/ClientLink/Request/ClientLinkRequest.cs | 10 +++++----- .../ClientLink/Response/ClientLinkResponseLinks.cs | 8 +++----- .../Client/ClientLinkClientTests.cs | 14 ++++++++++++-- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/Mollie.Api/Models/ClientLink/Request/ClientLinkOwner.cs b/src/Mollie.Api/Models/ClientLink/Request/ClientLinkOwner.cs index 466a7170..6f85ecd7 100644 --- a/src/Mollie.Api/Models/ClientLink/Request/ClientLinkOwner.cs +++ b/src/Mollie.Api/Models/ClientLink/Request/ClientLinkOwner.cs @@ -5,17 +5,17 @@ public class ClientLinkOwner /// /// The email address of your customer. /// - public string Email { get; set; } + public required string Email { get; init; } /// /// The given name (first name) of your customer. /// - public string GivenName { get; set; } + public required string GivenName { get; init; } /// /// The family name (surname) of your customer. /// - public string FamilyName { get; set; } + public required string FamilyName { get; init; } /// /// Allows you to preset the language to be used in the login / authorize flow. When this parameter is @@ -23,6 +23,6 @@ public class ClientLinkOwner /// but the authorize flow currently only supports the following languages: /// en_US nl_NL nl_BE fr_FR fr_BE de_DE es_ES it_IT /// - public string Locale { get; set; } + public string? Locale { get; set; } } } \ No newline at end of file diff --git a/src/Mollie.Api/Models/ClientLink/Request/ClientLinkRequest.cs b/src/Mollie.Api/Models/ClientLink/Request/ClientLinkRequest.cs index db8b456d..c3c1332f 100644 --- a/src/Mollie.Api/Models/ClientLink/Request/ClientLinkRequest.cs +++ b/src/Mollie.Api/Models/ClientLink/Request/ClientLinkRequest.cs @@ -5,29 +5,29 @@ public class ClientLinkRequest /// /// Personal data of your customer which is required for this endpoint. /// - public ClientLinkOwner Owner { get; set; } + public required ClientLinkOwner Owner { get; init; } /// /// Name of the organization. /// - public string Name { get; set; } + public required string Name { get; init; } /// /// Address of the organization. Note that the country parameter /// must always be provided. /// - public AddressObject Address { get; set; } + public required AddressObject Address { get; init; } /// /// The Chamber of Commerce (or local equivalent) registration number /// of the organization. /// - public string RegistrationNumber { get; set; } + public string? RegistrationNumber { get; set; } /// /// The VAT number of the organization, if based in the European Union /// or the United Kingdom. /// - public string VatNumber { get; set; } + public string? VatNumber { get; set; } } } \ No newline at end of file diff --git a/src/Mollie.Api/Models/ClientLink/Response/ClientLinkResponseLinks.cs b/src/Mollie.Api/Models/ClientLink/Response/ClientLinkResponseLinks.cs index 3025ef90..d4d52614 100644 --- a/src/Mollie.Api/Models/ClientLink/Response/ClientLinkResponseLinks.cs +++ b/src/Mollie.Api/Models/ClientLink/Response/ClientLinkResponseLinks.cs @@ -1,10 +1,8 @@ using Mollie.Api.Models.Url; -namespace Mollie.Api.Models.ClientLink.Response -{ - public class ClientLinkResponseLinks - { - public UrlLink ClientLink { get; set; } +namespace Mollie.Api.Models.ClientLink.Response { + public class ClientLinkResponseLinks { + public required UrlLink ClientLink { get; init; } public required UrlLink Documentation { get; init; } } } \ No newline at end of file diff --git a/tests/Mollie.Tests.Unit/Client/ClientLinkClientTests.cs b/tests/Mollie.Tests.Unit/Client/ClientLinkClientTests.cs index 4f848f64..6a1258a7 100644 --- a/tests/Mollie.Tests.Unit/Client/ClientLinkClientTests.cs +++ b/tests/Mollie.Tests.Unit/Client/ClientLinkClientTests.cs @@ -3,6 +3,7 @@ using System.Threading.Tasks; using FluentAssertions; using Mollie.Api.Client; +using Mollie.Api.Models; using Mollie.Api.Models.Chargeback; using Mollie.Api.Models.ClientLink.Request; using Mollie.Api.Models.ClientLink.Response; @@ -24,10 +25,19 @@ public async Task CreateClientLinkAsync_ResponseIsDeserializedInExpectedFormat() mockHttp.When( HttpMethod.Post, $"{BaseMollieClient.ApiEndPoint}client-links") .Respond("application/json", clientLinkResponseJson); HttpClient httpClient = mockHttp.ToHttpClient(); - ClientLinkClient clientLinkClient = new ClientLinkClient("clientId", "access_1234", httpClient); + ClientLinkClient clientLinkClient = new ClientLinkClient("clientId", "access_1234", httpClient); + var request = new ClientLinkRequest { + Owner = new ClientLinkOwner { + Email = "email", + GivenName = "gicen-name", + FamilyName = "family-name" + }, + Address = new AddressObject(), + Name = "name" + }; // When: We send the request - ClientLinkResponse response = await clientLinkClient.CreateClientLinkAsync(new ClientLinkRequest()); + ClientLinkResponse response = await clientLinkClient.CreateClientLinkAsync(request); // Then response.Id.Should().Be(clientLinkId);