delopay 0.20.0

Official Rust SDK for the DeloPay payments API
Documentation
//! Out-of-band transitions: what a payment provider did that DeloPay never
//! observed, recorded by an operator.

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

/// A recorded out-of-band transition.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ExternalRecordResponse {
    /// The record's id.
    pub record_id: String,
    /// `payment`, `refund`, `dispute` or `payout`.
    pub resource_kind: String,
    /// The object the transition was written to.
    pub resource_id: String,
    /// The payment the object belongs to.
    #[serde(default)]
    pub payment_id: Option<String>,
    /// Whether the record created the object.
    pub created_resource: bool,
    /// The object's status before.
    #[serde(default)]
    pub previous_status: Option<String>,
    /// The status recorded.
    pub recorded_status: String,
    /// What became of the outgoing webhook.
    #[serde(default)]
    pub webhook_outcome: Option<String>,
    /// Who recorded it.
    pub recorded_by: String,
    /// When, ISO 8601.
    pub recorded_at: String,
    /// Any additional response fields not modeled above.
    #[serde(flatten)]
    pub extra: serde_json::Map<String, Value>,
}

/// Whether an object with no record yet can be created by a record.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ExternalRecordCreateSupport {
    /// `served`; `not_implemented` (a gap in this release) or
    /// `not_applicable` (refused by a rule).
    pub status: String,
    /// Why it is not served: the message a create call answers with.
    #[serde(default)]
    pub reason: Option<String>,
    /// Any additional response fields not modeled above.
    #[serde(flatten)]
    pub extra: serde_json::Map<String, Value>,
}

/// What this deployment accepts for one kind of object.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ExternalRecordKindCapability {
    /// `payment`, `refund`, `dispute` or `payout`.
    pub resource: String,
    /// Whether a transition of an object DeloPay already holds is served.
    pub transition: bool,
    /// Whether an object DeloPay does not hold yet can be created.
    pub create: ExternalRecordCreateSupport,
    /// Every status spelling the kind accepts.
    #[serde(default)]
    pub statuses: Vec<String>,
    /// Any additional response fields not modeled above.
    #[serde(flatten)]
    pub extra: serde_json::Map<String, Value>,
}

/// What this deployment accepts, per kind of object.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ExternalRecordCapabilities {
    /// Every kind, served or not.
    #[serde(default)]
    pub kinds: Vec<ExternalRecordKindCapability>,
    /// Any additional response fields not modeled above.
    #[serde(flatten)]
    pub extra: serde_json::Map<String, Value>,
}