enbbox 1.0.1

Notification infrastructure API — open-source alternative to Novu/Courier
Documentation
/*
 * enbbox API
 *
 * Notification infrastructure API — open-source alternative to Novu/Courier
 *
 * The version of the OpenAPI document: 1.0.0
 * 
 * Generated by: https://openapi-generator.tech
 */

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

/// Subscription : Current subscription details.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Subscription {
    /// Billing interval (month or year).
    #[serde(rename = "billing_interval", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub billing_interval: Option<Option<String>>,
    /// Cancellation date (ISO 8601), if scheduled.
    #[serde(rename = "cancel_at", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub cancel_at: Option<Option<String>>,
    /// Billing period end (ISO 8601).
    #[serde(rename = "current_period_end", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub current_period_end: Option<Option<String>>,
    /// Billing period start (ISO 8601).
    #[serde(rename = "current_period_start", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub current_period_start: Option<Option<String>>,
    /// Events usage in the current period.
    #[serde(rename = "events")]
    pub events: models::EventsUsage,
    /// Whether the customer has a payment method on file.
    #[serde(rename = "has_payment_method")]
    pub has_payment_method: bool,
    /// Whether the subscription is active.
    #[serde(rename = "is_active")]
    pub is_active: bool,
    /// Current plan.
    #[serde(rename = "plan")]
    pub plan: models::Plan,
    /// Stripe subscription status (active, past_due, canceled, etc.).
    #[serde(rename = "status")]
    pub status: String,
    /// Trial information.
    #[serde(rename = "trial")]
    pub trial: models::Trial,
}

impl Subscription {
    /// Current subscription details.
    pub fn new(events: models::EventsUsage, has_payment_method: bool, is_active: bool, plan: models::Plan, status: String, trial: models::Trial) -> Subscription {
        Subscription {
            billing_interval: None,
            cancel_at: None,
            current_period_end: None,
            current_period_start: None,
            events,
            has_payment_method,
            is_active,
            plan,
            status,
            trial,
        }
    }
}