Skip to content

Commit

Permalink
Change all models from class to record
Browse files Browse the repository at this point in the history
  • Loading branch information
Viincenttt committed Apr 26, 2024
1 parent 9c77a67 commit df693ac
Show file tree
Hide file tree
Showing 139 changed files with 165 additions and 183 deletions.
10 changes: 1 addition & 9 deletions src/Mollie.Api/Models/Amount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Newtonsoft.Json;

namespace Mollie.Api.Models {
public class Amount {
public record Amount {
private static readonly IDictionary<string, string> CurrenciesWithAlternativeDecimalPrecision =
new Dictionary<string, string>() {
{ "JPY", "0" },
Expand Down Expand Up @@ -60,14 +60,6 @@ public override string ToString() {
return $"{Value} {Currency}";
}

public override bool Equals(object? obj) {
if (obj is Amount amount) {
return Currency == amount.Currency && Value == amount.Value;
}

return false;
}

public override int GetHashCode() {
unchecked {
return (Currency.GetHashCode() * 397) ^ Value.GetHashCode();
Expand Down
2 changes: 1 addition & 1 deletion src/Mollie.Api/Models/ApplicationFee.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace Mollie.Api.Models {
public class ApplicationFee {
public record ApplicationFee {
/// <summary>
/// The amount in EURO that the app wants to charge, e.g. 10.00 if the app would want to charge €10.00.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Newtonsoft.Json;

namespace Mollie.Api.Models.Balance.Response.BalanceReport {
public class BalanceReportResponse : IResponseObject {
public record BalanceReportResponse : IResponseObject {
/// <summary>
/// Indicates the response contains a balance report object. Will always contain balance-report for this endpoint.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections.Generic;

namespace Mollie.Api.Models.Balance.Response.BalanceReport {
public class BalanceReportSubtotals {
public record BalanceReportSubtotals {
public string? TransactionType { get; set; }
public string? Method { get; set; }
public string? PrepaymentPartType { get; init; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace Mollie.Api.Models.Balance.Response.BalanceReport.Specific.StatusBalance {
public class StatusBalanceAvailableBalance {
public record StatusBalanceAvailableBalance {
public required BalanceReportAmount Open { get; init; }
public required BalanceReportAmount Close { get; init; }
public required BalanceReportAmountWithSubtotals MovedFromPending { get; init; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace Mollie.Api.Models.Balance.Response.BalanceReport.Specific.StatusBalance {
public class StatusBalanceReportResponse : BalanceReportResponse {
public record StatusBalanceReportResponse : BalanceReportResponse {
public required StatusBalancesTotal Totals { get; init; }
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace Mollie.Api.Models.Balance.Response.BalanceReport.Specific.StatusBalance {
public class StatusBalancesPendingBalance {
public record StatusBalancesPendingBalance {
public required BalanceReportAmount Open { get; init; }
public required BalanceReportAmount Close { get; init; }
public required BalanceReportAmountWithSubtotals Pending { get; init; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace Mollie.Api.Models.Balance.Response.BalanceReport.Specific.StatusBalance {
public class StatusBalancesTotal {
public record StatusBalancesTotal {
public required StatusBalancesPendingBalance PendingBalance { get; init; }
public required StatusBalanceAvailableBalance AvailableBalance { get; init; }
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace Mollie.Api.Models.Balance.Response.BalanceReport.Specific.TransactionCategories {
public class TransactionCategoriesReportResponse : BalanceReportResponse {
public record TransactionCategoriesReportResponse : BalanceReportResponse {
public required TransactionCategoriesTotal Totals { get; init; }
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace Mollie.Api.Models.Balance.Response.BalanceReport.Specific.TransactionCategories {
public class TransactionCategoriesSummaryBalances {
public record TransactionCategoriesSummaryBalances {
public required BalanceReportAmount Pending { get; init; }
public required BalanceReportAmount Available { get; init; }
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Newtonsoft.Json;

namespace Mollie.Api.Models.Balance.Response.BalanceReport.Specific.TransactionCategories {
public class TransactionCategoriesTotal {
public record TransactionCategoriesTotal {
public required TransactionCategoriesSummaryBalances Open { get; init; }
public required TransactionCategoriesSummaryBalances Close { get; init; }
public required TransactionCategoriesTransaction Payments { get; init; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace Mollie.Api.Models.Balance.Response.BalanceReport.Specific.TransactionCategories {
public class TransactionCategoriesTransaction {
public record TransactionCategoriesTransaction {
public required BalanceReportAmountWithSubtotals Pending { get; init; }
public required BalanceReportAmountWithSubtotals MovedToAvailable { get; init; }
public required BalanceReportAmountWithSubtotals ImmediatelyAvailable { get; init; }
Expand Down
2 changes: 1 addition & 1 deletion src/Mollie.Api/Models/Capture/Response/CaptureResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Mollie.Api.Models.Capture
{
public class CaptureResponse : IResponseObject {
public record CaptureResponse : IResponseObject {
/// <summary>
/// Indicates the response contains a capture object. Will always contain capture for this endpoint.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using Mollie.Api.Models.Url;

namespace Mollie.Api.Models.Capture {
public class CaptureResponseLinks {
public record CaptureResponseLinks {
/// <summary>
/// The API resource URL of the capture itself.
/// </summary>
Expand Down
10 changes: 5 additions & 5 deletions src/Mollie.Api/Models/Chargeback/ChargebackResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
using Newtonsoft.Json;

namespace Mollie.Api.Models.Chargeback {
public class ChargebackResponse : IResponseObject {
/// <summary>
/// The chargeback's unique identifier, for example chb_n9z0tp.
/// </summary>
public required string Id { get; init; }
public record ChargebackResponse : IResponseObject {
/// <summary>
/// The chargeback's unique identifier, for example chb_n9z0tp.
/// </summary>
public required string Id { get; init; }

/// <summary>
/// The amount charged back.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Mollie.Api.Models.Url;

namespace Mollie.Api.Models.Chargeback {
public class ChargebackResponseLinks {
public record ChargebackResponseLinks {
/// <summary>
/// The API resource URL of the chargeback itself.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions src/Mollie.Api/Models/Chargeback/ChargebackResponseReason.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace Mollie.Api.Models.Chargeback {
public class ChargebackResponseReason {
public record ChargebackResponseReason {
/// <summary>
/// The reason for the chargeback, these are documented here on Mollie's webiste https://help.mollie.com/hc/en-us/articles/115000309865-Why-did-my-direct-debit-payment-fail-
/// The reason for the chargeback, these are documented here on Mollie's website https://help.mollie.com/hc/en-us/articles/115000309865-Why-did-my-direct-debit-payment-fail-
/// </summary>
public required string Code { get; init; }
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Mollie.Api.Models.ClientLink.Request
{
public class ClientLinkOwner
public record ClientLinkOwner
{
/// <summary>
/// The email address of your customer.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Mollie.Api.Models.ClientLink.Request
{
public class ClientLinkRequest
public record ClientLinkRequest
{
/// <summary>
/// Personal data of your customer which is required for this endpoint.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Newtonsoft.Json;

namespace Mollie.Api.Models.ClientLink.Response {
public class ClientLinkResponse {
public record ClientLinkResponse {
public required string Id { get; init; }

public required string Resource { get; init; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Mollie.Api.Models.Url;

namespace Mollie.Api.Models.ClientLink.Response {
public class ClientLinkResponseLinks {
public record ClientLinkResponseLinks {
public required UrlLink ClientLink { get; init; }
public required UrlLink Documentation { get; init; }
}
Expand Down
2 changes: 1 addition & 1 deletion src/Mollie.Api/Models/CompanyObject.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace Mollie.Api.Models {
public class CompanyObject {
public record CompanyObject {
/// <summary>
/// Organization’s registration number.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Mollie.Api/Models/Connect/RevokeTokenRequest.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Newtonsoft.Json;

namespace Mollie.Api.Models.Connect {
public class RevokeTokenRequest {
public record RevokeTokenRequest {
/// <summary>
/// Type of the token you want to revoke.
/// </summary>
Expand Down
3 changes: 1 addition & 2 deletions src/Mollie.Api/Models/Connect/TokenRequest.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using Newtonsoft.Json;

namespace Mollie.Api.Models.Connect {
public class TokenRequest {

public record TokenRequest {
/// <param name="code">This can be an authorization code or a refresh token. The correct grant type will be automatically selected</param>
/// <param name="redirectUri">The URL the merchant is sent back to once the request has been authorized. It must match the URL you set when registering your app. </param>
public TokenRequest(string code, string redirectUri) {
Expand Down
2 changes: 1 addition & 1 deletion src/Mollie.Api/Models/Connect/TokenResponse.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Newtonsoft.Json;

namespace Mollie.Api.Models.Connect {
public class TokenResponse : IResponseObject {
public record TokenResponse : IResponseObject {
/// <summary>
/// The access token, with which you will be able to access the Mollie API on the merchant's behalf.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Mollie.Api/Models/Customer/CustomerRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Newtonsoft.Json;

namespace Mollie.Api.Models.Customer {
public class CustomerRequest {
public record CustomerRequest {
/// <summary>
/// The full name of the customer.
/// </summary>
Expand Down
4 changes: 1 addition & 3 deletions src/Mollie.Api/Models/Customer/CustomerResponse.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using System;
using System.Collections.Generic;
using Mollie.Api.JsonConverters;
using Mollie.Api.Models.Payment;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace Mollie.Api.Models.Customer {
public class CustomerResponse : IResponseObject {
public record CustomerResponse : IResponseObject {
/// <summary>
/// Indicates the response contains a customer object. Will always contain customer for this endpoint.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Mollie.Api/Models/Customer/CustomerResponseLinks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using Mollie.Api.Models.Url;

namespace Mollie.Api.Models.Customer {
public class CustomerResponseLinks {
public record CustomerResponseLinks {
/// <summary>
/// The API resource URL of the customer itself.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Mollie.Api/Models/Error/MollieErrorMessage.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Newtonsoft.Json;

namespace Mollie.Api.Models.Error {
public class MollieErrorMessage {
public record MollieErrorMessage {
public int Status { get; set; }
public required string Title { get; init; }
public required string Detail { get; init; }
Expand Down
2 changes: 1 addition & 1 deletion src/Mollie.Api/Models/Invoice/InvoiceLine.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace Mollie.Api.Models.Invoice {
public class InvoiceLine {
public record InvoiceLine {
/// <summary>
/// The administrative period (YYYY) on which the line should be booked.
/// </summary>
Expand Down
3 changes: 1 addition & 2 deletions src/Mollie.Api/Models/Invoice/InvoiceResponse.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using System.Collections.Generic;
using Mollie.Api.Models.Settlement;
using Newtonsoft.Json;

namespace Mollie.Api.Models.Invoice {
public class InvoiceResponse : IResponseObject {
public record InvoiceResponse : IResponseObject {
/// <summary>
/// Indicates the response contains an invoice object. Will always contain invoice for this endpoint.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Mollie.Api/Models/Invoice/InvoiceResponseLinks.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Mollie.Api.Models.Url;

namespace Mollie.Api.Models.Invoice {
public class InvoiceResponseLinks {
public record InvoiceResponseLinks {
/// <summary>
/// The API resource URL of the invoice itself.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Mollie.Api/Models/Issuer/IssuerResponse.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace Mollie.Api.Models.Issuer {
public class IssuerResponse : IResponseObject {
public record IssuerResponse : IResponseObject {
/// <summary>
/// Contains "issuer"
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Mollie.Api/Models/Issuer/IssuerResponseImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/// <summary>
/// URLs of images representing the issuer.
/// </summary>
public class IssuerResponseImage {
public record IssuerResponseImage {
public required string Size1x { get; init; }
public required string Size2x { get; init; }
public required string Svg { get; init; }
Expand Down
2 changes: 1 addition & 1 deletion src/Mollie.Api/Models/List/ListResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Newtonsoft.Json;

namespace Mollie.Api.Models.List {
public class ListResponse<T> where T : IResponseObject{
public record ListResponse<T> where T : IResponseObject{
public int Count { get; set; }

[JsonConverter(typeof(ListResponseConverter))]
Expand Down
2 changes: 1 addition & 1 deletion src/Mollie.Api/Models/List/ListResponseLinks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Mollie.Api.Models.List {
/// <summary>
/// Links to help navigate through the lists of objects, based on the given offset.
/// </summary>
public class ListResponseLinks<T> where T : IResponseObject {
public record ListResponseLinks<T> where T : IResponseObject {
/// <summary>
/// The URL to the current set of payments.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Mollie.Api/Models/Mandate/MandateRequest.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;

namespace Mollie.Api.Models.Mandate {
public class MandateRequest {
public record MandateRequest {
/// <summary>
/// Payment method of the mandate - Possible values: `directdebit` `paypal`
/// </summary>
Expand Down
3 changes: 1 addition & 2 deletions src/Mollie.Api/Models/Mandate/MandateResponse.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace Mollie.Api.Models.Mandate {
public class MandateResponse : IResponseObject {
public record MandateResponse : IResponseObject {
/// <summary>
/// Indicates the response contains a mandate object. Will always contain mandate for this endpoint.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Mollie.Api/Models/Mandate/MandateResponseLinks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Mollie.Api.Models.Url;

namespace Mollie.Api.Models.Mandate {
public class MandateResponseLinks {
public record MandateResponseLinks {
/// <summary>
/// The API resource URL of the mandate itself.
/// </summary>
Expand Down
6 changes: 2 additions & 4 deletions src/Mollie.Api/Models/Mandate/PayPalMandateRequest.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System.Diagnostics.CodeAnalysis;

namespace Mollie.Api.Models.Mandate
namespace Mollie.Api.Models.Mandate
{
public class PayPalMandateRequest : MandateRequest
public record PayPalMandateRequest : MandateRequest
{
public PayPalMandateRequest() {
Method = Payment.PaymentMethod.PayPal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Mollie.Api.Models.Mandate
{
public class SepaDirectDebitMandateRequest : MandateRequest
public record SepaDirectDebitMandateRequest : MandateRequest
{
public SepaDirectDebitMandateRequest() {
Method = Payment.PaymentMethod.DirectDebit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/// <summary>
/// Data of the organization you want to provide.
/// </summary>
public class OnboardingOrganizationRequest {
public record OnboardingOrganizationRequest {
/// <summary>
/// Name of the organization.
/// </summary>
Expand Down
Loading

0 comments on commit df693ac

Please sign in to comment.