late 0.0.1097

API reference for Zernio. Authenticate with a Bearer API key. Base URL: https://zernio.com/api Versioning and deprecation: all endpoints are versioned in the URL path (current version: /v1). Breaking changes only ship in a new path version; existing versions keep working. Deprecated operations are marked 'deprecated: true' in this spec and announced in the changelog (https://zernio.com/changelog) before removal. Errors: every 4xx/5xx response is application/json with a machine-readable 'code' and a human-readable 'error' message (see the ErrorResponse schema). Request ids: responses carry an X-Request-Id header with the id we log the request under. Quote it when reporting a problem. A valid x-request-id you send is reused as that id.
Documentation
/*
 * Zernio API
 *
 * API reference for Zernio. Authenticate with a Bearer API key. Base URL: https://zernio.com/api  Versioning and deprecation: all endpoints are versioned in the URL path (current version: /v1). Breaking changes only ship in a new path version; existing versions keep working. Deprecated operations are marked 'deprecated: true' in this spec and announced in the changelog (https://zernio.com/changelog) before removal.  Errors: every 4xx/5xx response is application/json with a machine-readable 'code' and a human-readable 'error' message (see the ErrorResponse schema).  Request ids: responses carry an X-Request-Id header with the id we log the request under. Quote it when reporting a problem. A valid x-request-id you send is reused as that id.
 *
 * The version of the OpenAPI document: 1.168.0
 * Contact: support@zernio.com
 * Generated by: https://openapi-generator.tech
 */

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

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct CreateCommerceDiscountRequest {
    #[serde(rename = "accountId")]
    pub account_id: String,
    #[serde(rename = "title")]
    pub title: String,
    #[serde(rename = "method")]
    pub method: Method,
    #[serde(rename = "type")]
    pub r#type: Type,
    /// Required for method code.
    #[serde(rename = "code", skip_serializing_if = "Option::is_none")]
    pub code: Option<String>,
    /// For type percentage, e.g. 15 for 15%.
    #[serde(rename = "percentage", skip_serializing_if = "Option::is_none")]
    pub percentage: Option<f64>,
    /// For type fixed_amount, a decimal in the store currency.
    #[serde(rename = "amount", skip_serializing_if = "Option::is_none")]
    pub amount: Option<String>,
    /// fixed_amount only: take the amount off each item instead of once per order.
    #[serde(rename = "appliesOnEachItem", skip_serializing_if = "Option::is_none")]
    pub applies_on_each_item: Option<bool>,
    /// Minimum order subtotal, a decimal in the store currency.
    #[serde(
        rename = "minimumSubtotal",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub minimum_subtotal: Option<Option<String>>,
    #[serde(
        rename = "minimumQuantity",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub minimum_quantity: Option<Option<i32>>,
    /// Code discounts only: total uses allowed.
    #[serde(
        rename = "usageLimit",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub usage_limit: Option<Option<i32>>,
    /// Code discounts only.
    #[serde(rename = "oncePerCustomer", skip_serializing_if = "Option::is_none")]
    pub once_per_customer: Option<bool>,
    /// Defaults to now.
    #[serde(rename = "startsAt", skip_serializing_if = "Option::is_none")]
    pub starts_at: Option<String>,
    #[serde(
        rename = "endsAt",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub ends_at: Option<Option<String>>,
    #[serde(rename = "productIds", skip_serializing_if = "Option::is_none")]
    pub product_ids: Option<Vec<String>>,
    #[serde(rename = "collectionIds", skip_serializing_if = "Option::is_none")]
    pub collection_ids: Option<Vec<String>>,
}

impl CreateCommerceDiscountRequest {
    pub fn new(
        account_id: String,
        title: String,
        method: Method,
        r#type: Type,
    ) -> CreateCommerceDiscountRequest {
        CreateCommerceDiscountRequest {
            account_id,
            title,
            method,
            r#type,
            code: None,
            percentage: None,
            amount: None,
            applies_on_each_item: None,
            minimum_subtotal: None,
            minimum_quantity: None,
            usage_limit: None,
            once_per_customer: None,
            starts_at: None,
            ends_at: None,
            product_ids: None,
            collection_ids: None,
        }
    }
}
///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Method {
    #[serde(rename = "code")]
    Code,
    #[serde(rename = "automatic")]
    Automatic,
}

impl Default for Method {
    fn default() -> Method {
        Self::Code
    }
}
///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "percentage")]
    Percentage,
    #[serde(rename = "fixed_amount")]
    FixedAmount,
    #[serde(rename = "free_shipping")]
    FreeShipping,
}

impl Default for Type {
    fn default() -> Type {
        Self::Percentage
    }
}