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
//! The merchant audit-log models.
//!
//! What a merchant is allowed to see of their own log, which is deliberately
//! less than what the platform records. Two redactions are structural rather
//! than cosmetic, and both are documented on the types that carry them:
//! a DeloPay actor is never named, and a DeloPay session is never described.
use serde::Deserialize;
use serde_json::Value;
/// The parties a merchant can see in their own log.
///
/// `"delopay"` covers support acting on the account and the platform itself,
/// deliberately as one value: which of DeloPay's mechanisms it was is not the
/// merchant's question, and splitting it would leak internal structure.
///
/// Open-ended (`String`) rather than an enum, so a party added later reaches
/// the caller as data instead of a deserialization failure. Known values:
/// `"team_member"`, `"api_key"`, `"delopay"`, `"system"`.
pub type MerchantAuditActorKind = String;
/// Which relationship an impersonated change was made under.
///
/// `None` means **unknown** — a row written before this was recorded — which
/// is not the same as `"self_acted"`. Known values: `"self_acted"`,
/// `"admin_for_merchant"`, `"merchant_for_team_member"`.
pub type MerchantAuditImpersonationKind = String;
/// Who acted, as a merchant is allowed to see it.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct MerchantAuditActorInfo {
/// `None` for a DeloPay actor: the merchant learns that support acted, not
/// which employee it was.
#[serde(default)]
pub id: Option<String>,
/// See [`MerchantAuditActorKind`].
pub kind: MerchantAuditActorKind,
/// The team member's email, or the label for a non-human actor.
#[serde(default)]
pub name: Option<String>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// The sign-in a change was made in.
///
/// Only ever present for the merchant's **own** people. A DeloPay support
/// session carries none: the employee's device, address and city are not the
/// merchant's to read back.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct MerchantAuditSessionInfo {
/// Session id — the grouping key for "everything done in one sign-in".
pub id: String,
/// Address the session signed in from.
#[serde(default)]
pub ip_address: Option<String>,
#[serde(default)]
pub user_agent: Option<String>,
#[serde(default)]
pub country_code: Option<String>,
#[serde(default)]
pub city: Option<String>,
/// Approximate — derived from the IP, so a neighbourhood, not an address.
#[serde(default)]
pub latitude: Option<f64>,
/// Approximate, on the same terms as [`latitude`](Self::latitude).
#[serde(default)]
pub longitude: Option<f64>,
#[serde(default)]
pub auth_method: Option<String>,
#[serde(default)]
pub started_at: Option<String>,
#[serde(default)]
pub last_seen_at: Option<String>,
/// Set when the session was ended early.
#[serde(default)]
pub revoked_at: Option<String>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// One recorded change on a merchant's account or one of its shops.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct MerchantAuditLogEntry {
/// Unique entry id, as taken by [`crate::Audit::retrieve`].
pub id: String,
/// Who the change is attributed to.
pub actor: MerchantAuditActorInfo,
/// The person really acting, when it was one of the merchant's own — an
/// admin signed in as a team member. `None` when nobody was impersonating,
/// and also when it was DeloPay: `impersonation_kind` says an admin acted,
/// and `actor` already says it was DeloPay.
#[serde(default)]
pub real_actor: Option<MerchantAuditActorInfo>,
/// See [`MerchantAuditImpersonationKind`] — `None` is unknown, not
/// "nobody impersonated".
#[serde(default)]
pub impersonation_kind: Option<MerchantAuditImpersonationKind>,
/// The sign-in the change was made in, where the merchant may see it.
#[serde(default)]
pub session: Option<MerchantAuditSessionInfo>,
/// The shop the change belongs to, when it was shop-scoped.
#[serde(default)]
pub profile_id: Option<String>,
/// What was done, e.g. `"update"`.
pub action: String,
/// What it was done to, e.g. `"business_profile"`.
pub entity_type: String,
#[serde(default)]
pub entity_id: Option<String>,
/// What the entity was called. `None` when it has since been deleted.
#[serde(default)]
pub entity_name: Option<String>,
/// Which fields the change touched. Names only, never values — the raw
/// payload can carry connector credentials, so it is never forwarded.
#[serde(default)]
pub changed_fields: Vec<String>,
/// ISO 8601 timestamp of the change.
pub created_at: String,
/// For a change to one setting: its key and its value before and after.
#[serde(default)]
pub setting_change: Option<MerchantAuditSettingChange>,
/// The change line by line, where the entry records it.
#[serde(default)]
pub changes: Option<Vec<AuditChange>>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// A change to one setting, as an audit entry records it.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct MerchantAuditSettingChange {
/// The setting's key.
pub key: String,
/// Whether a value was stored before the change.
pub was_set: bool,
/// Whether a value is stored after the change; `false` when it was
/// cleared.
pub is_set: bool,
/// The value before the change; `None` when none was stored.
#[serde(default)]
pub old_value: Option<Value>,
/// The value after the change; `None` when it was cleared.
#[serde(default)]
pub new_value: Option<Value>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// One line of an audited change.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct AuditChange {
/// `"added"`, `"removed"`, `"replaced"`, `"changed"`, `"moved"` or
/// `"reordered"`.
pub op: String,
/// `live` or `test`, on a checkout layout change.
#[serde(default)]
pub environment: Option<String>,
/// Where: a layout tier, or `shops` / `payment_methods` on a connector
/// account.
#[serde(default)]
pub group: Option<String>,
/// The field that changed, for `changed` and `moved`.
#[serde(default)]
pub field: Option<String>,
/// The item the line is about.
#[serde(default)]
pub item: Option<AuditChangeItem>,
/// The item it replaced, for `replaced`.
#[serde(default)]
pub previous_item: Option<AuditChangeItem>,
/// The value before.
#[serde(default)]
pub old_value: Option<Value>,
/// The value after.
#[serde(default)]
pub new_value: Option<Value>,
/// `true` when the values are secret and were not recorded.
#[serde(default)]
pub withheld: bool,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// What one line of an audited change is about.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct AuditChangeItem {
/// `method`, `card`, `heading`, `general` or `account`.
#[serde(default)]
pub kind: Option<String>,
/// The payment method.
#[serde(default)]
pub method: Option<String>,
/// The connector.
#[serde(default)]
pub connector: Option<String>,
/// The connector account.
#[serde(default)]
pub merchant_connector_id: Option<String>,
/// The capability.
#[serde(default)]
pub capability: Option<String>,
/// The preset.
#[serde(default)]
pub preset: Option<String>,
/// The merchant's own label for the tile or the account.
#[serde(default)]
pub label: Option<String>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// One page of a merchant's audit log.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct MerchantAuditLogListResponse {
/// The page, newest first.
pub entries: Vec<MerchantAuditLogEntry>,
/// How many entries the filter matched in total, which is what makes
/// paging terminable without probing for the end.
pub total_count: i64,
/// Offset this page was read at.
pub offset: i64,
/// Page size this page was read with.
pub limit: i64,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}