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};

/// EntitlementGrantResponse : Detailed view of a single entitlement grant: who it's for, its lifecycle state, and any integration-specific delivery payload.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct EntitlementGrantResponse {
    /// Identifier of the business that owns the grant.
    #[serde(rename = "business_id")]
    pub business_id: String,
    /// Timestamp when the grant was created.
    #[serde(rename = "created_at")]
    pub created_at: chrono::DateTime<chrono::FixedOffset>,
    /// Identifier of the customer the grant was issued to.
    #[serde(rename = "customer_id")]
    pub customer_id: String,
    /// Timestamp when the grant transitioned to `delivered`, when applicable.
    #[serde(rename = "delivered_at", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub delivered_at: Option<Option<chrono::DateTime<chrono::FixedOffset>>>,
    /// Digital-product-delivery payload, present when the entitlement integration is `digital_files`.
    #[serde(rename = "digital_product_delivery", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub digital_product_delivery: Option<Option<Box<models::DigitalProductDelivery>>>,
    /// Identifier of the entitlement this grant was issued from.
    #[serde(rename = "entitlement_id")]
    pub entitlement_id: String,
    /// Machine-readable code reported when delivery failed, when applicable.
    #[serde(rename = "error_code", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub error_code: Option<Option<String>>,
    /// Human-readable message reported when delivery failed, when applicable.
    #[serde(rename = "error_message", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub error_message: Option<Option<String>>,
    /// Unique identifier of the grant.
    #[serde(rename = "id")]
    pub id: String,
    /// License-key delivery payload, present when the entitlement integration is `license_key`.
    #[serde(rename = "license_key", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub license_key: Option<Option<Box<models::LicenseKeyGrant>>>,
    /// Arbitrary key-value metadata recorded on the grant.
    #[serde(rename = "metadata")]
    pub metadata: std::collections::HashMap<String, String>,
    /// Timestamp when `oauth_url` stops being valid, when applicable.
    #[serde(rename = "oauth_expires_at", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub oauth_expires_at: Option<Option<chrono::DateTime<chrono::FixedOffset>>>,
    /// Customer-facing OAuth URL for OAuth-style integrations. Populated during the customer-portal accept flow; `null` until the customer completes that step, and on grants for non-OAuth integrations.
    #[serde(rename = "oauth_url", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub oauth_url: Option<Option<String>>,
    /// Identifier of the payment that triggered this grant, when applicable.
    #[serde(rename = "payment_id", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub payment_id: Option<Option<String>>,
    /// Reason recorded when the grant was revoked, when applicable.
    #[serde(rename = "revocation_reason", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub revocation_reason: Option<Option<String>>,
    /// Timestamp when the grant transitioned to `revoked`, when applicable.
    #[serde(rename = "revoked_at", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub revoked_at: Option<Option<chrono::DateTime<chrono::FixedOffset>>>,
    /// Lifecycle status of the grant.
    #[serde(rename = "status")]
    pub status: models::EntitlementGrantStatus,
    /// Identifier of the subscription that triggered this grant, when applicable.
    #[serde(rename = "subscription_id", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub subscription_id: Option<Option<String>>,
    /// Timestamp when the grant was last modified.
    #[serde(rename = "updated_at")]
    pub updated_at: chrono::DateTime<chrono::FixedOffset>,
}

impl EntitlementGrantResponse {
    /// Detailed view of a single entitlement grant: who it's for, its lifecycle state, and any integration-specific delivery payload.
    pub fn new(business_id: String, created_at: chrono::DateTime<chrono::FixedOffset>, customer_id: String, entitlement_id: String, id: String, metadata: std::collections::HashMap<String, String>, status: models::EntitlementGrantStatus, updated_at: chrono::DateTime<chrono::FixedOffset>) -> EntitlementGrantResponse {
        EntitlementGrantResponse {
            business_id,
            created_at,
            customer_id,
            delivered_at: None,
            digital_product_delivery: None,
            entitlement_id,
            error_code: None,
            error_message: None,
            id,
            license_key: None,
            metadata,
            oauth_expires_at: None,
            oauth_url: None,
            payment_id: None,
            revocation_reason: None,
            revoked_at: None,
            status,
            subscription_id: None,
            updated_at,
        }
    }
}