square_api_client/models/
order_line_item.rs

1//! Model struct for OrderLineItem type
2
3use std::collections::HashMap;
4
5use serde::{Deserialize, Serialize};
6
7use super::{
8    enums::OrderLineItemItemType, Money, OrderLineItemAppliedDiscount, OrderLineItemAppliedTax,
9    OrderLineItemModifier, OrderLineItemPricingBlocklists, OrderQuantityUnit,
10};
11
12/// Represents a line item in an order.
13///
14/// Each line item describes a different product to purchase, with its own quantity and price
15/// details.
16#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
17pub struct OrderLineItem {
18    /// A unique ID that identifies the line item only within this order.
19    pub uid: Option<String>,
20    /// The name of the line item.
21    pub name: Option<String>,
22    /// The quantity purchased, formatted as a decimal number. For example, "3".
23    ///
24    /// Line items with a quantity of "0" are automatically removed when paying for or otherwise
25    /// completing the order.
26    ///
27    /// Line items with a `quantity_unit` can have non-integer quantities. For example, "1.70000".
28    pub quantity: String,
29    /// The unit and precision that this line item's quantity is measured in.
30    pub quantity_unit: Option<OrderQuantityUnit>,
31    /// The note of the line item.
32    pub note: Option<String>,
33    /// The [CatalogItemVariation] ID applied to this line item.
34    pub catalog_object_id: Option<String>,
35    /// The version of the catalog object that this line item references.
36    pub catalog_version: Option<i64>,
37    /// The name of the variation applied to this line item.
38    pub variation_name: Option<String>,
39    /// The type of line item: an itemized sale, a non-itemized sale (custom amount), or the
40    /// activation or reloading of a gift card.
41    pub item_type: Option<OrderLineItemItemType>,
42    /// Application-defined data attached to this order. Metadata fields are intended to store
43    /// descriptive references or associations with an entity in another system or store brief
44    /// information about the object. Square does not process this field; it only stores and returns
45    /// it in relevant API calls. Do not use metadata to store any sensitive information (such as
46    /// personally identifiable information or card details).
47    ///
48    /// Keys written by applications must be 60 characters or less and must be in the character set
49    /// `[a-zA-Z0-9_-]`. Entries can also include metadata generated by Square. These keys are
50    /// prefixed with a namespace, separated from the key with a ':' character.
51    ///
52    /// Values have a maximum length of 255 characters.
53    ///
54    /// An application can have up to 10 entries per metadata field.
55    ///
56    /// Entries written by applications are private and can only be read or modified by the same
57    /// application.
58    ///
59    /// For more information,
60    /// see [Metadata](https://developer.squareup.com/docs/build-basics/metadata).
61    pub metadata: Option<HashMap<String, String>>,
62    /// The [CatalogModifier]s applied to this line item.
63    pub modifiers: Option<Vec<OrderLineItemModifier>>,
64    /// The list of references to taxes applied to this line item. Each `OrderLineItemAppliedTax`
65    /// has a `tax_uid` that references the `uid` of a top-level `OrderLineItemTax` applied to the
66    /// line item. On reads, the amount applied is populated.
67    ///
68    /// An `OrderLineItemAppliedTax` is automatically created on every line item for all `ORDER`
69    /// scoped taxes added to the order. `OrderLineItemAppliedTax` records for `LINE_ITEM` scoped
70    /// taxes must be added in requests for the tax to apply to any line items.
71    ///
72    /// To change the amount of a tax, modify the referenced top-level tax.
73    pub applied_taxes: Option<Vec<OrderLineItemAppliedTax>>,
74    /// The list of references to discounts applied to this line item. Each
75    /// `OrderLineItemAppliedDiscount` has a `discount_uid` that references the `uid` of a top-level
76    /// `OrderLineItemDiscounts` applied to the line item. On reads, the amount applied is
77    /// populated.
78    ///
79    /// An `OrderLineItemAppliedDiscount` is automatically created on every line item for all
80    /// `ORDER` scoped discounts that are added to the order. `OrderLineItemAppliedDiscount` records
81    /// for `LINE_ITEM` scoped discounts must be added in requests for the discount to apply to any
82    /// line items.
83    ///
84    /// To change the amount of a discount, modify the referenced top-level discount.
85    pub applied_discounts: Option<Vec<OrderLineItemAppliedDiscount>>,
86    /// The base price for a single unit of the line item.
87    pub base_price_money: Option<Money>,
88    /// **Read only** The total price of all item variations sold in this line item. The price is
89    /// calculated as `base_price_money` multiplied by `quantity`. It does not include modifiers.
90    pub variation_total_price_money: Option<Money>,
91    /// **Read only** The amount of money made in gross sales for this line item. The amount is
92    /// calculated as the sum of the variation's total price and each modifier's total price.
93    pub gross_sales_money: Option<Money>,
94    /// **Read only** The total amount of tax money to collect for the line item.
95    pub total_tax_money: Option<Money>,
96    /// **Read only** The total amount of discount money to collect for the line item.
97    pub total_discount_money: Option<Money>,
98    /// **Read only** The total amount of money to collect for this line item.
99    pub total_money: Option<Money>,
100    /// Describes pricing adjustments that are blocked from manual and automatic application to a
101    /// line item. For more information, see [Apply Taxes and
102    /// Discounts](https://developer.squareup.com/docs/orders-api/apply-taxes-and-discounts).
103    pub pricing_blocklists: Option<OrderLineItemPricingBlocklists>,
104}