delopay 0.20.0

Official Rust SDK for the DeloPay payments API
Documentation
//! Merchant cost rule models: what a merchant's own goods and partners'
//! shares cost it.

use serde::Deserialize;
use serde_json::Value;

/// What a cost rule records: `"goods"`, `"partner_share"` or `"other"`.
///
/// A string rather than an enum, so a category added later still decodes.
pub type MerchantCostRuleCategory = String;

/// A recorded merchant cost rule.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct MerchantCostRuleResponse {
    /// Rule ID.
    pub id: String,
    /// The merchant the rule belongs to.
    pub merchant_id: String,
    /// The one shop it covers. `None` covers every shop.
    #[serde(default)]
    pub shop_id: Option<String>,
    /// What the rule records — see [`MerchantCostRuleCategory`].
    pub category: MerchantCostRuleCategory,
    /// Percentage of the transaction, e.g. `42.5` for 42.5 %.
    #[serde(default)]
    pub percentage: Option<f64>,
    /// Flat component in minor units of [`flat_currency`](Self::flat_currency).
    #[serde(default)]
    pub flat_amount: Option<i64>,
    /// ISO 4217 currency of the fixed components. `None` states them in the
    /// transaction currency.
    #[serde(default)]
    pub flat_currency: Option<String>,
    /// Per-transaction floor.
    #[serde(default)]
    pub min_amount: Option<i64>,
    /// Per-transaction ceiling.
    #[serde(default)]
    pub max_amount: Option<i64>,
    /// When the rate starts applying (ISO 8601).
    pub effective_from: String,
    /// When it stops applying (ISO 8601, exclusive). `None` while open-ended.
    #[serde(default)]
    pub effective_to: Option<String>,
    /// Whether the rule is active.
    pub is_active: bool,
    /// What the merchant calls the rule.
    #[serde(default)]
    pub label: Option<String>,
    /// Any additional response fields not modeled above.
    #[serde(flatten)]
    pub extra: serde_json::Map<String, Value>,
}

/// The answer to a cost rule delete.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct MerchantCostRuleDeleteResponse {
    /// Whether the rule was deleted.
    pub deleted: bool,
    /// The deleted rule's ID.
    pub id: String,
    /// Any additional response fields not modeled above.
    #[serde(flatten)]
    pub extra: serde_json::Map<String, Value>,
}