delopay 0.20.0

Official Rust SDK for the DeloPay payments API
Documentation
//! The evidence buyers hand in for a shop's cases, as the shop's team reads
//! and reviews it.

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

use crate::core::models::buyer_case::BuyerEvidenceFile;

/// A case with buyer evidence, as the review queue lists it.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct BuyerEvidenceSummary {
    /// The evidence's id.
    pub id: String,
    /// The merchant.
    pub merchant_id: String,
    /// The shop.
    pub profile_id: String,
    /// The buyer.
    pub customer_id: String,
    /// `refund_request` or `dispute`.
    pub case_kind: String,
    /// For example `refund_request`, `inquiry`, `dispute` or
    /// `bank_chargeback`.
    pub case_category: String,
    /// When the case was opened, ISO 8601.
    pub case_opened_at: String,
    /// Whether the case is a test case.
    pub test_mode: bool,
    /// `awaiting_buyer`, `awaiting_review`, `information_requested` or
    /// `reviewed`.
    pub state: String,
    /// Who acts next: `buyer`, `reviewer` or `nobody`.
    pub next_actor: String,
    /// When the buyer's evidence is due, ISO 8601.
    #[serde(default)]
    pub buyer_due_at: Option<String>,
    /// `initial` or `supplement`.
    #[serde(default)]
    pub buyer_due_kind: Option<String>,
    /// When the review is due, ISO 8601.
    #[serde(default)]
    pub review_due_at: Option<String>,
    /// Whether the next step is overdue.
    pub overdue: bool,
    /// The reviewer.
    #[serde(default)]
    pub reviewer_id: Option<String>,
    /// The review's result: `supports_buyer`, `does_not_support_buyer` or
    /// `inconclusive`.
    #[serde(default)]
    pub outcome: Option<String>,
    /// When the buyer asked for more time, ISO 8601.
    #[serde(default)]
    pub extension_requested_at: Option<String>,
    /// Where the evidence policy came from.
    pub policy_source: String,
    /// ISO 8601 creation timestamp.
    pub created_at: String,
    /// ISO 8601 last-modification timestamp.
    pub modified_at: String,
    /// Any additional response fields not modeled above.
    #[serde(flatten)]
    pub extra: serde_json::Map<String, Value>,
}

/// The shop's cases with buyer evidence, the nearest target first.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct BuyerEvidenceQueue {
    /// The cases on this page.
    #[serde(default)]
    pub data: Vec<BuyerEvidenceSummary>,
    /// Every case matching the filters.
    pub total: i64,
    /// Any additional response fields not modeled above.
    #[serde(flatten)]
    pub extra: serde_json::Map<String, Value>,
}

/// The evidence policy that applied when the evidence was first opened.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct BuyerEvidencePolicy {
    /// The case categories the policy covers.
    #[serde(default)]
    pub case_categories: Vec<String>,
    /// The most files a buyer may hand in.
    pub max_files: i64,
    /// The largest file, in megabytes.
    pub max_file_megabytes: i64,
    /// The file types accepted: `pdf`, `png`, `jpeg`, `webp`, `text`.
    #[serde(default)]
    pub file_types: Vec<String>,
    /// Whether the buyer must explain in writing.
    pub explanation_required: bool,
    /// Hours the buyer has for the first evidence.
    pub initial_hours: i64,
    /// Hours the buyer has to answer a request for more.
    pub supplement_hours: i64,
    /// Hours the review should take.
    pub review_target_hours: i64,
    /// Hours before a cut-off the buyer is reminded.
    #[serde(default)]
    pub reminder_hours: Option<i64>,
    /// What the shop may do: `none`, `view` or `review`.
    pub merchant_access: String,
    /// Any additional response fields not modeled above.
    #[serde(flatten)]
    pub extra: serde_json::Map<String, Value>,
}

/// A file of the evidence, as the review reads it.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct BuyerEvidenceReviewFile {
    /// The file's id.
    pub id: String,
    /// The file's name.
    pub file_name: String,
    /// `pdf`, `png`, `jpeg`, `webp` or `text`.
    pub file_type: String,
    /// The file's size in bytes.
    pub size_bytes: i64,
    /// When it was uploaded, ISO 8601.
    pub uploaded_at: String,
    /// Whether the buyer submitted it.
    pub submitted: bool,
    /// The file's SHA-256 digest, hex-encoded.
    pub sha256: String,
    /// When the file was removed, ISO 8601.
    #[serde(default)]
    pub removed_at: Option<String>,
    /// Any additional response fields not modeled above.
    #[serde(flatten)]
    pub extra: serde_json::Map<String, Value>,
}

/// One step of the evidence's history.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct BuyerEvidenceReviewEntry {
    /// The step's id.
    pub id: String,
    /// What happened.
    pub kind: String,
    /// Who took the step.
    pub actor: String,
    /// When, ISO 8601.
    pub at: String,
    /// The step's text.
    #[serde(default)]
    pub body: Option<String>,
    /// Why, for a step that carries a reason.
    #[serde(default)]
    pub reason: Option<String>,
    /// The cut-off the step set, ISO 8601.
    #[serde(default)]
    pub due_at: Option<String>,
    /// The cut-off the step replaced, ISO 8601.
    #[serde(default)]
    pub previous_due_at: Option<String>,
    /// The result a review step recorded.
    #[serde(default)]
    pub outcome: Option<String>,
    /// Files attached to the step.
    #[serde(default)]
    pub files: Vec<BuyerEvidenceFile>,
    /// The user who took the step, for a reviewer or the shop's team.
    #[serde(default)]
    pub actor_id: Option<String>,
    /// Whether the buyer sees the step.
    pub public: bool,
    /// Any additional response fields not modeled above.
    #[serde(flatten)]
    pub extra: serde_json::Map<String, Value>,
}

/// One case with its evidence, history and files.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct BuyerEvidenceReviewDetail {
    /// The evidence's id.
    pub id: String,
    /// The merchant.
    pub merchant_id: String,
    /// The shop.
    pub profile_id: String,
    /// The buyer.
    pub customer_id: String,
    /// `refund_request` or `dispute`.
    pub case_kind: String,
    /// For example `refund_request`, `inquiry`, `dispute` or
    /// `bank_chargeback`.
    pub case_category: String,
    /// When the case was opened, ISO 8601.
    pub case_opened_at: String,
    /// Whether the case is a test case.
    pub test_mode: bool,
    /// `awaiting_buyer`, `awaiting_review`, `information_requested` or
    /// `reviewed`.
    pub state: String,
    /// Who acts next: `buyer`, `reviewer` or `nobody`.
    pub next_actor: String,
    /// When the buyer's evidence is due, ISO 8601.
    #[serde(default)]
    pub buyer_due_at: Option<String>,
    /// `initial` or `supplement`.
    #[serde(default)]
    pub buyer_due_kind: Option<String>,
    /// When the review is due, ISO 8601.
    #[serde(default)]
    pub review_due_at: Option<String>,
    /// Whether the next step is overdue.
    pub overdue: bool,
    /// The reviewer.
    #[serde(default)]
    pub reviewer_id: Option<String>,
    /// The review's result.
    #[serde(default)]
    pub outcome: Option<String>,
    /// When the buyer asked for more time, ISO 8601.
    #[serde(default)]
    pub extension_requested_at: Option<String>,
    /// Where the evidence policy came from.
    pub policy_source: String,
    /// ISO 8601 creation timestamp.
    pub created_at: String,
    /// ISO 8601 last-modification timestamp.
    pub modified_at: String,
    /// The case as the buyer's case list shows it, kept as raw JSON. `None`
    /// when it can no longer be read.
    #[serde(default)]
    pub case: Option<Value>,
    /// The policy that applied when the evidence was first opened.
    pub policy: BuyerEvidencePolicy,
    /// Every step, oldest first.
    #[serde(default)]
    pub history: Vec<BuyerEvidenceReviewEntry>,
    /// Every file of the evidence.
    #[serde(default)]
    pub files: Vec<BuyerEvidenceReviewFile>,
    /// Any additional response fields not modeled above.
    #[serde(flatten)]
    pub extra: serde_json::Map<String, Value>,
}