Skip to content

Commit

Permalink
93 nullability warnings to go
Browse files Browse the repository at this point in the history
  • Loading branch information
Viincenttt committed Mar 26, 2024
1 parent cece38c commit 34aa215
Show file tree
Hide file tree
Showing 30 changed files with 109 additions and 99 deletions.
12 changes: 6 additions & 6 deletions src/Mollie.Api/Models/AddressObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,31 @@ public class AddressObject {
/// <summary>
/// The card holder’s street and street number.
/// </summary>
public string StreetAndNumber { get; set; }
public string? StreetAndNumber { get; set; }

/// <summary>
/// Any additional addressing details, for example an apartment number.
/// </summary>
public string StreetAdditional { get; set; }
public string? StreetAdditional { get; set; }

/// <summary>
/// The card holder’s postal code.
/// </summary>
public string PostalCode { get; set; }
public string? PostalCode { get; set; }

/// <summary>
/// The card holder’s city.
/// </summary>
public string City { get; set; }
public string? City { get; set; }

/// <summary>
/// The card holder’s region.
/// </summary>
public string Region { get; set; }
public string? Region { get; set; }

/// <summary>
/// The card holder’s country in ISO 3166-1 alpha-2 format.
/// </summary>
public string Country { get; set; }
public string? Country { get; set; }
}
}
6 changes: 3 additions & 3 deletions src/Mollie.Api/Models/CompanyObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ public class CompanyObject {
/// <summary>
/// Organization’s registration number.
/// </summary>
public string RegistrationNumber { get; set; }
public string? RegistrationNumber { get; set; }

/// <summary>
/// Organization’s VAT number.
/// </summary>
public string VatNumber { get; set; }
public string? VatNumber { get; set; }

/// <summary>
/// Organization’s entity type.
/// The Mollie.Api.Models.CompanyEntityType class contains a full list of possible values
/// </summary>
public string EntityType { get; set; }
public string? EntityType { get; set; }
}
}
8 changes: 4 additions & 4 deletions src/Mollie.Api/Models/Customer/CustomerRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
namespace Mollie.Api.Models.Customer {
public class CustomerRequest {
/// <summary>
/// Required - The full name of the customer.
/// The full name of the customer.
/// </summary>
public string Name { get; set; }
public string? Name { get; set; }

/// <summary>
/// Required - The email address of the customer.
/// The email address of the customer.
/// </summary>
public string Email { get; set; }
public string? Email { get; set; }

/// <summary>
/// Allows you to preset the language to be used in the payment screens shown to the consumer. When this parameter is not
Expand Down
15 changes: 5 additions & 10 deletions src/Mollie.Api/Models/Customer/CustomerResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,25 @@ public class CustomerResponse : IResponseObject {
/// <summary>
/// Name of your customer.
/// </summary>
public string Name { get; set; }
public string? Name { get; set; }

/// <summary>
/// E-mailaddress of your customer.
/// </summary>
public string Email { get; set; }
public string? Email { get; set; }

/// <summary>
/// Allows you to preset the language to be used in the payment screens shown to the consumer. If this parameter was not
/// provided when the customer was created, the browser language will be used instead in the payment flow (which is usually
/// more accurate).
/// </summary>
public string Locale { get; set; }
public string? Locale { get; set; }

/// <summary>
/// Optional metadata. Use this if you want Mollie to store additional info.
/// </summary>
[JsonConverter(typeof(RawJsonConverter))]
public string Metadata { get; set; }

/// <summary>
/// Payment methods that the customer recently used for payments.
/// </summary>
public List<string> RecentlyUsedMethods { get; set; }
public string? Metadata { get; set; }

/// <summary>
/// DateTime when user was created.
Expand All @@ -61,7 +56,7 @@ public class CustomerResponse : IResponseObject {
/// An object with several URL objects relevant to the customer. Every URL object will contain an href and a type field.
/// </summary>
[JsonProperty("_links")]
public CustomerResponseLinks Links { get; set; }
public required CustomerResponseLinks Links { get; init; }

public T? GetMetadata<T>(JsonSerializerSettings? jsonSerializerSettings = null) {
return Metadata != null ? JsonConvert.DeserializeObject<T>(Metadata, jsonSerializerSettings) : default;
Expand Down
6 changes: 3 additions & 3 deletions src/Mollie.Api/Models/Customer/CustomerResponseLinks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ public class CustomerResponseLinks {
/// <summary>
/// The API resource URL of the customer itself.
/// </summary>
public UrlObjectLink<CustomerResponse> Self { get; set; }
public required UrlObjectLink<CustomerResponse> Self { get; init; }

/// <summary>
/// The API resource URL of the subscriptions belonging to the Customer, if there are no subscriptions this parameter is omitted.
/// </summary>
public UrlObjectLink<ListResponse<SubscriptionResponse>> Subscriptions { get; set; }
public UrlObjectLink<ListResponse<SubscriptionResponse>>? Subscriptions { get; set; }

/// <summary>
/// The API resource URL of the payments belonging to the Customer, if there are no payments this parameter is omitted.
/// </summary>
public UrlObjectLink<ListResponse<PaymentResponse>> Payments { get; set; }
public UrlObjectLink<ListResponse<PaymentResponse>>? Payments { get; set; }

/// <summary>
/// The URL to the customer retrieval endpoint documentation.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
namespace Mollie.Api.Models.Order.Request.ManageOrderLines {
public class ManageOrderLinesAddOperation : ManageOrderLinesOperation {
public ManageOrderLinesAddOperationData Data { get; set; }
public required ManageOrderLinesAddOperationData Data { get; init; }

public ManageOrderLinesAddOperation() {
this.Operation = OrderLineOperation.Add;
Operation = OrderLineOperation.Add;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
namespace Mollie.Api.Models.Order.Request.ManageOrderLines {
public class ManageOrderLinesCancelOperation : ManageOrderLinesOperation {
public ManagerOrderLinesCancelOperationData Data { get; set; }
public required ManagerOrderLinesCancelOperationData Data { get; init; }

public ManageOrderLinesCancelOperation() {
this.Operation = OrderLineOperation.Cancel;
Operation = OrderLineOperation.Cancel;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ public abstract class ManageOrderLinesOperation {
/// <summary>
/// Operation type. Either `add`, `update`, or `cancel`.
/// </summary>
public string Operation { get; protected set; }
public string Operation { get; protected set; } = string.Empty;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ public class ManageOrderLinesRequest {
/// <summary>
/// List of operations to be processed.
/// </summary>
public IList<ManageOrderLinesOperation> Operations { get; set; }
public required IList<ManageOrderLinesOperation> Operations { get; init; }
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Mollie.Api.Models.Order.Request.ManageOrderLines {
public class ManageOrderLinesUpdateOperation : ManageOrderLinesOperation {
public ManageOrderLinesUpdateOperationData Data { get; set; }
public required ManageOrderLinesUpdateOperationData Data { get; init; }

public ManageOrderLinesUpdateOperation() {
this.Operation = OrderLineOperation.Update;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Mollie.Api.Models.Order {
public class OrderLineCancellationRequest {
public IEnumerable<OrderLineDetails> Lines { get; set; }
public required IEnumerable<OrderLineDetails> Lines { get; init; }

/// <summary>
/// Oauth only - Optional
Expand Down
2 changes: 1 addition & 1 deletion src/Mollie.Api/Models/Order/Request/OrderLineDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
public class OrderLineDetails {
public required string Id { get; init; }
public int? Quantity { get; set; }
public Amount Amount { get; set; }
public Amount? Amount { get; set; }
}
}
26 changes: 13 additions & 13 deletions src/Mollie.Api/Models/Order/Request/OrderLineRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,73 +7,73 @@ public class OrderLineRequest {
/// The type of product bought, for example, a physical or a digital product. See the
/// Mollie.Api.Models.Order.OrderLineDetailsType class for a full list of known values.
/// </summary>
public string Type { get; set; }
public string? Type { get; set; }

/// <summary>
/// The category of product bought. See the Mollie.Api.Models.Order.OrderLineDetailsCategory class
/// for a full list of known values
/// </summary>
public string Category { get; set; }
public string? Category { get; set; }

/// <summary>
/// A description of the order line, for example LEGO 4440 Forest Police Station.
/// </summary>
public string Name { get; set; }
public required string Name { get; init; }

/// <summary>
/// The number of items in the order line.
/// </summary>
public int Quantity { get; set; }
public required int Quantity { get; init; }

/// <summary>
/// The price of a single item in the order line.
/// </summary>
public Amount UnitPrice { get; set; }
public required Amount UnitPrice { get; init; }

/// <summary>
/// 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.
/// </summary>
public Amount DiscountAmount { get; set; }
public Amount? DiscountAmount { get; set; }

/// <summary>
/// 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.
/// </summary>
public Amount TotalAmount { get; set; }
public required Amount TotalAmount { get; init; }

/// <summary>
/// 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.
/// </summary>
public string VatRate { get; set; }
public required string VatRate { get; init; }

/// <summary>
/// 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)). Any deviations from this will
/// result in an error.
/// </summary>
public Amount VatAmount { get; set; }
public required Amount VatAmount { get; init; }

/// <summary>
/// The SKU, EAN, ISBN or UPC of the product sold. The maximum character length is 64.
/// </summary>
public string Sku { get; set; }
public string? Sku { get; set; }

/// <summary>
/// A link pointing to an image of the product sold.
/// </summary>
public string ImageUrl { get; set; }
public string? ImageUrl { get; set; }

/// <summary>
/// A link pointing to the product page in your web shop of the product sold.
/// </summary>
public string ProductUrl { get; set; }
public string? ProductUrl { get; set; }

/// <summary>
/// The optional metadata you provided upon line creation.
/// </summary>
[JsonConverter(typeof(RawJsonConverter))]
public string Metadata { get; set; }
public string? Metadata { get; set; }
}
}
20 changes: 10 additions & 10 deletions src/Mollie.Api/Models/Order/Request/OrderLineUpdateRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,30 @@ public class OrderLineUpdateRequest {
/// <summary>
/// A description of the order line, for example LEGO 4440 Forest Police Station.
/// </summary>
public string Name { get; set; }
public string? Name { get; set; }

/// <summary>
/// A link pointing to an image of the product sold.
/// </summary>
public string ImageUrl { get; set; }
public string? ImageUrl { get; set; }

/// <summary>
/// A link pointing to the product page in your web shop of the product sold.
/// </summary>
public string ProductUrl { get; set; }
public string? ProductUrl { get; set; }

/// <summary>
/// The SKU, EAN, ISBN or UPC of the product sold. The maximum character length is 64.
/// </summary>
public string Sku { get; set; }
public string? Sku { get; set; }

/// <summary>
/// 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.
/// </summary>
[JsonConverter(typeof(RawJsonConverter))]
public string Metadata { get; set; }
public string? Metadata { get; set; }

/// <summary>
/// The number of items in the order line.
Expand All @@ -39,31 +39,31 @@ public class OrderLineUpdateRequest {
/// <summary>
/// The price of a single item including VAT in the order line.
/// </summary>
public Amount UnitPrice { get; set; }
public Amount? UnitPrice { get; set; }

/// <summary>
/// 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.
/// </summary>
public Amount DiscountAmount { get; set; }
public Amount? DiscountAmount { get; set; }

/// <summary>
/// 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.
/// </summary>
public Amount TotalAmount { get; set; }
public Amount? TotalAmount { get; set; }

/// <summary>
/// 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)).
/// </summary>
public Amount VatAmount { get; set; }
public Amount? VatAmount { get; set; }

/// <summary>
/// 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.
/// </summary>
public string VatRate { get; set; }
public string? VatRate { get; set; }

/// <summary>
/// Oauth only - Optional
Expand Down
6 changes: 3 additions & 3 deletions src/Mollie.Api/Models/Order/Request/OrderPaymentRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ public string? Method {
/// The ID of the Customer for whom the payment is being created. This is used for recurring payments
/// and single click payments.
/// </summary>
public string CustomerId { get; set; }
public string? CustomerId { get; set; }

/// <summary>
/// When creating recurring payments, the ID of a specific Mandate may be supplied to indicate which
/// of the consumer’s accounts should be credited.
/// </summary>
public string MandateId { get; set; }
public string? MandateId { get; set; }

/// <summary>
/// Oauth only - Optional – Set this to true to make this payment a test payment.
Expand All @@ -56,6 +56,6 @@ public string? Method {
/// 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.
/// </summary>
public ApplicationFee ApplicationFee { get; set; }
public ApplicationFee? ApplicationFee { get; set; }
}
}
Loading

0 comments on commit 34aa215

Please sign in to comment.