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 CalculatedProductCartItem {
    #[serde(rename = "addons", skip_serializing_if = "Option::is_none")]
    pub addons: Option<Vec<models::CalculatedAddonItem>>,
    /// Credit entitlements that will be granted upon purchase
    #[serde(rename = "credit_entitlements")]
    pub credit_entitlements: Vec<models::CheckoutCreditEntitlementItem>,
    /// the currency in which the calculatiosn were made
    #[serde(rename = "currency")]
    pub currency: models::Currency,
    #[serde(rename = "description", skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,
    /// discount percentage
    #[serde(rename = "discount_amount", skip_serializing_if = "Option::is_none")]
    pub discount_amount: Option<i32>,
    /// number of cycles the discount will apply
    #[serde(rename = "discount_cycle", skip_serializing_if = "Option::is_none")]
    pub discount_cycle: Option<i32>,
    /// discounted price
    #[serde(rename = "discounted_price")]
    pub discounted_price: i32,
    /// Whether this is a subscription product (affects tax calculation in breakup)
    #[serde(rename = "is_subscription")]
    pub is_subscription: bool,
    #[serde(rename = "is_usage_based")]
    pub is_usage_based: bool,
    #[serde(rename = "meters")]
    pub meters: Vec<models::MeterDetails>,
    /// name of the product
    #[serde(rename = "name", skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    /// the product currency
    #[serde(rename = "og_currency")]
    pub og_currency: models::Currency,
    /// original price of the product
    #[serde(rename = "og_price")]
    pub og_price: i32,
    /// unique id of the product
    #[serde(rename = "product_id")]
    pub product_id: String,
    /// Quanitity
    #[serde(rename = "quantity")]
    pub quantity: i32,
    /// total tax
    #[serde(rename = "tax", skip_serializing_if = "Option::is_none")]
    pub tax: Option<i32>,
    /// tax category
    #[serde(rename = "tax_category")]
    pub tax_category: models::TaxCategory,
    /// Whether tax is included in the price
    #[serde(rename = "tax_inclusive")]
    pub tax_inclusive: bool,
    /// tax rate
    #[serde(rename = "tax_rate")]
    pub tax_rate: i32,
}

impl CalculatedProductCartItem {
    pub fn new(credit_entitlements: Vec<models::CheckoutCreditEntitlementItem>, currency: models::Currency, discounted_price: i32, is_subscription: bool, is_usage_based: bool, meters: Vec<models::MeterDetails>, og_currency: models::Currency, og_price: i32, product_id: String, quantity: i32, tax_category: models::TaxCategory, tax_inclusive: bool, tax_rate: i32) -> CalculatedProductCartItem {
        CalculatedProductCartItem {
            addons: None,
            credit_entitlements,
            currency,
            description: None,
            discount_amount: None,
            discount_cycle: None,
            discounted_price,
            is_subscription,
            is_usage_based,
            meters,
            name: None,
            og_currency,
            og_price,
            product_id,
            quantity,
            tax: None,
            tax_category,
            tax_inclusive,
            tax_rate,
        }
    }
}