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
//! A customer's identity history: every email address, name and handle a
//! customer has been known by, with where it came from.
//!
//! Values are personal data. `Debug` on these types prints none of them, so a
//! response logged with `{:?}` does not carry a buyer's email into the log.
use std::fmt;
use serde::Deserialize;
use serde_json::Value;
/// What became of one import row.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize)]
#[serde(rename_all = "snake_case")]
#[non_exhaustive]
pub enum CustomerIdentityImportOutcome {
/// The value is new for this customer, kind and source label.
Accepted,
/// The customer already holds the value from the same source label.
Unchanged,
/// The row was refused; `reason` says why.
Rejected,
/// An outcome this SDK version does not know yet.
#[serde(other)]
Unknown,
}
/// One row's result, in the order the rows were sent.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct CustomerIdentityImportRowResult {
/// The row's position in the request, from 0.
pub row_index: u32,
/// Your reference for the row, as sent.
pub external_ref: String,
#[serde(default)]
pub customer_id: Option<String>,
/// `email`, `name` or `handle`.
#[serde(default)]
pub kind: Option<String>,
pub outcome: CustomerIdentityImportOutcome,
/// Why a rejected row was refused, for example `invalid_customer_id`,
/// `not_an_email`, `placeholder` or `customer_erased`.
#[serde(default)]
pub reason: Option<String>,
/// The history entry the row maps to, once recorded.
#[serde(default)]
pub entry_id: Option<String>,
/// How many other customers already hold the same value, stored or in an
/// earlier row of the request. Only on an accepted or unchanged row of a
/// preview or a first import.
#[serde(default)]
pub other_customers: Option<u32>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// What an import would do. Nothing was written.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct CustomerIdentityImportPreviewResponse {
pub rows_total: u32,
pub rows_accepted: u32,
pub rows_unchanged: u32,
/// Rows refused by their content. A customer erased since cannot be seen
/// here; the import refuses its rows with `customer_erased`.
pub rows_rejected: u32,
/// Distinct customer ids among the acceptable rows that have no customer
/// yet. Their values are recorded under the id all the same.
#[serde(default)]
pub customers_without_record: u32,
/// Acceptable rows whose value other customers hold too.
#[serde(default)]
pub rows_with_other_customers: u32,
pub rows: Vec<CustomerIdentityImportRowResult>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// An import run and its rows.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct CustomerIdentityImportResponse {
pub run_id: String,
pub idempotency_key: String,
/// `true` when this answers a repeated request and nothing was written.
pub replayed: bool,
pub rows_total: u32,
pub rows_accepted: u32,
pub rows_unchanged: u32,
pub rows_rejected: u32,
/// ISO 8601.
pub created_at: String,
/// Acceptable rows whose value other customers hold too. Only on a first
/// import, not on a replay or a readback.
#[serde(default)]
pub rows_with_other_customers: Option<u32>,
pub rows: Vec<CustomerIdentityImportRowResult>,
/// The history entries the run's rows map to, as they stand now. Only on
/// the readback (`Customers::retrieve_identity_import`).
#[serde(default)]
pub entries: Option<Vec<CustomerIdentityEntry>>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// One value a customer has been known by, from one origin.
#[derive(Clone, Deserialize)]
#[non_exhaustive]
pub struct CustomerIdentityEntry {
pub id: String,
pub customer_id: String,
/// `email`, `name` or `handle`.
pub kind: String,
/// The value as first recorded.
pub value: String,
/// The value normalised as the import compares it.
pub normalized_value: String,
/// `import`, `psp`, `merchant_request` or `profile`.
pub source: String,
pub source_label: String,
/// The processor's verdict on the payer's account, when it reported one.
#[serde(default)]
pub account_status: Option<String>,
#[serde(default)]
pub first_source_ref: Option<String>,
#[serde(default)]
pub last_source_ref: Option<String>,
/// ISO 8601, when known.
#[serde(default)]
pub first_seen_at: Option<String>,
/// ISO 8601, when known.
#[serde(default)]
pub last_seen_at: Option<String>,
#[serde(default)]
pub seen_count: u32,
/// When the entry was first recorded, ISO 8601.
pub recorded_at: String,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
impl fmt::Debug for CustomerIdentityEntry {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("CustomerIdentityEntry")
.field("id", &self.id)
.field("customer_id", &self.customer_id)
.field("kind", &self.kind)
.field("value", &"<redacted>")
.field("normalized_value", &"<redacted>")
.field("source", &self.source)
.field("source_label", &self.source_label)
.field("account_status", &self.account_status)
.field("seen_count", &self.seen_count)
.field("recorded_at", &self.recorded_at)
.finish_non_exhaustive()
}
}
/// The history of the customers asked for, or a search's matches.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct CustomerIdentityHistoryResponse {
pub entries: Vec<CustomerIdentityEntry>,
/// Search only: `true` when more entries match than were returned: a match
/// past `limit`, or the candidate limit was reached. By customer, only the
/// candidate limit; further pages are `next_cursor`.
#[serde(default)]
pub truncated: Option<bool>,
/// Search by customer only: this page's customers.
#[serde(default)]
pub customers: Option<Vec<CustomerIdentityMatch>>,
/// Search by customer only: how many customers match.
#[serde(default)]
pub total_customers: Option<u32>,
/// Search by customer only: the `cursor` of the next page; absent on the
/// last.
#[serde(default)]
pub next_cursor: Option<String>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// One customer's matching values in a search answered by customer.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct CustomerIdentityMatch {
pub customer_id: String,
/// The customer's matching entries, newest first.
pub entries: Vec<CustomerIdentityEntry>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}