dodopayments_rust 2.2.2

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.87.0
 * 
 * Generated by: https://openapi-generator.tech
 */

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

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct CreateSubscriptionResponse {
    /// Addons associated with this subscription
    #[serde(rename = "addons")]
    pub addons: Vec<models::AddonCartResponseItem>,
    /// Client secret used to load Dodo checkout SDK NOTE : Dodo checkout SDK will be coming soon
    #[serde(rename = "client_secret", skip_serializing_if = "Option::is_none")]
    pub client_secret: Option<String>,
    /// Customer details associated with this subscription
    #[serde(rename = "customer")]
    pub customer: Box<models::CustomerLimitedDetailsResponse>,
    /// The discount id if discount is applied
    #[serde(rename = "discount_id", skip_serializing_if = "Option::is_none")]
    pub discount_id: Option<String>,
    /// Expiry timestamp of the payment link
    #[serde(rename = "expires_on", skip_serializing_if = "Option::is_none")]
    pub expires_on: Option<String>,
    /// Additional metadata associated with the subscription
    #[serde(rename = "metadata")]
    pub metadata: std::collections::HashMap<String, String>,
    /// One time products associated with the purchase of subscription
    #[serde(rename = "one_time_product_cart", skip_serializing_if = "Option::is_none")]
    pub one_time_product_cart: Option<Vec<models::OneTimeProductCartItemResponse>>,
    /// First payment id for the subscription
    #[serde(rename = "payment_id")]
    pub payment_id: String,
    /// URL to checkout page
    #[serde(rename = "payment_link", skip_serializing_if = "Option::is_none")]
    pub payment_link: Option<String>,
    /// Tax will be added to the amount and charged to the customer on each billing cycle
    #[serde(rename = "recurring_pre_tax_amount")]
    pub recurring_pre_tax_amount: i32,
    /// Unique identifier for the subscription
    #[serde(rename = "subscription_id")]
    pub subscription_id: String,
}

impl CreateSubscriptionResponse {
    pub fn new(addons: Vec<models::AddonCartResponseItem>, customer: models::CustomerLimitedDetailsResponse, metadata: std::collections::HashMap<String, String>, payment_id: String, recurring_pre_tax_amount: i32, subscription_id: String) -> CreateSubscriptionResponse {
        CreateSubscriptionResponse {
            addons,
            client_secret: None,
            customer: Box::new(customer),
            discount_id: None,
            expires_on: None,
            metadata,
            one_time_product_cart: None,
            payment_id,
            payment_link: None,
            recurring_pre_tax_amount,
            subscription_id,
        }
    }
}