square_api_client/models/catalog_pricing_rule.rs
1//! Model struct for CatalogPricingRule type.
2
3use serde::{Deserialize, Serialize};
4
5use super::{enums::ExcludeStrategy, Money};
6
7/// Defines how discounts are automatically applied to a set of items that match the pricing rule
8/// during the active time period.
9#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
10pub struct CatalogPricingRule {
11 /// User-defined name for the pricing rule. For example, "Buy one get one free" or "10% off".
12 pub name: Option<String>,
13 /// A list of unique IDs for the catalog time periods when this pricing rule is in effect. If
14 /// left unset, the pricing rule is always in effect.
15 pub time_period_ids: Option<Vec<String>>,
16 /// Unique ID for the `CatalogDiscount` to take off the price of all matched items.
17 pub discount_id: Option<String>,
18 /// Unique ID for the `CatalogProductSet` that will be matched by this rule. A match rule
19 /// matches within the entire cart, and can match multiple times. This field will always be set.
20 pub match_products_id: Option<String>,
21 /// **Deprecated:** Please use the `exclude_products_id` field to apply an exclude set instead.
22 /// Exclude sets allow better control over quantity ranges and offer more flexibility for which
23 /// matched items receive a discount.
24 ///
25 /// `CatalogProductSet` to apply the pricing to. An apply rule matches within the subset of the
26 /// cart that fits the match rules (the match set). An apply rule can only match once in the
27 /// match set. If not supplied, the pricing will be applied to all products in the match set.
28 /// Other products retain their base price, or a price generated by other rules.
29 #[deprecated]
30 pub apply_products_id: Option<String>,
31 /// `CatalogProductSet` to exclude from the pricing rule. An exclude rule matches within the
32 /// subset of the cart that fits the match rules (the match set). An exclude rule can only match
33 /// once in the match set. If not supplied, the pricing will be applied to all products in the
34 /// match set. Other products retain their base price, or a price generated by other rules.
35 pub exclude_products_id: Option<String>,
36 /// Represents the date the Pricing Rule is valid from. Represented in RFC 3339 full-date format
37 /// (YYYY-MM-DD).
38 pub valid_from_date: Option<String>,
39 /// Represents the local time the pricing rule should be valid from. Represented in RFC 3339
40 /// partial-time format (HH:MM:SS). Partial seconds will be truncated.
41 pub valid_from_local_time: Option<String>,
42 /// Represents the date the Pricing Rule is valid until. Represented in RFC 3339 full-date
43 /// format (YYYY-MM-DD).
44 pub valid_until_date: Option<String>,
45 /// Represents the local time the pricing rule should be valid until. Represented in RFC 3339
46 /// partial-time format (HH:MM:SS). Partial seconds will be truncated.
47 pub valid_until_local_time: Option<String>,
48 /// If an `exclude_products_id` was given, controls which subset of matched products is excluded
49 /// from any discounts.
50 ///
51 /// Default value: `LEAST_EXPENSIVE`
52 pub exclude_strategy: Option<ExcludeStrategy>,
53 /// The minimum order subtotal (before discounts or taxes are applied) that must be met before
54 /// this rule may be applied.
55 pub minimum_order_subtotal_money: Option<Money>,
56 /// A list of IDs of customer groups, the members of which are eligible for discounts specified
57 /// in this pricing rule. Notice that a group ID is generated by the Customers API. If this
58 /// field is not set, the specified discount applies to matched products sold to anyone whether
59 /// the buyer has a customer profile created or not. If this `customer_group_ids_any` field is
60 /// set, the specified discount applies only to matched products sold to customers belonging to
61 /// the specified customer groups.
62 pub customer_group_ids_any: Option<Vec<String>>,
63}