sellapp-sdk 0.1.1

Official Rust SDK for the SellApp API: manage products, orders, subscriptions, and customers.
// This file is auto-generated by oagen. Do not edit.

#[allow(unused_imports)]
use super::*;
#[allow(unused_imports)]
use crate::enums::*;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(remote = "Self")]
pub struct SdkCreateUpsellOfferRequestApplicationJson {
    pub name: String,
    #[serde(
        skip_serializing_if = "Option::is_none",
        default,
        deserialize_with = "crate::runtime_schema::present_nullable"
    )]
    pub description: Option<Option<String>>,
    pub is_active: bool,
    pub source_listing_id: i64,
    #[serde(
        skip_serializing_if = "Option::is_none",
        default,
        deserialize_with = "crate::runtime_schema::present_nullable"
    )]
    pub source_variant_id: Option<Option<i64>>,
    /// Integer USD cents, for example 1000 for USD 10.00.
    #[serde(
        skip_serializing_if = "Option::is_none",
        default,
        deserialize_with = "crate::runtime_schema::present_nullable"
    )]
    pub minimum_order_total_usd_cents: Option<Option<i64>>,
    /// Integer USD cents. When present, must be greater than or equal to minimum_order_total_usd_cents.
    #[serde(
        skip_serializing_if = "Option::is_none",
        default,
        deserialize_with = "crate::runtime_schema::present_nullable"
    )]
    pub maximum_order_total_usd_cents: Option<Option<i64>>,
    #[serde(
        skip_serializing_if = "Option::is_none",
        default,
        deserialize_with = "crate::runtime_schema::present_nullable"
    )]
    pub starts_at: Option<Option<String>>,
    /// Must be after or equal to starts_at.
    #[serde(
        skip_serializing_if = "Option::is_none",
        default,
        deserialize_with = "crate::runtime_schema::present_nullable"
    )]
    pub ends_at: Option<Option<String>>,
    #[serde(
        skip_serializing_if = "Option::is_none",
        default,
        deserialize_with = "crate::runtime_schema::present_nullable"
    )]
    pub available_for_days: Option<Option<i64>>,
    #[serde(
        skip_serializing_if = "Option::is_none",
        default,
        deserialize_with = "crate::runtime_schema::present_nullable"
    )]
    pub max_accepts_per_customer: Option<Option<i64>>,
    /// Required optimistic concurrency token for updates. Use the version from the latest response; stale versions are rejected with 422.
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub expected_version: Option<i64>,
    /// Complete ordered target-item set. Target variant IDs must be unique and belong to their target product in this store.
    pub items: Vec<CreateUpsellOfferRequestApplicationJsonPropertyItemsItem>,
    /// Fields returned by a newer API version that are not yet known to this SDK.
    #[serde(default, flatten)]
    pub additional_properties: std::collections::HashMap<String, serde_json::Value>,
}
impl Serialize for SdkCreateUpsellOfferRequestApplicationJson {
    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        Self::serialize(self, serializer)
    }
}
impl<'de> Deserialize<'de> for SdkCreateUpsellOfferRequestApplicationJson {
    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        let mut value = serde_json::Value::deserialize(deserializer)?;
        crate::runtime_schema::model(&value, "SdkCreateUpsellOfferRequestApplicationJson", false)
            .map_err(serde::de::Error::custom)?;
        crate::runtime_schema::retain_model_fields(
            &mut value,
            "SdkCreateUpsellOfferRequestApplicationJson",
        );
        Self::deserialize(value).map_err(serde::de::Error::custom)
    }
}
impl SdkCreateUpsellOfferRequestApplicationJson {
    /// Validate the serialized request, including schema constraints and compatibility rules.
    pub fn validate_request(&self) -> Result<(), crate::error::Error> {
        let value = serde_json::to_value(self)
            .map_err(|e| crate::error::Error::Serialization(e.to_string()))?;
        crate::runtime_schema::model(&value, "SdkCreateUpsellOfferRequestApplicationJson", true)
    }
}