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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
//! A buyer's cases and the evidence they hand in for one.
//!
//! A case is a refund request the buyer sent or a dispute about one of their
//! purchases. The same shapes answer the shop's customer portal and the buyer
//! account. Enumerated values arrive as strings, so a value added later does
//! not break decoding; each field lists the values known today.
use serde::Deserialize;
use serde_json::Value;
/// The buyer's cases, newest first.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct BuyerCaseList {
/// The cases.
#[serde(default)]
pub data: Vec<BuyerCase>,
/// Whether more cases exist than were returned.
#[serde(default)]
pub has_more: bool,
/// Whether cases of records the buyer has not confirmed were left out.
#[serde(default)]
pub unconfirmed_records: bool,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// One refund request or dispute, where it stands and who acts next.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct BuyerCase {
/// Case id, as the evidence routes name it.
pub id: String,
/// `refund_request` or `dispute`.
pub kind: String,
/// `refund_request`, `inquiry`, `dispute`, `bank_chargeback`,
/// `pre_chargeback_alert` or `unknown`.
pub category: String,
/// `buyer_portal`, `payment_provider`, `bank_card_issuer` or `unknown`.
pub origin: String,
/// Where the case stands, such as `waiting_for_merchant`, `approved`,
/// `refunded`, `declined`, `open`, `under_review` or `resolved`.
pub state: String,
/// Who acts next: `buyer`, `merchant`, `operator`, `provider`,
/// `reviewer`, `nobody` or `unknown`.
pub next_actor: String,
/// `pending`, `buyer_favour`, `merchant_favour`, `cancelled` or `unknown`.
pub outcome: String,
/// The record the case belongs to, on the buyer account.
#[serde(default)]
pub record: Option<String>,
/// The shop the case is with.
#[serde(default)]
pub shop: Option<String>,
/// The shop's name.
pub shop_name: String,
/// The purchase the case is about.
#[serde(default)]
pub purchase: Option<String>,
/// The kind of that purchase.
#[serde(default)]
pub purchase_kind: Option<String>,
/// The amount in question, in minor units.
#[serde(default)]
pub amount: Option<i64>,
/// ISO 4217 currency of `amount`.
#[serde(default)]
pub currency: Option<String>,
/// The amount the shop approved, in minor units.
#[serde(default)]
pub approved_amount: Option<i64>,
/// The stated reason.
#[serde(default)]
pub reason: Option<String>,
/// The buyer's message.
#[serde(default)]
pub message: Option<String>,
/// The shop's reply.
#[serde(default)]
pub merchant_reply: Option<String>,
/// The refund the case led to, when one was started.
#[serde(default)]
pub refund: Option<BuyerCaseRefund>,
/// What of the payment can still be refunded.
#[serde(default)]
pub refund_balance: Option<BuyerCaseRefundBalance>,
/// When the shop must answer by.
#[serde(default)]
pub merchant_respond_by: Option<String>,
/// When the case was opened.
pub created_at: String,
/// When the case last changed.
pub updated_at: String,
/// Whether the case belongs to test mode.
#[serde(default)]
pub test_mode: Option<bool>,
/// The recorded steps, oldest first.
#[serde(default)]
pub events: Vec<BuyerCaseEvent>,
/// Whether `events` holds every step, or only the recent ones.
#[serde(default)]
pub history_complete: bool,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// The refund a case led to.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct BuyerCaseRefund {
/// `pending`, `succeeded` or `failed`.
pub status: String,
/// Refunded amount, in minor units.
pub amount: i64,
/// ISO 4217 currency of `amount`.
pub currency: String,
/// When the refund was started.
pub created_at: String,
/// When the refund last changed.
pub updated_at: String,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// What of a payment can still be refunded.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct BuyerCaseRefundBalance {
/// Captured amount, in minor units.
pub captured_amount: i64,
/// Already refunded, in minor units.
pub succeeded_refund_amount: i64,
/// Still refundable, in minor units.
pub remaining_amount: i64,
/// ISO 4217 currency of the amounts.
pub currency: String,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// One recorded step of a case.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct BuyerCaseEvent {
/// When it happened.
pub at: String,
/// What happened, such as `opened`, `approved`, `declined`, `refunded`,
/// `status_changed`, `deadline_changed` or `evidence_submitted`.
pub kind: String,
/// Who acted: `buyer`, `merchant`, `operator`, `provider`, `reviewer`,
/// `nobody` or `unknown`.
pub actor: String,
/// The case state after the step.
#[serde(default)]
pub state: Option<String>,
/// Who acts next after the step.
#[serde(default)]
pub next_actor: Option<String>,
/// `inquiry`, `dispute`, `pre_arbitration` or `arbitration`.
#[serde(default)]
pub stage: Option<String>,
/// When the next answer is due.
#[serde(default)]
pub respond_by: Option<String>,
/// Amount the step concerns, in minor units.
#[serde(default)]
pub amount: Option<i64>,
/// ISO 4217 currency of `amount`.
#[serde(default)]
pub currency: Option<String>,
/// When the step was recorded, when that differs from `at`.
#[serde(default)]
pub recorded_at: Option<String>,
/// A due date the step set.
#[serde(default)]
pub due_at: Option<String>,
/// The reviewer's finding, on an `evidence_reviewed` step.
#[serde(default)]
pub evidence_outcome: Option<String>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// A case's evidence: what may be handed in and by when, the files saved and
/// handed in, and what the reviewer said.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct BuyerEvidence {
/// Whether the buyer may hand in evidence for this case.
pub available: bool,
/// Why not: `not_offered`, `case_not_eligible` or `case_closed`.
#[serde(default)]
pub unavailable_reason: Option<String>,
/// `awaiting_buyer`, `awaiting_review`, `information_requested` or
/// `reviewed`.
#[serde(default)]
pub state: Option<String>,
/// What a submission may carry.
#[serde(default)]
pub rules: Option<BuyerEvidenceRules>,
/// The buyer's cut-off.
#[serde(default)]
pub deadline: Option<BuyerEvidenceDeadline>,
/// When the review is expected.
#[serde(default)]
pub review_target: Option<String>,
/// The payment provider's own cut-off.
#[serde(default)]
pub provider_deadline: Option<String>,
/// `buyer`, `reviewer` or `nobody`.
#[serde(default)]
pub next_actor: Option<String>,
/// Whether a submission is accepted now.
#[serde(default)]
pub can_submit: bool,
/// Whether more time may be asked for now.
#[serde(default)]
pub can_request_extension: bool,
/// Whether more time was asked for since the cut-off was last set.
#[serde(default)]
pub extension_requested: bool,
/// Who reads the evidence: `delopay` or `delopay_and_shop`.
#[serde(default)]
pub audience: Option<String>,
/// `supports_buyer`, `does_not_support_buyer` or `inconclusive`.
#[serde(default)]
pub outcome: Option<String>,
/// Files uploaded for the case, handed in or not.
#[serde(default)]
pub saved_files: Vec<BuyerEvidenceFile>,
/// Submissions, requests and reviews, oldest first.
#[serde(default)]
pub history: Vec<BuyerEvidenceEntry>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// What a submission may carry.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct BuyerEvidenceRules {
/// Accepted file types: `pdf`, `png`, `jpeg`, `webp`, `text`.
#[serde(default)]
pub file_types: Vec<String>,
/// The most files one submission may carry.
pub max_files: i32,
/// The largest file accepted, in bytes.
pub max_file_bytes: i64,
/// Whether a submission must carry an explanation.
pub explanation_required: bool,
/// The longest explanation accepted, in characters.
pub explanation_max_chars: i32,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// The buyer's cut-off for evidence.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct BuyerEvidenceDeadline {
/// When it falls.
pub due_at: String,
/// `initial` or `supplement`.
pub kind: String,
/// Whether it has passed.
pub passed: bool,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// A file uploaded for a case.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct BuyerEvidenceFile {
/// File id.
pub id: String,
/// The name it was uploaded under.
pub file_name: String,
/// `pdf`, `png`, `jpeg`, `webp` or `text`.
pub file_type: String,
/// Size in bytes.
pub size_bytes: i64,
/// When it was uploaded.
pub uploaded_at: String,
/// Whether a submission took it. A submitted file stays.
pub submitted: bool,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// One entry of a case's evidence history.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct BuyerEvidenceEntry {
/// Entry id.
pub id: String,
/// `submitted`, `information_requested`, `replied`, `reviewed`,
/// `deadline_changed`, `extension_requested`, `reviewer_assigned`,
/// `note`, `reminded` or `reminder_failed`.
pub kind: String,
/// `buyer`, `delopay`, `shop` or `system`.
pub actor: String,
/// When it happened.
pub at: String,
/// The text handed in or written.
#[serde(default)]
pub body: Option<String>,
/// The reason given.
#[serde(default)]
pub reason: Option<String>,
/// The cut-off the entry set.
#[serde(default)]
pub due_at: Option<String>,
/// The cut-off before this entry changed it.
#[serde(default)]
pub previous_due_at: Option<String>,
/// The reviewer's finding, on a `reviewed` entry.
#[serde(default)]
pub outcome: Option<String>,
/// Files handed in with the entry.
#[serde(default)]
pub files: Vec<BuyerEvidenceFile>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}