1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
//! Project models: the project itself and the merchant-level aggregates
//! returned by the project stats and overview endpoints.
use serde::Deserialize;
use serde_json::Value;
use crate::core::models::shop::{CurrencyRevenue, ShopStats};
/// A project — an optional grouping layer that contains one or more shops.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ProjectResponse {
/// Unique project ID (the API field is `id`, not `project_id`).
pub id: String,
/// Merchant account that owns this project.
pub merchant_id: String,
/// Display name of the project.
pub project_name: String,
/// Whether the project is active.
pub is_active: bool,
/// ISO 8601 creation timestamp.
pub created_at: String,
/// ISO 8601 last-modification timestamp.
pub modified_at: String,
/// Free-form description.
#[serde(default)]
pub description: Option<String>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// Order and revenue figures for one project, plus its shops.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ProjectStats {
/// The project these figures belong to.
pub project_id: String,
/// Display name of the project.
pub project_name: String,
/// Number of successful orders in the window.
pub orders: i64,
/// Raw cross-currency minor-unit sum — do not display. Use
/// [`revenue_usd`](Self::revenue_usd) or
/// [`revenue_by_currency`](Self::revenue_by_currency).
pub revenue: i64,
/// FX-converted revenue in USD major units.
pub revenue_usd: f64,
/// Revenue split by the currency it was taken in.
#[serde(default)]
pub revenue_by_currency: Vec<CurrencyRevenue>,
/// Orders left out of `revenue_usd` for want of a fresh USD rate.
pub unconverted_orders: i64,
/// Per-shop breakdown for the shops grouped under this project.
#[serde(default)]
pub shops: Vec<ShopStats>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// Aggregate payment statistics across all of a merchant's projects, as
/// returned by the `projects.stats` endpoint.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ProjectStatsResponse {
/// Per-project breakdown.
#[serde(default)]
pub projects: Vec<ProjectStats>,
/// Every shop of the merchant, including shops that belong to no project —
/// those never appear under `projects[].shops`, since projects are an
/// optional grouping layer. Look a single shop up here rather than walking
/// the project tree.
#[serde(default)]
pub shops: Vec<ShopStats>,
/// Total number of successful orders in the window.
pub total_orders: i64,
/// Raw cross-currency minor-unit sum — do not display. Use
/// [`total_revenue_usd`](Self::total_revenue_usd).
pub total_revenue: i64,
/// FX-converted total revenue in USD major units.
pub total_revenue_usd: f64,
/// Total revenue split by the currency it was taken in.
#[serde(default)]
pub total_revenue_by_currency: Vec<CurrencyRevenue>,
/// Orders left out of `total_revenue_usd` for want of a fresh USD rate.
pub unconverted_orders: i64,
/// Window the figures cover, in days. `None` when an all-time total was
/// asked for.
#[serde(default)]
pub period_days: Option<i64>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// One headline figure on the merchant overview, with its period-over-period
/// change.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct MerchantOverviewStat {
/// Human-readable label for the figure.
pub label: String,
/// The figure itself.
pub value: f64,
/// Change against the previous window, in percent.
pub change_percent: f64,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// High-level merchant overview, as returned by the `projects.overview`
/// endpoint.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct MerchantOverviewResponse {
/// Total number of shops.
pub total_shops: MerchantOverviewStat,
/// Number of active shops.
pub active_shops: MerchantOverviewStat,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}