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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
//! 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>,
}