diff --git a/ShopifySharp.Tests/PriceRule_Tests.cs b/ShopifySharp.Tests/PriceRule_Tests.cs index 4ddb2abd..cdba869f 100644 --- a/ShopifySharp.Tests/PriceRule_Tests.cs +++ b/ShopifySharp.Tests/PriceRule_Tests.cs @@ -82,9 +82,9 @@ public async Task Creates_PriceRules() [Fact] public async Task Updates_PriceRules() { - string suffix = Guid.NewGuid().ToString(); + var suffix = Guid.NewGuid().ToString(); var created = await Fixture.Create(suffix); - long id = created.Id.Value; + var id = created.Id.Value; created.Value = -5.0m; created.Id = null; diff --git a/ShopifySharp/Entities/PrerequisiteQuantityRange.cs b/ShopifySharp/Entities/PrerequisiteQuantityRange.cs index 292d5aa1..9158e1c2 100644 --- a/ShopifySharp/Entities/PrerequisiteQuantityRange.cs +++ b/ShopifySharp/Entities/PrerequisiteQuantityRange.cs @@ -5,6 +5,6 @@ namespace ShopifySharp public class PrerequisiteQuantityRange { [JsonProperty("greater_than_or_equal_to")] - public int GreaterThanOrEqualTo { get; set; } + public int? GreaterThanOrEqualTo { get; set; } } -} \ No newline at end of file +} diff --git a/ShopifySharp/Entities/PrerequisiteToEntitlementQuantityRatio.cs b/ShopifySharp/Entities/PrerequisiteToEntitlementQuantityRatio.cs index 68a2118a..86abd583 100644 --- a/ShopifySharp/Entities/PrerequisiteToEntitlementQuantityRatio.cs +++ b/ShopifySharp/Entities/PrerequisiteToEntitlementQuantityRatio.cs @@ -5,9 +5,9 @@ namespace ShopifySharp public class PrerequisiteToEntitlementQuantityRatio { [JsonProperty("prerequisite_quantity")] - public int PrerequisiteQuantity { get; set; } + public int? PrerequisiteQuantity { get; set; } [JsonProperty("entitled_quantity")] - public int EntitledQuantity { get; set; } + public int? EntitledQuantity { get; set; } } -} \ No newline at end of file +} diff --git a/ShopifySharp/Entities/PriceRule.cs b/ShopifySharp/Entities/PriceRule.cs index 55e69ca7..cf2f674a 100644 --- a/ShopifySharp/Entities/PriceRule.cs +++ b/ShopifySharp/Entities/PriceRule.cs @@ -66,66 +66,38 @@ public class PriceRule : ShopifyObject [JsonProperty("customer_selection")] public string CustomerSelection { get; set; } - /** - * Prerequisite cart subtotal range. - */ - [JsonProperty("prerequisite_subtotal_range")] - public PrerequisiteValueRange PrerequisiteSubtotalRange { get; set; } + [JsonProperty("allocation_limit")] + public int? AllocationLimit { get; set; } /** - * Prerequisite shipping cost range.Can only be used when target_type is shipping_line. + * The date and time when the price rule starts. */ - [JsonProperty("prerequisite_shipping_price_range")] - public PrerequisiteValueRange PrerequisiteShippingPriceRange { get; set; } + [JsonProperty("starts_at")] + public DateTimeOffset? StartsAt { get; set; } /** - * Prerequisite cart quantity range. + * The date and time when the price rule ends.Must be after starts_at. */ - [JsonProperty("prerequisite_quantity_range")] - public PrerequisiteQuantityRange PrerequisiteQuantityRange { get; set; } + [JsonProperty("ends_at")] + public DateTimeOffset? EndsAt { get; set; } /** - * A list of prerequisite customer saved search ids. For the price rule to be applicable, - * the customer applying the price rule must be in the group of customers matching the customer saved searches. + * The date and time the object was created. */ - [JsonProperty("prerequisite_saved_search_ids")] - public IEnumerable PrerequisiteSavedSearchIds { get; set; } - - [JsonProperty("customer_segment_prerequisite_ids")] - public IEnumerable CustomerSegmentPrerequisiteIds { get; set; } - - [JsonProperty("prerequisite_to_entitlement_purchase")] - public PrerequisiteToEntitlementPurchase PrerequisiteToEntitlementPurchase { get; set; } - - [JsonProperty("prerequisite_product_ids")] - public IEnumerable PrerequisiteProductIds { get; set; } - - [JsonProperty("prerequisite_variant_ids")] - public IEnumerable PrerequisiteVariantIds { get; set; } - - [JsonProperty("prerequisite_collection_ids")] - public List PrerequisiteCollectionIds { get; set; } - - [JsonProperty("prerequisite_to_entitlement_quantity_ratio")] - public PrerequisiteToEntitlementQuantityRatio PrerequisiteToEntitlementQuantityRatio { get; set; } - - [JsonProperty("allocation_limit")] - public int? AllocationLimit { get; set; } - - + [JsonProperty("created_at")] + public DateTimeOffset? CreatedAt { get; set; } /** - * A list of prerequisite customer ids. For the price rule to be applicable, - * the customer applying the price rule must be in the group of customers specified. + * The date and time the object was last updated. */ - [JsonProperty("prerequisite_customer_ids")] - public IEnumerable PrerequisiteCustomerIds { get; set; } + [JsonProperty("updated_at")] + public DateTimeOffset? UpdatedAt { get; set; } /** * A list of entitled product ids.Can be used in combination with entitled_variant_ids. entitled_product_ids can - * only be used in conjunction with target_type set to line_itemif and target_selection set to entitled + * only be used in conjunction with target_type set to line_item if and target_selection set to entitled */ - [JsonProperty("entitled_product_ids")] + [JsonProperty("entitled_product_ids", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] public IEnumerable EntitledProductIds { get; set; } /** @@ -133,7 +105,7 @@ public class PriceRule : ShopifyObject * entitled_variant_ids can only be used in conjunction with target_type set to line_item if and target_selection set to * entitled */ - [JsonProperty("entitled_variant_ids")] + [JsonProperty("entitled_variant_ids", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] public IEnumerable EntitledVariantIds { get; set; } /** @@ -141,40 +113,64 @@ public class PriceRule : ShopifyObject * entitled_variant_ids. entitled_collection_ids can only be used in conjunction with target_typeset to line_item and * target_selection set to entitled */ - [JsonProperty("entitled_collection_ids")] + [JsonProperty("entitled_collection_ids", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] public IEnumerable EntitledCollectionIds { get; set; } - - /** * A list of shipping country ids. entitled_country_ids can only be used in conjunction with target_type set to * shipping_line and target_selection set to entitled. */ - [JsonProperty("entitled_country_ids")] + [JsonProperty("entitled_country_ids", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] public IEnumerable EntitledCountryIds { get; set; } /** - * The date and time when the price rule starts. + * A list of prerequisite customer ids. For the price rule to be applicable, + * the customer applying the price rule must be in the group of customers specified. */ - [JsonProperty("starts_at")] - public DateTimeOffset? StartsAt { get; set; } + [JsonProperty("prerequisite_customer_ids", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] + public IEnumerable PrerequisiteCustomerIds { get; set; } /** - * The date and time when the price rule ends.Must be after starts_at. + * Prerequisite cart subtotal range. */ - [JsonProperty("ends_at")] - public DateTimeOffset? EndsAt { get; set; } + [JsonProperty("prerequisite_subtotal_range", DefaultValueHandling = DefaultValueHandling.Ignore)] + public PrerequisiteValueRange PrerequisiteSubtotalRange { get; set; } /** - * The date and time the object was created. + * Prerequisite shipping cost range.Can only be used when target_type is shipping_line. */ - [JsonProperty("created_at")] - public DateTimeOffset? CreatedAt { get; set; } + [JsonProperty("prerequisite_shipping_price_range", DefaultValueHandling = DefaultValueHandling.Ignore)] + public PrerequisiteValueRange PrerequisiteShippingPriceRange { get; set; } /** - * The date and time the object was last updated. + * Prerequisite cart quantity range. */ - [JsonProperty("updated_at")] - public DateTimeOffset? UpdatedAt { get; set; } + [JsonProperty("prerequisite_quantity_range", DefaultValueHandling = DefaultValueHandling.Ignore)] + public PrerequisiteQuantityRange PrerequisiteQuantityRange { get; set; } + + /** + * A list of prerequisite customer saved search ids. For the price rule to be applicable, + * the customer applying the price rule must be in the group of customers matching the customer saved searches. + */ + [JsonProperty("prerequisite_saved_search_ids", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] + public IEnumerable PrerequisiteSavedSearchIds { get; set; } + + [JsonProperty("customer_segment_prerequisite_ids", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] + public IEnumerable CustomerSegmentPrerequisiteIds { get; set; } + + [JsonProperty("prerequisite_to_entitlement_purchase", DefaultValueHandling = DefaultValueHandling.Ignore)] + public PrerequisiteToEntitlementPurchase PrerequisiteToEntitlementPurchase { get; set; } + + [JsonProperty("prerequisite_product_ids", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] + public IEnumerable PrerequisiteProductIds { get; set; } + + [JsonProperty("prerequisite_variant_ids", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] + public IEnumerable PrerequisiteVariantIds { get; set; } + + [JsonProperty("prerequisite_collection_ids", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] + public IEnumerable PrerequisiteCollectionIds { get; set; } + + [JsonProperty("prerequisite_to_entitlement_quantity_ratio", DefaultValueHandling = DefaultValueHandling.Ignore)] + public PrerequisiteToEntitlementQuantityRatio PrerequisiteToEntitlementQuantityRatio { get; set; } } }