amazon-spapi 2.0.3

A Rust client library for Amazon Selling Partner API (SP-API)
Documentation
/*
 * Selling Partner API for Orders
 *
 * Use the Orders Selling Partner API to programmatically retrieve order information. With this API, you can develop fast, flexible, and custom applications to manage order synchronization, perform order research, and create demand-based decision support tools.   _Note:_ For the JP, AU, and SG marketplaces, the Orders API supports orders from 2016 onward. For all other marketplaces, the Orders API supports orders for the last two years (orders older than this don't show up in the response).
 *
 * The version of the OpenAPI document: v0
 * 
 * Generated by: https://openapi-generator.tech
 */

use crate::models;
use serde::{Deserialize, Serialize};

/// Order : Order information.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Order {
    /// An Amazon-defined order identifier, in 3-7-7 format.
    #[serde(rename = "AmazonOrderId")]
    pub amazon_order_id: String,
    /// A seller-defined order identifier.
    #[serde(rename = "SellerOrderId", skip_serializing_if = "Option::is_none")]
    pub seller_order_id: Option<String>,
    /// The date when the order was created.
    #[serde(rename = "PurchaseDate")]
    pub purchase_date: String,
    /// The date when the order was last updated.  __Note__: `LastUpdateDate` is returned with an incorrect date for orders that were last updated before 2009-04-01.
    #[serde(rename = "LastUpdateDate")]
    pub last_update_date: String,
    /// The current order status.
    #[serde(rename = "OrderStatus")]
    pub order_status: OrderStatus,
    /// Whether the order was fulfilled by Amazon (`AFN`) or by the seller (`MFN`).
    #[serde(rename = "FulfillmentChannel", skip_serializing_if = "Option::is_none")]
    pub fulfillment_channel: Option<FulfillmentChannel>,
    /// The sales channel for the first item in the order.
    #[serde(rename = "SalesChannel", skip_serializing_if = "Option::is_none")]
    pub sales_channel: Option<String>,
    /// The order channel for the first item in the order.
    #[serde(rename = "OrderChannel", skip_serializing_if = "Option::is_none")]
    pub order_channel: Option<String>,
    /// The order's shipment service level.
    #[serde(rename = "ShipServiceLevel", skip_serializing_if = "Option::is_none")]
    pub ship_service_level: Option<String>,
    #[serde(rename = "OrderTotal", skip_serializing_if = "Option::is_none")]
    pub order_total: Option<Box<models::orders_v0::Money>>,
    /// The number of items shipped.
    #[serde(rename = "NumberOfItemsShipped", skip_serializing_if = "Option::is_none")]
    pub number_of_items_shipped: Option<i32>,
    /// The number of items unshipped.
    #[serde(rename = "NumberOfItemsUnshipped", skip_serializing_if = "Option::is_none")]
    pub number_of_items_unshipped: Option<i32>,
    /// A list of payment execution detail items.
    #[serde(rename = "PaymentExecutionDetail", skip_serializing_if = "Option::is_none")]
    pub payment_execution_detail: Option<Vec<models::orders_v0::PaymentExecutionDetailItem>>,
    /// The payment method for the order. This property is limited to COD and CVS payment methods. Unless you need the specific COD payment information provided by the `PaymentExecutionDetailItem` object, we recommend using the `PaymentMethodDetails` property to get payment method information.
    #[serde(rename = "PaymentMethod", skip_serializing_if = "Option::is_none")]
    pub payment_method: Option<PaymentMethod>,
    /// A list of payment method detail items.
    #[serde(rename = "PaymentMethodDetails", skip_serializing_if = "Option::is_none")]
    pub payment_method_details: Option<Vec<String>>,
    /// The identifier for the marketplace where the order was placed.
    #[serde(rename = "MarketplaceId", skip_serializing_if = "Option::is_none")]
    pub marketplace_id: Option<String>,
    /// The shipment service level category for the order.  **Possible values**: `Expedited`, `FreeEconomy`, `NextDay`, `Priority`, `SameDay`, `SecondDay`, `Scheduled`, and `Standard`.
    #[serde(rename = "ShipmentServiceLevelCategory", skip_serializing_if = "Option::is_none")]
    pub shipment_service_level_category: Option<String>,
    #[serde(rename = "EasyShipShipmentStatus", skip_serializing_if = "Option::is_none")]
    pub easy_ship_shipment_status: Option<models::orders_v0::EasyShipShipmentStatus>,
    /// Custom ship label for Checkout by Amazon (CBA).
    #[serde(rename = "CbaDisplayableShippingLabel", skip_serializing_if = "Option::is_none")]
    pub cba_displayable_shipping_label: Option<String>,
    /// The order's type.
    #[serde(rename = "OrderType", skip_serializing_if = "Option::is_none")]
    pub order_type: Option<OrderType>,
    /// The start of the time period within which you have committed to ship the order. In [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date time format. Only returned for seller-fulfilled orders.  __Note__: `EarliestShipDate` might not be returned for orders placed before February 1, 2013.
    #[serde(rename = "EarliestShipDate", skip_serializing_if = "Option::is_none")]
    pub earliest_ship_date: Option<String>,
    /// The end of the time period within which you have committed to ship the order. In [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date time format. Only returned for seller-fulfilled orders.  __Note__: `LatestShipDate` might not be returned for orders placed before February 1, 2013.
    #[serde(rename = "LatestShipDate", skip_serializing_if = "Option::is_none")]
    pub latest_ship_date: Option<String>,
    /// The start of the time period within which you have committed to fulfill the order. In [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date time format. Only returned for seller-fulfilled orders.
    #[serde(rename = "EarliestDeliveryDate", skip_serializing_if = "Option::is_none")]
    pub earliest_delivery_date: Option<String>,
    /// The end of the time period within which you have committed to fulfill the order. In [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) date time format. Only returned for seller-fulfilled orders that do not have a `PendingAvailability`, `Pending`, or `Canceled` status.
    #[serde(rename = "LatestDeliveryDate", skip_serializing_if = "Option::is_none")]
    pub latest_delivery_date: Option<String>,
    /// When true, the order is an Amazon Business order. An Amazon Business order is an order where the buyer is a Verified Business Buyer.
    #[serde(rename = "IsBusinessOrder", skip_serializing_if = "Option::is_none")]
    pub is_business_order: Option<bool>,
    /// When true, the order is a seller-fulfilled Amazon Prime order.
    #[serde(rename = "IsPrime", skip_serializing_if = "Option::is_none")]
    pub is_prime: Option<bool>,
    /// When true, the order has a Premium Shipping Service Level Agreement. For more information about Premium Shipping orders, refer to \"Premium Shipping Options\" in the Seller Central Help for your marketplace.
    #[serde(rename = "IsPremiumOrder", skip_serializing_if = "Option::is_none")]
    pub is_premium_order: Option<bool>,
    /// When true, the order is a `GlobalExpress` order.
    #[serde(rename = "IsGlobalExpressEnabled", skip_serializing_if = "Option::is_none")]
    pub is_global_express_enabled: Option<bool>,
    /// The order ID value for the order that is being replaced. Returned only if IsReplacementOrder = true.
    #[serde(rename = "ReplacedOrderId", skip_serializing_if = "Option::is_none")]
    pub replaced_order_id: Option<String>,
    /// When true, this is a replacement order.
    #[serde(rename = "IsReplacementOrder", skip_serializing_if = "Option::is_none")]
    pub is_replacement_order: Option<bool>,
    /// Indicates the date by which the seller must respond to the buyer with an estimated ship date. Only returned for Sourcing on Demand orders.
    #[serde(rename = "PromiseResponseDueDate", skip_serializing_if = "Option::is_none")]
    pub promise_response_due_date: Option<String>,
    /// When true, the estimated ship date is set for the order. Only returned for Sourcing on Demand orders.
    #[serde(rename = "IsEstimatedShipDateSet", skip_serializing_if = "Option::is_none")]
    pub is_estimated_ship_date_set: Option<bool>,
    /// When true, the item within this order was bought and re-sold by Amazon Business EU SARL (ABEU). By buying and instantly re-selling your items, ABEU becomes the seller of record, making your inventory available for sale to customers who would not otherwise purchase from a third-party seller.
    #[serde(rename = "IsSoldByAB", skip_serializing_if = "Option::is_none")]
    pub is_sold_by_ab: Option<bool>,
    /// When true, the item within this order was bought and re-sold by Amazon Business EU SARL (ABEU). By buying and instantly re-selling your items, ABEU becomes the seller of record, making your inventory available for sale to customers who would not otherwise purchase from a third-party seller.
    #[serde(rename = "IsIBA", skip_serializing_if = "Option::is_none")]
    pub is_iba: Option<bool>,
    #[serde(rename = "DefaultShipFromLocationAddress", skip_serializing_if = "Option::is_none")]
    pub default_ship_from_location_address: Option<Box<models::orders_v0::Address>>,
    /// The buyer's invoicing preference. Sellers can use this data to issue electronic invoices for orders in Turkey.  **Note**: This attribute is only available in the Turkey marketplace.
    #[serde(rename = "BuyerInvoicePreference", skip_serializing_if = "Option::is_none")]
    pub buyer_invoice_preference: Option<BuyerInvoicePreference>,
    #[serde(rename = "BuyerTaxInformation", skip_serializing_if = "Option::is_none")]
    pub buyer_tax_information: Option<Box<models::orders_v0::BuyerTaxInformation>>,
    #[serde(rename = "FulfillmentInstruction", skip_serializing_if = "Option::is_none")]
    pub fulfillment_instruction: Option<Box<models::orders_v0::FulfillmentInstruction>>,
    /// When true, this order is marked to be picked up from a store rather than delivered.
    #[serde(rename = "IsISPU", skip_serializing_if = "Option::is_none")]
    pub is_ispu: Option<bool>,
    /// When true, this order is marked to be delivered to an Access Point. The access location is chosen by the customer. Access Points include Amazon Hub Lockers, Amazon Hub Counters, and pickup points operated by carriers.
    #[serde(rename = "IsAccessPointOrder", skip_serializing_if = "Option::is_none")]
    pub is_access_point_order: Option<bool>,
    #[serde(rename = "MarketplaceTaxInfo", skip_serializing_if = "Option::is_none")]
    pub marketplace_tax_info: Option<Box<models::orders_v0::MarketplaceTaxInfo>>,
    /// The seller’s friendly name registered in the marketplace where the sale took place. Sellers can use this data to issue electronic invoices for orders in Brazil.  **Note**: This attribute is only available in the Brazil marketplace for the orders with `Pending` or `Unshipped` status.
    #[serde(rename = "SellerDisplayName", skip_serializing_if = "Option::is_none")]
    pub seller_display_name: Option<String>,
    #[serde(rename = "ShippingAddress", skip_serializing_if = "Option::is_none")]
    pub shipping_address: Option<Box<models::orders_v0::Address>>,
    #[serde(rename = "BuyerInfo", skip_serializing_if = "Option::is_none")]
    pub buyer_info: Option<Box<models::orders_v0::BuyerInfo>>,
    #[serde(rename = "AutomatedShippingSettings", skip_serializing_if = "Option::is_none")]
    pub automated_shipping_settings: Option<Box<models::orders_v0::AutomatedShippingSettings>>,
    /// Whether the order contains regulated items which may require additional approval steps before being fulfilled.
    #[serde(rename = "HasRegulatedItems", skip_serializing_if = "Option::is_none")]
    pub has_regulated_items: Option<bool>,
    #[serde(rename = "ElectronicInvoiceStatus", skip_serializing_if = "Option::is_none")]
    pub electronic_invoice_status: Option<models::orders_v0::ElectronicInvoiceStatus>,
}

impl Order {
    /// Order information.
    pub fn new(amazon_order_id: String, purchase_date: String, last_update_date: String, order_status: OrderStatus) -> Order {
        Order {
            amazon_order_id,
            seller_order_id: None,
            purchase_date,
            last_update_date,
            order_status,
            fulfillment_channel: None,
            sales_channel: None,
            order_channel: None,
            ship_service_level: None,
            order_total: None,
            number_of_items_shipped: None,
            number_of_items_unshipped: None,
            payment_execution_detail: None,
            payment_method: None,
            payment_method_details: None,
            marketplace_id: None,
            shipment_service_level_category: None,
            easy_ship_shipment_status: None,
            cba_displayable_shipping_label: None,
            order_type: None,
            earliest_ship_date: None,
            latest_ship_date: None,
            earliest_delivery_date: None,
            latest_delivery_date: None,
            is_business_order: None,
            is_prime: None,
            is_premium_order: None,
            is_global_express_enabled: None,
            replaced_order_id: None,
            is_replacement_order: None,
            promise_response_due_date: None,
            is_estimated_ship_date_set: None,
            is_sold_by_ab: None,
            is_iba: None,
            default_ship_from_location_address: None,
            buyer_invoice_preference: None,
            buyer_tax_information: None,
            fulfillment_instruction: None,
            is_ispu: None,
            is_access_point_order: None,
            marketplace_tax_info: None,
            seller_display_name: None,
            shipping_address: None,
            buyer_info: None,
            automated_shipping_settings: None,
            has_regulated_items: None,
            electronic_invoice_status: None,
        }
    }
}
/// The current order status.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum OrderStatus {
    #[serde(rename = "Pending")]
    Pending,
    #[serde(rename = "Unshipped")]
    Unshipped,
    #[serde(rename = "PartiallyShipped")]
    PartiallyShipped,
    #[serde(rename = "Shipped")]
    Shipped,
    #[serde(rename = "Canceled")]
    Canceled,
    #[serde(rename = "Unfulfillable")]
    Unfulfillable,
    #[serde(rename = "InvoiceUnconfirmed")]
    InvoiceUnconfirmed,
    #[serde(rename = "PendingAvailability")]
    PendingAvailability,
}

impl Default for OrderStatus {
    fn default() -> OrderStatus {
        Self::Pending
    }
}
/// Whether the order was fulfilled by Amazon (`AFN`) or by the seller (`MFN`).
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum FulfillmentChannel {
    #[serde(rename = "MFN")]
    Mfn,
    #[serde(rename = "AFN")]
    Afn,
}

impl Default for FulfillmentChannel {
    fn default() -> FulfillmentChannel {
        Self::Mfn
    }
}
/// The payment method for the order. This property is limited to COD and CVS payment methods. Unless you need the specific COD payment information provided by the `PaymentExecutionDetailItem` object, we recommend using the `PaymentMethodDetails` property to get payment method information.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum PaymentMethod {
    #[serde(rename = "COD")]
    Cod,
    #[serde(rename = "CVS")]
    Cvs,
    #[serde(rename = "Other")]
    Other,
}

impl Default for PaymentMethod {
    fn default() -> PaymentMethod {
        Self::Cod
    }
}
/// The order's type.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum OrderType {
    #[serde(rename = "StandardOrder")]
    StandardOrder,
    #[serde(rename = "LongLeadTimeOrder")]
    LongLeadTimeOrder,
    #[serde(rename = "Preorder")]
    Preorder,
    #[serde(rename = "BackOrder")]
    BackOrder,
    #[serde(rename = "SourcingOnDemandOrder")]
    SourcingOnDemandOrder,
}

impl Default for OrderType {
    fn default() -> OrderType {
        Self::StandardOrder
    }
}
/// The buyer's invoicing preference. Sellers can use this data to issue electronic invoices for orders in Turkey.  **Note**: This attribute is only available in the Turkey marketplace.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum BuyerInvoicePreference {
    #[serde(rename = "INDIVIDUAL")]
    Individual,
    #[serde(rename = "BUSINESS")]
    Business,
}

impl Default for BuyerInvoicePreference {
    fn default() -> BuyerInvoicePreference {
        Self::Individual
    }
}