sellapp-sdk 0.2.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};
/// A subscription of the signed-in customer. Provider IDs and seller-only details are not included.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(remote = "Self")]
pub struct CustomerPortalSubscription {
    /// The SellApp subscription ID, used as `productSubscription` in the action routes.
    pub id: i64,
    pub status: CustomerPortalSubscriptionStatus,
    /// Whether the subscription ends when the current period ends instead of renewing.
    pub cancel_at_period_end: bool,
    pub current_period_start: Option<String>,
    pub current_period_end: Option<String>,
    /// When the trial ends, while the subscription is `TRIALING`. It is `null` otherwise, including once the trial has ended. The seller API's `trial_ends_at` keeps its value after the trial.
    pub trial_ends_at: Option<String>,
    pub paused_at: Option<String>,
    /// When a paused subscription resumes by itself, or `null` when it has no automatic resume date.
    pub pause_resumes_at: Option<String>,
    /// The plan the subscription bills on now, or `null` when the plan no longer exists.
    pub plan: Option<CustomerPortalSubscriptionPlan>,
    pub created_at: Option<String>,
    pub updated_at: Option<String>,
    /// 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 CustomerPortalSubscription {
    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        Self::serialize(self, serializer)
    }
}
impl<'de> Deserialize<'de> for CustomerPortalSubscription {
    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, "CustomerPortalSubscription", false)
            .map_err(serde::de::Error::custom)?;
        crate::runtime_schema::retain_model_fields(&mut value, "CustomerPortalSubscription");
        Self::deserialize(value).map_err(serde::de::Error::custom)
    }
}
impl CustomerPortalSubscription {
    /// 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, "CustomerPortalSubscription", true)
    }
}