/*
 * doqium - service-auth REST API
 *
 * doqium - service-auth REST API
 *
 * The version of the OpenAPI document: 1.0
 *
 * Generated by: https://openapi-generator.tech
 */

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

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct UserSubscription {
    #[serde(rename = "planId")]
    pub plan_id: String,
    #[serde(rename = "subscriptionId")]
    pub subscription_id: String,
    #[serde(rename = "name")]
    pub name: String,
    #[serde(rename = "active")]
    pub active: bool,
    #[serde(rename = "from")]
    pub from: String,
    #[serde(rename = "to")]
    pub to: String,
    #[serde(rename = "metadata", deserialize_with = "Option::deserialize")]
    pub metadata: Option<Box<models::UserSubscriptionMetadata>>,
}

impl UserSubscription {
    pub fn new(
        plan_id: String,
        subscription_id: String,
        name: String,
        active: bool,
        from: String,
        to: String,
        metadata: Option<models::UserSubscriptionMetadata>,
    ) -> UserSubscription {
        UserSubscription {
            plan_id,
            subscription_id,
            name,
            active,
            from,
            to,
            metadata: if let Some(x) = metadata {
                Some(Box::new(x))
            } else {
                None
            },
        }
    }
}
