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 UpdateSubscriptionPlanReq {
    /// Addons for the new plan. Note : Leaving this empty would remove any existing addons
    #[serde(rename = "addons", skip_serializing_if = "Option::is_none")]
    pub addons: Option<Vec<models::AttachAddonReq>>,
    /// Optional discount code to apply to the new plan. If provided, validates and applies the discount to the plan change. If not provided and the subscription has an existing discount with `preserve_on_plan_change=true`, the existing discount will be preserved (if applicable to the new product).
    #[serde(rename = "discount_code", skip_serializing_if = "Option::is_none")]
    pub discount_code: Option<String>,
    /// Metadata for the payment. If not passed, the metadata of the subscription will be taken
    #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")]
    pub metadata: Option<std::collections::HashMap<String, String>>,
    /// Controls behavior when the plan change payment fails. - `prevent_change`: Keep subscription on current plan until payment succeeds - `apply_change` (default): Apply plan change immediately regardless of payment outcome  If not specified, uses the business-level default setting.
    #[serde(rename = "on_payment_failure", skip_serializing_if = "Option::is_none")]
    pub on_payment_failure: Option<models::OnPaymentFailure>,
    /// Unique identifier of the product to subscribe to
    #[serde(rename = "product_id")]
    pub product_id: String,
    /// Proration Billing Mode
    #[serde(rename = "proration_billing_mode")]
    pub proration_billing_mode: models::ProrationBillingMode,
    /// Number of units to subscribe for. Must be at least 1.
    #[serde(rename = "quantity")]
    pub quantity: i32,
}

impl UpdateSubscriptionPlanReq {
    pub fn new(product_id: String, proration_billing_mode: models::ProrationBillingMode, quantity: i32) -> UpdateSubscriptionPlanReq {
        UpdateSubscriptionPlanReq {
            addons: None,
            discount_code: None,
            metadata: None,
            on_payment_failure: None,
            product_id,
            proration_billing_mode,
            quantity,
        }
    }
}