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
//! Refund requests buyers raise from the customer portal, and the results of
//! blocking the buyers of refunds in bulk.
use std::fmt;
use serde::Deserialize;
use serde_json::Value;
use crate::core::models::dispute_workspace::DisputeBulkBlockedIdentifier;
/// A buyer's refund request.
///
/// The buyer's message is personal data: `Debug` prints `<redacted>` in its
/// place.
#[derive(Clone, Deserialize)]
#[non_exhaustive]
pub struct BuyerRefundRequest {
/// The request's id.
pub id: String,
/// The payment the buyer wants refunded.
pub payment_id: String,
/// The payment's shop.
pub profile_id: String,
/// The buyer.
pub customer_id: String,
/// `payment` for a one-off purchase, `renewal` for a subscription renewal.
pub purchase_kind: String,
/// `not_received`, `not_as_described`, `duplicate`, `cancelled_order` or
/// `other`.
pub reason: String,
/// What the buyer wrote.
pub message: String,
/// The amount the buyer asked for, in minor units.
pub amount: i64,
/// Three-letter ISO 4217 currency code.
pub currency: String,
/// `requested`, `approved` or `declined`.
pub status: String,
/// The refund that approved the request.
#[serde(default)]
pub refund_id: Option<String>,
/// The approved refund's amount, in minor units.
#[serde(default)]
pub approved_amount: Option<i64>,
/// What the shop told the buyer.
#[serde(default)]
pub merchant_reply: Option<String>,
/// The dashboard user or API key that decided.
#[serde(default)]
pub decided_by: Option<String>,
/// Whether the request is a test request.
pub test_mode: bool,
/// ISO 8601 creation timestamp.
pub created_at: String,
/// ISO 8601 decision timestamp.
#[serde(default)]
pub decided_at: Option<String>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
impl fmt::Debug for BuyerRefundRequest {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("BuyerRefundRequest")
.field("id", &self.id)
.field("payment_id", &self.payment_id)
.field("profile_id", &self.profile_id)
.field("customer_id", &self.customer_id)
.field("purchase_kind", &self.purchase_kind)
.field("reason", &self.reason)
.field("message", &"<redacted>")
.field("amount", &self.amount)
.field("currency", &self.currency)
.field("status", &self.status)
.field("refund_id", &self.refund_id)
.field("approved_amount", &self.approved_amount)
.field("merchant_reply", &self.merchant_reply)
.field("decided_by", &self.decided_by)
.field("test_mode", &self.test_mode)
.field("created_at", &self.created_at)
.field("decided_at", &self.decided_at)
.finish_non_exhaustive()
}
}
/// One page of refund requests, newest first.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct BuyerRefundRequestList {
/// The requests on this page.
#[serde(default)]
pub data: Vec<BuyerRefundRequest>,
/// Every request matching the filters.
pub total_count: i64,
/// The page size applied.
pub limit: i64,
/// The offset applied.
pub offset: i64,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// One identifier a block of a refund's buyer would name.
///
/// The identifier's value is personal data: `Debug` prints `<redacted>` in its
/// place.
#[derive(Clone, Deserialize)]
#[non_exhaustive]
pub struct RefundBulkIdentifier {
/// The identifier's kind, for example `email`, `ip` or `device_id`.
pub kind: String,
/// The identifier's value.
pub value: String,
/// The shop the entry would block in, or `None` for every shop.
#[serde(default)]
pub profile_id: Option<String>,
/// Where it was seen: `payment`, `paying_browser` or `seen`.
pub source: String,
/// Whether an entry already blocks it.
pub already_blocked: bool,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
impl fmt::Debug for RefundBulkIdentifier {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("RefundBulkIdentifier")
.field("kind", &self.kind)
.field("value", &"<redacted>")
.field("profile_id", &self.profile_id)
.field("source", &self.source)
.field("already_blocked", &self.already_blocked)
.finish_non_exhaustive()
}
}
/// One selected refund's buyer, as a block would name them.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct RefundBulkBuyer {
/// The refund.
pub refund_id: String,
/// The refund's payment.
pub payment_id: String,
/// The payment's shop.
#[serde(default)]
pub profile_id: Option<String>,
/// Every identifier a block would name.
#[serde(default)]
pub identifiers: Vec<RefundBulkIdentifier>,
/// Identifiers left out of `identifiers` for length.
#[serde(default)]
pub omitted_count: i64,
/// Why the buyer could not be read, when it could not.
#[serde(default)]
pub error_code: Option<String>,
/// The matching error message.
#[serde(default)]
pub error_message: Option<String>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// What a bulk block of refunds' buyers would name. Nothing was changed.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct RefundBulkBlockPreviewResponse {
/// How many refunds were selected.
pub selected_count: i64,
/// Each found refund's buyer.
#[serde(default)]
pub refunds: Vec<RefundBulkBuyer>,
/// The listed refund ids that were not found.
#[serde(default)]
pub not_found: Vec<String>,
/// Whether more than `max_refunds` matched, so only the first were read.
pub truncated: bool,
/// The most refunds a preview reads.
pub max_refunds: i64,
/// The most refunds one bulk block acts on.
pub max_run_refunds: i64,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// One refund's result of a bulk buyer block.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct RefundBulkBlockResult {
/// The refund.
pub refund_id: String,
/// The refund's payment.
#[serde(default)]
pub payment_id: Option<String>,
/// `blocked`, `already_blocked`, `skipped` or `failed`.
pub outcome: String,
/// Why a skipped refund was left out: `not_found`, `no_identifiers` or
/// `already_blocked`.
#[serde(default)]
pub reason: Option<String>,
/// The identifiers the block named.
#[serde(default)]
pub identifiers: Vec<DisputeBulkBlockedIdentifier>,
/// The error code of a failed refund.
#[serde(default)]
pub error_code: Option<String>,
/// The error message of a failed refund.
#[serde(default)]
pub error_message: Option<String>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// Every refund's result of a bulk buyer block.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct RefundBulkBlockBuyerResponse {
/// One result per listed refund.
#[serde(default)]
pub results: Vec<RefundBulkBlockResult>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}