dodopayments_rust 2.2.1

Rust SDK for Dodo Payments API
Documentation
/*
 * public
 *
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: 1.97.5
 * 
 * Generated by: https://openapi-generator.tech
 */

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

/// LicenseKeyGrant : License-key delivery payload, present on grants for `license_key` entitlements. The grant's top-level `status` is the source of truth for the grant's lifecycle.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct LicenseKeyGrant {
    /// Maximum activations allowed by the entitlement, when set.
    #[serde(rename = "activations_limit", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub activations_limit: Option<Option<i32>>,
    /// Number of activations consumed so far.
    #[serde(rename = "activations_used")]
    pub activations_used: i32,
    /// When the license key expires, when applicable.
    #[serde(rename = "expires_at", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub expires_at: Option<Option<chrono::DateTime<chrono::FixedOffset>>>,
    /// Issued license key.
    #[serde(rename = "key")]
    pub key: String,
}

impl LicenseKeyGrant {
    /// License-key delivery payload, present on grants for `license_key` entitlements. The grant's top-level `status` is the source of truth for the grant's lifecycle.
    pub fn new(activations_used: i32, key: String) -> LicenseKeyGrant {
        LicenseKeyGrant {
            activations_limit: None,
            activations_used,
            expires_at: None,
            key,
        }
    }
}