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

/// UsageBasedPrice : Usage Based price details.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct UsageBasedPrice {
    /// The currency in which the payment is made.
    #[serde(rename = "currency")]
    pub currency: models::Currency,
    /// Discount applied to the price, represented as a percentage (0 to 100).
    #[serde(rename = "discount")]
    pub discount: i64,
    /// The fixed payment amount. Represented in the lowest denomination of the currency (e.g., cents for USD). For example, to charge $1.00, pass `100`.
    #[serde(rename = "fixed_price")]
    pub fixed_price: i32,
    #[serde(rename = "meters", skip_serializing_if = "Option::is_none")]
    pub meters: Option<Vec<models::AddMeterToPrice>>,
    /// Number of units for the payment frequency. For example, a value of `1` with a `payment_frequency_interval` of `month` represents monthly payments.
    #[serde(rename = "payment_frequency_count")]
    pub payment_frequency_count: i32,
    /// The time interval for the payment frequency (e.g., day, month, year).
    #[serde(rename = "payment_frequency_interval")]
    pub payment_frequency_interval: models::TimeInterval,
    /// Indicates if purchasing power parity adjustments are applied to the price. Purchasing power parity feature is not available as of now
    #[serde(rename = "purchasing_power_parity")]
    pub purchasing_power_parity: bool,
    /// Number of units for the subscription period. For example, a value of `12` with a `subscription_period_interval` of `month` represents a one-year subscription.
    #[serde(rename = "subscription_period_count")]
    pub subscription_period_count: i32,
    /// The time interval for the subscription period (e.g., day, month, year).
    #[serde(rename = "subscription_period_interval")]
    pub subscription_period_interval: models::TimeInterval,
    /// Indicates if the price is tax inclusive
    #[serde(rename = "tax_inclusive", skip_serializing_if = "Option::is_none")]
    pub tax_inclusive: Option<bool>,
    #[serde(rename = "type")]
    pub r#type: Type,
}

impl UsageBasedPrice {
    /// Usage Based price details.
    pub fn new(currency: models::Currency, discount: i64, fixed_price: i32, payment_frequency_count: i32, payment_frequency_interval: models::TimeInterval, purchasing_power_parity: bool, subscription_period_count: i32, subscription_period_interval: models::TimeInterval, r#type: Type) -> UsageBasedPrice {
        UsageBasedPrice {
            currency,
            discount,
            fixed_price,
            meters: None,
            payment_frequency_count,
            payment_frequency_interval,
            purchasing_power_parity,
            subscription_period_count,
            subscription_period_interval,
            tax_inclusive: None,
            r#type,
        }
    }
}
/// 
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "usage_based_price")]
    UsageBasedPrice,
}

impl Default for Type {
    fn default() -> Type {
        Self::UsageBasedPrice
    }
}