Skip to content

Commit

Permalink
Add support for the OrderLineRequest.Category property
Browse files Browse the repository at this point in the history
  • Loading branch information
Viincenttt committed Dec 5, 2020
1 parent 5349dc0 commit 23c109b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
7 changes: 7 additions & 0 deletions Mollie.Api/Models/Order/Request/OrderLineDetailsCategory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Mollie.Api.Models.Order {
public static class OrderLineDetailsCategory {
public const string Meal = "meal";
public const string Eco = "eco";
public const string Gift = "gift";
}
}
6 changes: 6 additions & 0 deletions Mollie.Api/Models/Order/Request/OrderLineRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ public class OrderLineRequest {
/// </summary>
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; }

/// <summary>
/// A description of the order line, for example LEGO 4440 Forest Police Station.
/// </summary>
Expand Down
24 changes: 14 additions & 10 deletions Mollie.Tests.Integration/Api/OrderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class OrderTests : BaseMollieApiTestClass {
[Test][RetryOnApiRateLimitFailure(BaseMollieApiTestClass.NumberOfRetries)]
public async Task CanCreateOrderWithOnlyRequiredFields() {
// If: we create a order request with only the required parameters
OrderRequest orderRequest = this.CreateOrderRequestWithOnlyRequiredFields();
OrderRequest orderRequest = this.CreateOrder();

// When: We send the order request to Mollie
OrderResponse result = await this._orderClient.CreateOrderAsync(orderRequest);
Expand All @@ -25,13 +25,15 @@ public async Task CanCreateOrderWithOnlyRequiredFields() {
Assert.AreEqual(orderRequest.Amount.Value, result.Amount.Value);
Assert.AreEqual(orderRequest.Amount.Currency, result.Amount.Currency);
Assert.AreEqual(orderRequest.OrderNumber, result.OrderNumber);
Assert.AreEqual(orderRequest.Lines.Count(), result.Lines.Count());
Assert.AreEqual(orderRequest.Lines.First().Type, result.Lines.First().Type);
}

[Test]
[RetryOnApiRateLimitFailure(BaseMollieApiTestClass.NumberOfRetries)]
public async Task CanCreateOrderWithMultiplePaymentMethods() {
// When: we create a order request and specify multiple payment methods
OrderRequest orderRequest = this.CreateOrderRequestWithOnlyRequiredFields();
OrderRequest orderRequest = this.CreateOrder();
orderRequest.Methods = new List<string>() {
PaymentMethod.Ideal,
PaymentMethod.CreditCard,
Expand All @@ -52,7 +54,7 @@ public async Task CanCreateOrderWithMultiplePaymentMethods() {
[RetryOnApiRateLimitFailure(BaseMollieApiTestClass.NumberOfRetries)]
public async Task CanCreateOrderWithSinglePaymentMethod() {
// When: we create a order request and specify a single payment method
OrderRequest orderRequest = this.CreateOrderRequestWithOnlyRequiredFields();
OrderRequest orderRequest = this.CreateOrder();
orderRequest.Method = PaymentMethod.CreditCard;

// When: We send the order request to Mollie
Expand All @@ -69,7 +71,7 @@ public async Task CanCreateOrderWithSinglePaymentMethod() {
[Test][RetryOnApiRateLimitFailure(BaseMollieApiTestClass.NumberOfRetries)]
public async Task CanCreateOrderWithPaymentSpecificOptions() {
// If: we create a order request with payment specific parameters
OrderRequest orderRequest = this.CreateOrderRequestWithOnlyRequiredFields();
OrderRequest orderRequest = this.CreateOrder();
orderRequest.Payment = new IDealSpecificParameters() {
Issuer = "ideal_INGBNL2A"
};
Expand All @@ -87,7 +89,7 @@ public async Task CanCreateOrderWithPaymentSpecificOptions() {
[Test][RetryOnApiRateLimitFailure(BaseMollieApiTestClass.NumberOfRetries)]
public async Task CanRetrieveOrderAfterCreationOrder() {
// If: we create a new order
OrderRequest orderRequest = this.CreateOrderRequestWithOnlyRequiredFields();
OrderRequest orderRequest = this.CreateOrder();
OrderResponse createdOrder = await this._orderClient.CreateOrderAsync(orderRequest);

// When: We attempt to retrieve the order
Expand All @@ -101,7 +103,7 @@ public async Task CanRetrieveOrderAfterCreationOrder() {
[Test][RetryOnApiRateLimitFailure(BaseMollieApiTestClass.NumberOfRetries)]
public async Task CanRetrieveOrderAndIncludeEmbeddedData() {
// If: we create a new order
OrderRequest orderRequest = this.CreateOrderRequestWithOnlyRequiredFields();
OrderRequest orderRequest = this.CreateOrder();
OrderResponse createdOrder = await this._orderClient.CreateOrderAsync(orderRequest);

// When: We attempt to retrieve the order and add the include parameters
Expand All @@ -119,7 +121,7 @@ public async Task CanRetrieveOrderAndIncludeEmbeddedData() {
[Test][RetryOnApiRateLimitFailure(BaseMollieApiTestClass.NumberOfRetries)]
public async Task CanUpdateExistingOrder() {
// If: we create a new order
OrderRequest orderRequest = this.CreateOrderRequestWithOnlyRequiredFields();
OrderRequest orderRequest = this.CreateOrder();
OrderResponse createdOrder = await this._orderClient.CreateOrderAsync(orderRequest);

// When: We attempt to update the order
Expand All @@ -138,7 +140,7 @@ public async Task CanUpdateExistingOrder() {
[Test][RetryOnApiRateLimitFailure(BaseMollieApiTestClass.NumberOfRetries)]
public async Task CanCancelCreatedOrder() {
// If: we create a new order
OrderRequest orderRequest = this.CreateOrderRequestWithOnlyRequiredFields();
OrderRequest orderRequest = this.CreateOrder();
OrderResponse createdOrder = await this._orderClient.CreateOrderAsync(orderRequest);

// When: We attempt to cancel the order and then retrieve it
Expand All @@ -152,7 +154,7 @@ public async Task CanCancelCreatedOrder() {
[Test][RetryOnApiRateLimitFailure(BaseMollieApiTestClass.NumberOfRetries)]
public async Task CanUpdateOrderLine() {
// If: we create a new order
OrderRequest orderRequest = this.CreateOrderRequestWithOnlyRequiredFields();
OrderRequest orderRequest = this.CreateOrder();
OrderResponse createdOrder = await this._orderClient.CreateOrderAsync(orderRequest);

// When: We update the order line
Expand Down Expand Up @@ -187,13 +189,15 @@ public async Task ListOrdersNeverReturnsMorePaymentsThenTheNumberOfRequestedOrde
Assert.IsTrue(response.Items.Count <= numberOfOrders);
}

private OrderRequest CreateOrderRequestWithOnlyRequiredFields() {
private OrderRequest CreateOrder() {
return new OrderRequest() {
Amount = new Amount(Currency.EUR, "100.00"),
OrderNumber = "16738",
Lines = new List<OrderLineRequest>() {
new OrderLineRequest() {
Name = "A box of chocolates",
Type = OrderLineDetailsType.Physical,
Category = OrderLineDetailsCategory.Gift,
Quantity = 1,
UnitPrice = new Amount(Currency.EUR, "100.00"),
TotalAmount = new Amount(Currency.EUR, "100.00"),
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ In the past, this library used enums that were decorated with the EnumMemberAttr
- Mollie.Api.Models.Payment.Response.PayPalSellerProtection
- Mollie.Api.Models.Mandate.InvoiceStatus
- Mollie.Api.Models.Mandate.MandateStatus
- Mollie.Api.Models.Order.OrderLineDetailsCategory
- Mollie.Api.Models.Order.OrderLineDetailsType
- Mollie.Api.Models.Order.OrderLineStatus
- Mollie.Api.Models.Order.OrderStatus
Expand Down

0 comments on commit 23c109b

Please sign in to comment.