delopay 0.20.0

Official Rust SDK for the DeloPay payments API
Documentation
//! Checkout-template models: a shop's payment methods, behaviour and smart
//! routing, defined once for the merchant and used in many shops.

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

/// One checkout template and the shops on it.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct CheckoutTemplateResponse {
    /// The template's own profile. The checkout-methods, checkout-branding and
    /// routing calls edit the template under this id, as they edit a shop.
    pub template_id: String,
    /// Shown to the merchant's team only.
    pub name: String,
    /// Counts the writes made to the template's settings.
    pub content_version: i64,
    /// ISO 8601 creation time.
    pub created_at: String,
    /// ISO 8601 last-modification time.
    pub modified_at: String,
    /// The shops on the template.
    #[serde(default)]
    pub shops: Vec<CheckoutTemplateShop>,
    /// Any additional response fields not modeled above.
    #[serde(flatten)]
    pub extra: serde_json::Map<String, Value>,
}

/// One shop on a template, and whether it runs the template's current
/// settings.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct CheckoutTemplateShop {
    /// The shop (business profile).
    pub profile_id: String,
    /// `up_to_date`, `changes_not_applied`, `apply_failed` or
    /// `never_applied`.
    pub status: String,
    /// The template's `content_version` the shop last applied in full.
    #[serde(default)]
    pub applied_version: Option<i64>,
    /// ISO 8601 time of that apply.
    #[serde(default)]
    pub applied_at: Option<String>,
    /// Why the last apply stopped; present while `status` is `apply_failed`.
    #[serde(default)]
    pub last_error: Option<String>,
    /// ISO 8601 time of the last apply attempt.
    #[serde(default)]
    pub last_attempt_at: Option<String>,
    /// Any additional response fields not modeled above.
    #[serde(flatten)]
    pub extra: serde_json::Map<String, Value>,
}

/// The merchant's checkout templates.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct CheckoutTemplateListResponse {
    /// The templates.
    #[serde(default)]
    pub templates: Vec<CheckoutTemplateResponse>,
    /// Any additional response fields not modeled above.
    #[serde(flatten)]
    pub extra: serde_json::Map<String, Value>,
}

/// What an assign or apply did, or would do on a dry run, in each shop.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct CheckoutTemplateApplyResponse {
    /// The template.
    pub template_id: String,
    /// The template's `content_version` that was applied.
    pub content_version: i64,
    /// Whether nothing was changed.
    pub dry_run: bool,
    /// Each shop, reported on its own.
    #[serde(default)]
    pub shops: Vec<CheckoutTemplateShopPlan>,
    /// Any additional response fields not modeled above.
    #[serde(flatten)]
    pub extra: serde_json::Map<String, Value>,
}

/// What an assign or apply did, or would do, in one shop.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct CheckoutTemplateShopPlan {
    /// The shop (business profile).
    pub profile_id: String,
    /// `ready`, `applied`, `unchanged`, `blocked` or `failed`.
    pub outcome: String,
    /// The template the shop leaves, on an assign.
    #[serde(default)]
    pub leaves_template_id: Option<String>,
    /// Why the shop was left unchanged.
    #[serde(default)]
    pub blockers: Vec<CheckoutTemplateBlocker>,
    /// What changes in the shop: connector accounts added, accounts hidden or
    /// shown, routing, payment methods, entries and behaviour settings.
    #[serde(default)]
    pub changes: Value,
    /// Why the apply failed, when it did.
    #[serde(default)]
    pub error: Option<CheckoutTemplateApplyError>,
    /// Any additional response fields not modeled above.
    #[serde(flatten)]
    pub extra: serde_json::Map<String, Value>,
}

/// Why a shop was left unchanged by an assign or apply.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct CheckoutTemplateBlocker {
    /// e.g. `shop_not_found`, `connector_switched_off_in_shop`.
    pub reason: String,
    /// The connector account concerned.
    #[serde(default)]
    pub merchant_connector_id: Option<String>,
    /// The connector concerned.
    #[serde(default)]
    pub connector: Option<String>,
    /// In words.
    #[serde(default)]
    pub message: Option<String>,
    /// Any additional response fields not modeled above.
    #[serde(flatten)]
    pub extra: serde_json::Map<String, Value>,
}

/// Why an apply failed in one shop.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct CheckoutTemplateApplyError {
    /// Error code.
    pub code: String,
    /// In words.
    pub message: String,
    /// Any additional response fields not modeled above.
    #[serde(flatten)]
    pub extra: serde_json::Map<String, Value>,
}

/// The template a shop is on, if any.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct CheckoutTemplateOfShopResponse {
    /// The shop (business profile).
    pub profile_id: String,
    /// `None`: the shop is on no template and edits its own settings.
    #[serde(default)]
    pub template: Option<CheckoutTemplateRef>,
    /// Whether this profile is itself a template.
    pub is_template: bool,
    /// Any additional response fields not modeled above.
    #[serde(flatten)]
    pub extra: serde_json::Map<String, Value>,
}

/// A template by id and name.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct CheckoutTemplateRef {
    /// The template.
    pub template_id: String,
    /// Its name.
    pub name: String,
    /// Any additional response fields not modeled above.
    #[serde(flatten)]
    pub extra: serde_json::Map<String, Value>,
}