From 06e03c7c723d5a9ae64b767bf935eec5d743e7bc Mon Sep 17 00:00:00 2001 From: Samuel Corbeil Date: Thu, 5 Oct 2023 10:24:15 -0400 Subject: [PATCH] Fix AbstractDealProduct, DealProductUpdate, NewDealProduct to match discount breaking changes in API --- .../Clients/DealsClientTests.cs | 9 ++++++--- .../Models/Request/Deals/DealProductUpdate.cs | 7 +++++-- src/Pipedrive.net/Models/Request/Deals/NewDealProduct.cs | 7 +++++-- .../Models/Response/Products/AbstractDealProduct.cs | 7 +++++-- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/Pipedrive.net.Tests.Integration/Clients/DealsClientTests.cs b/src/Pipedrive.net.Tests.Integration/Clients/DealsClientTests.cs index 1c319f86..58b7bf9f 100644 --- a/src/Pipedrive.net.Tests.Integration/Clients/DealsClientTests.cs +++ b/src/Pipedrive.net.Tests.Integration/Clients/DealsClientTests.cs @@ -728,7 +728,8 @@ public async Task AddProductToDeal() { var newDealProduct = new NewDealProduct(1, 10, 30) { - DiscountPercentage = 55, + Discount = 55, + DiscountType = "percentage", EnabledFlag = true }; @@ -742,7 +743,8 @@ public async Task AddProductToDeal() Assert.Equal(10, dealProduct.ItemPrice); Assert.Equal(30, dealProduct.Quantity); Assert.Equal(135, dealProduct.Sum); - Assert.Equal(55, dealProduct.DiscountPercentage); + Assert.Equal(55, dealProduct.Discount); + Assert.Equal("percentage", dealProduct.DiscountType); // Cleanup await fixture.DeleteProduct(1, dealProduct.ProductAttachmentId.Value); @@ -764,7 +766,8 @@ public async Task UpdateDealProduct() ItemPrice = 44, Quantity = 1, Duration = 1, - DiscountPercentage = 11 + Discount = 11, + DiscountType = "percentage" }; var updatedDealProduct = await fixture.UpdateProduct(1, createdDealProduct.ProductAttachmentId.Value, dealProductUpdate); diff --git a/src/Pipedrive.net/Models/Request/Deals/DealProductUpdate.cs b/src/Pipedrive.net/Models/Request/Deals/DealProductUpdate.cs index cb50bd47..2d311982 100644 --- a/src/Pipedrive.net/Models/Request/Deals/DealProductUpdate.cs +++ b/src/Pipedrive.net/Models/Request/Deals/DealProductUpdate.cs @@ -10,8 +10,11 @@ public class DealProductUpdate [JsonProperty("quantity")] public long Quantity { get; set; } - [JsonProperty("discount_percentage")] - public decimal DiscountPercentage { get; set; } + [JsonProperty("discount")] + public decimal Discount { get; set; } + + [JsonProperty("discount_type")] + public string DiscountType { get; set; } [JsonProperty("duration")] public long Duration { get; set; } = 1; diff --git a/src/Pipedrive.net/Models/Request/Deals/NewDealProduct.cs b/src/Pipedrive.net/Models/Request/Deals/NewDealProduct.cs index 0fbfd2c8..254febe3 100644 --- a/src/Pipedrive.net/Models/Request/Deals/NewDealProduct.cs +++ b/src/Pipedrive.net/Models/Request/Deals/NewDealProduct.cs @@ -13,8 +13,11 @@ public class NewDealProduct [JsonProperty("quantity")] public long Quantity { get; set; } - [JsonProperty("discount_percentage")] - public decimal DiscountPercentage { get; set; } + [JsonProperty("discount")] + public decimal Discount { get; set; } + + [JsonProperty("discount_type")] + public string DiscountType { get; set; } [JsonProperty("duration")] public long Duration { get; set; } = 1; diff --git a/src/Pipedrive.net/Models/Response/Products/AbstractDealProduct.cs b/src/Pipedrive.net/Models/Response/Products/AbstractDealProduct.cs index b03d0873..f0a8f0b9 100644 --- a/src/Pipedrive.net/Models/Response/Products/AbstractDealProduct.cs +++ b/src/Pipedrive.net/Models/Response/Products/AbstractDealProduct.cs @@ -23,8 +23,11 @@ public abstract class AbstractDealProduct [JsonProperty("item_price")] public decimal ItemPrice { get; set; } - [JsonProperty("discount_percentage")] - public decimal DiscountPercentage { get; set; } + [JsonProperty("discount")] + public decimal Discount { get; set; } + + [JsonProperty("discount_type")] + public string DiscountType { get; set; } [JsonProperty("duration")] public long Duration { get; set; }