Skip to content

Commit

Permalink
199 nullability warnings to go
Browse files Browse the repository at this point in the history
  • Loading branch information
Viincenttt committed Mar 25, 2024
1 parent d4be2b1 commit 882c998
Show file tree
Hide file tree
Showing 21 changed files with 86 additions and 92 deletions.
11 changes: 5 additions & 6 deletions src/Mollie.Api/Models/Error/MollieErrorMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,22 @@
namespace Mollie.Api.Models.Error {
public class MollieErrorMessage {
public int Status { get; set; }
public string Title { get; set; }
public string Detail { get; set; }
public required string Title { get; init; }
public required string Detail { get; init; }

/// <summary>
/// The errors that are returned by the Connect client have a different format for some reason
/// In order to use the same object, we just map private properties to the public properties
/// that are used by the public api
/// </summary>
[JsonProperty("error")]
private string Error { set { Title = value; } }
private string Error { init { Title = value; } }

[JsonProperty("error_description")]
private string ErrorDescription { set { Detail = value; } }

private string ErrorDescription { init { Detail = value; } }

public override string ToString() {
return $"{this.Title} - {this.Detail}";
return $"{Title} - {Detail}";
}
}
}
14 changes: 6 additions & 8 deletions src/Mollie.Api/Models/Invoice/InvoiceLine.cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
using System;

namespace Mollie.Api.Models.Invoice {
namespace Mollie.Api.Models.Invoice {
public class InvoiceLine {
/// <summary>
/// The administrative period (YYYY) on which the line should be booked.
/// </summary>
public string Period { get; set; }
public required string Period { get; init; }

/// <summary>
/// Description of the product.
/// </summary>
public string Description { get; set; }
public required string Description { get; init; }

/// <summary>
/// Number of products invoiced (usually number of payments).
/// </summary>
public int Count { get; set; }
public required int Count { get; init; }

/// <summary>
/// Optional – VAT percentage rate that applies to this product.
/// </summary>
public decimal VatPercentage { get; set; }
public required decimal VatPercentage { get; init; }

/// <summary>
/// Amount excluding VAT.
/// </summary>
public Amount Amount { get; set; }
public required Amount Amount { get; init; }
}
}
30 changes: 12 additions & 18 deletions src/Mollie.Api/Models/Invoice/InvoiceResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,66 +17,60 @@ public class InvoiceResponse : IResponseObject {
/// <summary>
/// The reference number of the invoice. An example value would be: 2016.10000.
/// </summary>
public string Reference { get; set; }
public required string Reference { get; init; }

/// <summary>
/// Optional – The VAT number to which the invoice was issued to (if applicable).
/// </summary>
public string VatNumber { get; set; }
public string? VatNumber { get; set; }

/// <summary>
/// Status of the invoices - See the Mollie.Api.Models.Invoice.InvoiceStatus class for
/// a full list of known values
/// </summary>
public string Status { get; set; }
public required string Status { get; init; }

/// <summary>
/// The invoice date (in YYYY-MM-DD format).
/// </summary>
public string IssuedAt { get; set; }
public required string IssuedAt { get; init; }

/// <summary>
/// Optional – The date on which the invoice was paid (in YYYY-MM-DD format). Only for paid invoices.
/// </summary>
public string PaidAt { get; set; }
public string? PaidAt { get; set; }

/// <summary>
/// Optional – The date on which the invoice is due (in YYYY-MM-DD format). Only for due invoices.
/// </summary>
public string DueAt { get; set; }
public string? DueAt { get; set; }

/// <summary>
/// Total amount of the invoice excluding VAT, e.g. {"currency":Currency.EUR, "value":"100.00"}.
/// </summary>
public Amount NetAmount { get; set; }
public required Amount NetAmount { get; init; }

/// <summary>
/// VAT amount of the invoice. Only for merchants registered in the Netherlands. For EU merchants, VAT
/// will be shifted to recipient; article 44 and 196 EU VAT Directive 2006/112. For merchants outside the
/// EU, no VAT will be charged.
/// </summary>
public Amount VatAmount { get; set; }
public required Amount VatAmount { get; init; }

/// <summary>
/// Total amount of the invoice including VAT.
/// </summary>
public Amount GrossAmount { get; set; }
public required Amount GrossAmount { get; init; }

/// <summary>
/// Only available if you require this field to be included – The collection of products which make up the invoice.
/// The collection of products which make up the invoice.
/// </summary>
public List<InvoiceLine> Lines { get; set; }

/// <summary>
/// Only available if you require this field to be included – A array of settlements that were invoiced on this invoice.
/// You need the settlements.read permission for this field.
/// </summary>
public List<SettlementResponse> Settlements { get; set; }
public required List<InvoiceLine> Lines { get; init; }

/// <summary>
/// Useful URLs to related resources.
/// </summary>
[JsonProperty("_links")]
public InvoiceResponseLinks Links { get; set; }
public required InvoiceResponseLinks Links { get; init; }
}
}
4 changes: 2 additions & 2 deletions src/Mollie.Api/Models/Invoice/InvoiceResponseLinks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ public class InvoiceResponseLinks {
/// <summary>
/// The API resource URL of the invoice itself.
/// </summary>
public UrlObjectLink<InvoiceResponse> Self { get; set; }
public required UrlObjectLink<InvoiceResponse> Self { get; init; }

/// <summary>
/// The URL to the PDF version of the invoice. The URL will expire after 60 minutes.
/// </summary>
public UrlLink Pdf { get; set; }
public UrlLink? Pdf { get; set; }

/// <summary>
/// The URL to the invoice retrieval endpoint documentation.
Expand Down
4 changes: 2 additions & 2 deletions src/Mollie.Api/Models/Issuer/IssuerResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ public class IssuerResponse : IResponseObject {
/// <summary>
/// The issuer's full name, for example 'ABN AMRO'.
/// </summary>
public string Name { get; set; }
public required string Name { get; init; }

/// <summary>
/// Different Issuer Image icons (iDEAL).
/// </summary>
public IssuerResponseImage Image { get; set; }
public required IssuerResponseImage Image { get; init; }
}
}
8 changes: 4 additions & 4 deletions src/Mollie.Api/Models/Issuer/IssuerResponseImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
/// URLs of images representing the issuer.
/// </summary>
public class IssuerResponseImage {
public string Size1x { get; set; }
public string Size2x { get; set; }
public string Svg { get; set; }
public required string Size1x { get; init; }
public required string Size2x { get; init; }
public required string Svg { get; init; }

public override string ToString() {
return this.Size1x;
return Size1x;
}
}
}
10 changes: 2 additions & 8 deletions src/Mollie.Api/Models/List/ListResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,9 @@ public class ListResponse<T> where T : IResponseObject{

[JsonConverter(typeof(ListResponseConverter))]
[JsonProperty("_embedded")]
public List<T> Items { get; set; }
public required List<T> Items { get; init; }

[JsonProperty("_links")]
public ListResponseLinks<T> Links { get; set; }
}

public class ListResponseSimple<T> {
public int Count { get; set; }

public List<T> Data { get; set; }
public required ListResponseLinks<T> Links { get; init; }
}
}
6 changes: 3 additions & 3 deletions src/Mollie.Api/Models/List/ListResponseLinks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ public class ListResponseLinks<T> where T : IResponseObject {
/// <summary>
/// The URL to the current set of payments.
/// </summary>
public UrlObjectLink<ListResponse<T>> Self { get; set; }
public required UrlObjectLink<ListResponse<T>> Self { get; init; }

/// <summary>
/// The previous set of objects, if available.
/// </summary>
public UrlObjectLink<ListResponse<T>> Previous { get; set; }
public UrlObjectLink<ListResponse<T>>? Previous { get; set; }

/// <summary>
/// The next set of objects, if available.
/// </summary>
public UrlObjectLink<ListResponse<T>> Next { get; set; }
public UrlObjectLink<ListResponse<T>>? Next { get; set; }

/// <summary>
/// The URL to the payments list endpoint documentation.
Expand Down
6 changes: 3 additions & 3 deletions src/Mollie.Api/Models/Mandate/MandateRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ public class MandateRequest {
/// <summary>
/// Payment method of the mandate - Possible values: `directdebit` `paypal`
/// </summary>
public string Method { get; set; }
public required string Method { get; init; }

/// <summary>
/// Required - Name of consumer you add to the mandate
/// </summary>
public string ConsumerName { get; set; }
public required string ConsumerName { get; init; }

/// <summary>
/// Optional - The date when the mandate was signed.
Expand All @@ -20,7 +20,7 @@ public class MandateRequest {
/// <summary>
/// Optional - A custom reference
/// </summary>
public string MandateReference { get; set; }
public string? MandateReference { get; set; }

/// <summary>
/// Oauth only - Optional – Set this to true to make this mandate a test mandate.
Expand Down
14 changes: 7 additions & 7 deletions src/Mollie.Api/Models/Mandate/MandateResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,38 @@ public class MandateResponse : IResponseObject {
/// Current status of mandate - See the Mollie.Api.Models.Mandate.MandateStatus class for a full
/// list of known values.
/// </summary>
public string Status { get; set; }
public required string Status { get; init; }

/// <summary>
/// Payment method of the mandate - See the Mollie.Api.Models.Payment.PaymentMethod class for a full list of known values.
/// </summary>
public string Method { get; set; }
public required string Method { get; init; }

/// <summary>
/// Mandate details that are different per payment method. Available fields depend on that payment method.
/// </summary>
public MandateDetails Details { get; set; }
public MandateDetails? Details { get; set; }

/// <summary>
/// The mandate’s custom reference, if this was provided when creating the mandate.
/// </summary>
public string MandateReference { get; set; }
public string? MandateReference { get; set; }

/// <summary>
/// The signature date of the mandate in YYYY-MM-DD format.
/// </summary>
public string SignatureDate { get; set; }
public string? SignatureDate { get; set; }

/// <summary>
/// DateTime when mandate was created.
/// </summary>
public DateTime? CreatedAt { get; set; }
public DateTime CreatedAt { get; init; }

/// <summary>
/// An object with several URL objects relevant to the mandate. Every URL object will contain an href and a type field.
/// </summary>
[JsonProperty("_links")]
public MandateResponseLinks Links { get; set; }
public required MandateResponseLinks Links { get; init; }
}

public class MandateDetails {
Expand Down
4 changes: 2 additions & 2 deletions src/Mollie.Api/Models/Mandate/MandateResponseLinks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ public class MandateResponseLinks {
/// <summary>
/// The API resource URL of the mandate itself.
/// </summary>
public UrlObjectLink<MandateResponse> Self { get; set; }
public required UrlObjectLink<MandateResponse> Self { get; init; }

/// <summary>
/// The API resource URL of the customer the mandate is for.
/// </summary>
public UrlObjectLink<CustomerResponse> Customer { get; set; }
public required UrlObjectLink<CustomerResponse> Customer { get; init; }

/// <summary>
/// The URL to the mandate retrieval endpoint documentation.
Expand Down
4 changes: 1 addition & 3 deletions src/Mollie.Api/Models/Mandate/MandateStatus.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Runtime.Serialization;

namespace Mollie.Api.Models.Mandate {
namespace Mollie.Api.Models.Mandate {
public static class MandateStatus {
public const string Valid = "valid";
public const string Invalid = "invalid";
Expand Down
10 changes: 6 additions & 4 deletions src/Mollie.Api/Models/Mandate/PayPalMandateRequest.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
namespace Mollie.Api.Models.Mandate
using System.Diagnostics.CodeAnalysis;

namespace Mollie.Api.Models.Mandate
{
public class PayPalMandateRequest : MandateRequest
{
public PayPalMandateRequest() {
this.Method = Payment.PaymentMethod.PayPal;
Method = Payment.PaymentMethod.PayPal;
}

/// <summary>
/// Required For Paypal - The consumer's email address.
/// </summary>
public string ConsumerEmail { get; set; }
public required string ConsumerEmail { get; init; }

/// <summary>
/// Required for `paypal` mandates - The billing agreement ID given by PayPal.
/// </summary>
public string PaypalBillingAgreementId { get; set; }
public required string PaypalBillingAgreementId { get; init; }
}
}
10 changes: 6 additions & 4 deletions src/Mollie.Api/Models/Mandate/SepaDirectDebitMandateRequest.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
namespace Mollie.Api.Models.Mandate
using System.Diagnostics.CodeAnalysis;

namespace Mollie.Api.Models.Mandate
{
public class SepaDirectDebitMandateRequest : MandateRequest
{
public SepaDirectDebitMandateRequest() {
this.Method = Payment.PaymentMethod.DirectDebit;
Method = Payment.PaymentMethod.DirectDebit;
}

/// <summary>
/// Required for `directdebit` mandates - Consumer's IBAN account
/// </summary>
public string ConsumerAccount { get; set; }
public required string ConsumerAccount { get; init; }

/// <summary>
/// Optional - The consumer's bank's BIC / SWIFT code.
/// </summary>
public string ConsumerBic { get; set; }
public string? ConsumerBic { get; set; }

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ public class OnboardingOrganizationRequest {
/// <summary>
/// Name of the organization.
/// </summary>
public string Name { get; set; }
public string? Name { get; set; }

/// <summary>
/// Address of the organization.
/// </summary>
public AddressObject Address { get; set; }
public AddressObject? Address { get; set; }
}
}
Loading

0 comments on commit 882c998

Please sign in to comment.