late 0.0.1345

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.526.1
 * 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 AutoRecharge {
    /// Whether auto-recharge is on. Charges happen only when this is true and disabledReason is null.
    #[serde(rename = "enabled")]
    pub enabled: bool,
    /// Recharge when the balance drops below this, in cents.
    #[serde(rename = "belowCents")]
    pub below_cents: i32,
    /// Recharge back up to this, in cents. The charge is toCents minus the balance, plus tax.
    #[serde(rename = "toCents")]
    pub to_cents: i32,
    /// Most auto-recharge may add per calendar month (UTC), before tax; null for no limit.
    #[serde(rename = "monthlyLimitCents", deserialize_with = "Option::deserialize")]
    pub monthly_limit_cents: Option<i32>,
    /// Low-balance email threshold, sent once per drop below it; null for none.
    #[serde(rename = "alertBelowCents", deserialize_with = "Option::deserialize")]
    pub alert_below_cents: Option<i32>,
    /// `payment_failed` after four failed charges in a row. Updating the card clears it.
    #[serde(rename = "disabledReason", deserialize_with = "Option::deserialize")]
    pub disabled_reason: Option<DisabledReason>,
    /// Failed charges in a row; 0 once one goes through.
    #[serde(rename = "retryCount")]
    pub retry_count: i32,
    /// When a declined recharge is tried again; null when none is waiting.
    #[serde(rename = "nextRetryAt", deserialize_with = "Option::deserialize")]
    pub next_retry_at: Option<String>,
    /// Auto-recharge top-ups this calendar month (UTC), paid or being paid, before tax.
    #[serde(rename = "monthRechargedCents")]
    pub month_recharged_cents: i32,
}

impl AutoRecharge {
    pub fn new(
        enabled: bool,
        below_cents: i32,
        to_cents: i32,
        monthly_limit_cents: Option<i32>,
        alert_below_cents: Option<i32>,
        disabled_reason: Option<DisabledReason>,
        retry_count: i32,
        next_retry_at: Option<String>,
        month_recharged_cents: i32,
    ) -> AutoRecharge {
        AutoRecharge {
            enabled,
            below_cents,
            to_cents,
            monthly_limit_cents,
            alert_below_cents,
            disabled_reason,
            retry_count,
            next_retry_at,
            month_recharged_cents,
        }
    }
}
/// `payment_failed` after four failed charges in a row. Updating the card clears it.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum DisabledReason {
    #[serde(rename = "payment_failed")]
    PaymentFailed,
}

impl Default for DisabledReason {
    fn default() -> DisabledReason {
        Self::PaymentFailed
    }
}