delopay 0.20.0

Official Rust SDK for the DeloPay payments API
Documentation
//! Imports of refunds and disputes from a merchant's connected processor
//! accounts.

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

/// How many records an import or one of its sources handled.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct PspImportCounts {
    /// Records read from the processor.
    pub fetched: i64,
    /// Records recorded.
    pub imported: i64,
    /// Records DeloPay already held.
    pub already_present: i64,
    /// Records left out.
    pub skipped: i64,
    /// Records that could not be recorded.
    pub failed: i64,
    /// Any additional response fields not modeled above.
    #[serde(flatten)]
    pub extra: serde_json::Map<String, Value>,
}

/// One connector account and record type of an import.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct PspImportSourceProgress {
    /// The connector account.
    pub merchant_connector_id: String,
    /// The connector.
    pub connector: String,
    /// `refund` or `dispute`.
    pub record_type: String,
    /// `pending`, `running`, `waiting`, `completed`, `failed`, `unavailable`
    /// or `cancelled`.
    pub status: String,
    /// Why the source is unavailable, failed or waiting.
    #[serde(default)]
    pub reason: Option<String>,
    /// The source's counts.
    pub counts: PspImportCounts,
    /// Progress so far, when the processor reports a total.
    #[serde(default)]
    pub progress_done: Option<i64>,
    /// The total the progress counts towards.
    #[serde(default)]
    pub progress_total: Option<i64>,
    /// When a waiting source resumes, ISO 8601.
    #[serde(default)]
    pub retry_at: Option<String>,
    /// The error code of a failed source.
    #[serde(default)]
    pub error_code: Option<String>,
    /// The error message of a failed source.
    #[serde(default)]
    pub error_message: Option<String>,
    /// ISO 8601 start timestamp.
    #[serde(default)]
    pub started_at: Option<String>,
    /// ISO 8601 finish timestamp.
    #[serde(default)]
    pub finished_at: Option<String>,
    /// ISO 8601 last-update timestamp.
    pub updated_at: String,
    /// Any additional response fields not modeled above.
    #[serde(flatten)]
    pub extra: serde_json::Map<String, Value>,
}

/// An import run.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct PspImportRunResponse {
    /// The import's id.
    pub id: String,
    /// Whether the import reads test records.
    pub test_mode: bool,
    /// The earliest record read, ISO 8601.
    pub start_time: String,
    /// The latest record read: when the import started, ISO 8601.
    pub end_time: String,
    /// The record types read: `refund`, `dispute`.
    #[serde(default)]
    pub record_types: Vec<String>,
    /// `running`, `completed`, `completed_with_errors` or `cancelled`.
    pub status: String,
    /// Whether a stop was asked for.
    pub cancel_requested: bool,
    /// ISO 8601 creation timestamp.
    pub created_at: String,
    /// ISO 8601 finish timestamp.
    #[serde(default)]
    pub finished_at: Option<String>,
    /// The counts across every source.
    pub totals: PspImportCounts,
    /// One entry per connector account and record type.
    #[serde(default)]
    pub sources: Vec<PspImportSourceProgress>,
    /// Any additional response fields not modeled above.
    #[serde(flatten)]
    pub extra: serde_json::Map<String, Value>,
}

/// The newest import in an environment.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct PspImportLatestResponse {
    /// The import, or `None` when there has been none.
    #[serde(default)]
    pub run: Option<PspImportRunResponse>,
    /// Any additional response fields not modeled above.
    #[serde(flatten)]
    pub extra: serde_json::Map<String, Value>,
}

/// What a connector account can provide for one record type.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct PspImportCapability {
    /// `refund` or `dispute`.
    pub record_type: String,
    /// `available` (listed), `per_payment` (read payment by payment) or
    /// `unavailable`.
    pub availability: String,
    /// Why it is unavailable.
    #[serde(default)]
    pub reason: Option<String>,
    /// The earliest start the processor can read from, ISO 8601.
    #[serde(default)]
    pub earliest_start: Option<String>,
    /// Any additional response fields not modeled above.
    #[serde(flatten)]
    pub extra: serde_json::Map<String, Value>,
}

/// A connector account an import can read.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct PspImportAccount {
    /// The connector account.
    pub merchant_connector_id: String,
    /// The connector.
    pub connector: String,
    /// The account's label.
    #[serde(default)]
    pub connector_label: Option<String>,
    /// The account's shop.
    pub profile_id: String,
    /// What the account can provide, per record type.
    #[serde(default)]
    pub records: Vec<PspImportCapability>,
    /// Any additional response fields not modeled above.
    #[serde(flatten)]
    pub extra: serde_json::Map<String, Value>,
}

/// Every connector account an import can read in an environment.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct PspImportSourcesResponse {
    /// The accounts.
    #[serde(default)]
    pub accounts: Vec<PspImportAccount>,
    /// Any additional response fields not modeled above.
    #[serde(flatten)]
    pub extra: serde_json::Map<String, Value>,
}

/// A record an import left out or could not record.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct PspImportIssue {
    /// The connector account.
    pub merchant_connector_id: String,
    /// `refund` or `dispute`.
    pub record_type: String,
    /// The processor's id for the record.
    #[serde(default)]
    pub connector_record_id: Option<String>,
    /// `skipped` or `failed`.
    pub outcome: String,
    /// Why, for example `payment_not_found` or `other_shop`.
    pub reason: String,
    /// A readable message.
    #[serde(default)]
    pub message: Option<String>,
    /// ISO 8601 timestamp.
    pub created_at: String,
    /// Any additional response fields not modeled above.
    #[serde(flatten)]
    pub extra: serde_json::Map<String, Value>,
}

/// One page of an import's issues.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct PspImportIssuesResponse {
    /// The issues on this page.
    #[serde(default)]
    pub issues: Vec<PspImportIssue>,
    /// Whether more issues follow.
    pub has_more: bool,
    /// Any additional response fields not modeled above.
    #[serde(flatten)]
    pub extra: serde_json::Map<String, Value>,
}