Skip to content

Commit

Permalink
Fix PriceRule tests by adding DefaultValueHandling for Entitled*/Prer…
Browse files Browse the repository at this point in the history
…eq* properties
  • Loading branch information
nozzlegear committed Jun 22, 2023
1 parent fa42a75 commit 4db57f6
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 68 deletions.
4 changes: 2 additions & 2 deletions ShopifySharp.Tests/PriceRule_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions ShopifySharp/Entities/PrerequisiteQuantityRange.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
}
}
118 changes: 57 additions & 61 deletions ShopifySharp/Entities/PriceRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,115 +66,111 @@ 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<long> PrerequisiteSavedSearchIds { get; set; }

[JsonProperty("customer_segment_prerequisite_ids")]
public IEnumerable<long> CustomerSegmentPrerequisiteIds { get; set; }

[JsonProperty("prerequisite_to_entitlement_purchase")]
public PrerequisiteToEntitlementPurchase PrerequisiteToEntitlementPurchase { get; set; }

[JsonProperty("prerequisite_product_ids")]
public IEnumerable<long> PrerequisiteProductIds { get; set; }

[JsonProperty("prerequisite_variant_ids")]
public IEnumerable<long> PrerequisiteVariantIds { get; set; }

[JsonProperty("prerequisite_collection_ids")]
public List<object> 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<long> 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<long> EntitledProductIds { get; set; }

/**
* A list of entitled product variant ids. Can be used in combination with entitled_product_ids.
* 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<long> EntitledVariantIds { get; set; }

/**
* A list of entitled collection ids. Cannot be used in combination with entitled_product_ids nor
* 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<long> 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<long> 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<long> 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<long> PrerequisiteSavedSearchIds { get; set; }

[JsonProperty("customer_segment_prerequisite_ids", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)]
public IEnumerable<long> 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<long> PrerequisiteProductIds { get; set; }

[JsonProperty("prerequisite_variant_ids", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)]
public IEnumerable<long> PrerequisiteVariantIds { get; set; }

[JsonProperty("prerequisite_collection_ids", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)]
public IEnumerable<object> PrerequisiteCollectionIds { get; set; }

[JsonProperty("prerequisite_to_entitlement_quantity_ratio", DefaultValueHandling = DefaultValueHandling.Ignore)]
public PrerequisiteToEntitlementQuantityRatio PrerequisiteToEntitlementQuantityRatio { get; set; }
}
}

0 comments on commit 4db57f6

Please sign in to comment.