delopay 0.20.0

Official Rust SDK for the DeloPay payments API
Documentation
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
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
//! The `buyer_evidence_reviews` resource: the evidence buyers hand in for the
//! shop's cases, as the shop's team reads and reviews it.
//!
//! A case appears only where its evidence policy shows it to shops
//! (`merchant_access` `view` or `review`), and only for the caller's own shop
//! when the caller's role belongs to one. Reading needs the `Dispute` area at
//! `Read`; the review steps need `Write` and a policy that delegates the
//! review (`merchant_access: review`). Every route needs a dashboard session.
//! A result never refunds a payment and never decides a dispute with the
//! payment provider.

use std::sync::Arc;

use serde::Serialize;
use serde_json::Value;

use crate::core::encoding::{encode_segment, to_json_vec};
use crate::core::error::{DelopayError, Result};
use crate::core::models::buyer_evidence::{BuyerEvidenceQueue, BuyerEvidenceReviewDetail};
use crate::http::client::Inner;
use crate::http::transport::HttpMethod;
use crate::resources::ValidateRequest;

/// The `buyer_evidence_reviews` resource, obtained via
/// [`crate::Delopay::buyer_evidence_reviews`].
#[derive(Debug, Clone)]
pub struct BuyerEvidenceReviews {
    inner: Arc<Inner>,
}

impl BuyerEvidenceReviews {
    pub(crate) fn new(inner: Arc<Inner>) -> Self {
        Self { inner }
    }

    /// The shop's cases with buyer evidence, the nearest target first.
    /// `GET /buyer-evidence`
    pub async fn list(
        &self,
        params: Option<&BuyerEvidenceQueueParams>,
    ) -> Result<BuyerEvidenceQueue> {
        let query = params
            .map(BuyerEvidenceQueueParams::to_query)
            .unwrap_or_default();
        self.inner
            .request(HttpMethod::Get, "/buyer-evidence", None, &query, None)
            .await
    }

    /// One case's evidence with its history and files.
    /// `GET /buyer-evidence/{evidence_id}`
    pub async fn retrieve(&self, evidence_id: &str) -> Result<BuyerEvidenceReviewDetail> {
        self.inner
            .request(
                HttpMethod::Get,
                &evidence_path(evidence_id),
                None,
                &[],
                None,
            )
            .await
    }

    /// Download a file of a case's evidence, returned as its bytes.
    /// `GET /buyer-evidence/{evidence_id}/files/{file_id}`
    pub async fn download_file(&self, evidence_id: &str, file_id: &str) -> Result<Vec<u8>> {
        let path = format!(
            "{}/files/{}",
            evidence_path(evidence_id),
            encode_segment(file_id)
        );
        self.inner
            .request_bytes(HttpMethod::Get, &path, &[], "*/*")
            .await
    }

    /// Ask the buyer for more, by a cut-off. Refused once a result closed the
    /// review. `POST /buyer-evidence/{evidence_id}/information-requests`
    pub async fn request_information(
        &self,
        evidence_id: &str,
        params: &BuyerEvidenceInformationRequest,
    ) -> Result<BuyerEvidenceReviewDetail> {
        params.validate()?;
        self.post(evidence_id, "information-requests", &to_json_vec(params)?)
            .await
    }

    /// An answer the buyer sees. `POST /buyer-evidence/{evidence_id}/replies`
    pub async fn reply(
        &self,
        evidence_id: &str,
        params: &BuyerEvidenceReply,
    ) -> Result<BuyerEvidenceReviewDetail> {
        self.post(evidence_id, "replies", &to_json_vec(params)?)
            .await
    }

    /// Record the result, which closes the review.
    /// `POST /buyer-evidence/{evidence_id}/reviews`
    pub async fn review(
        &self,
        evidence_id: &str,
        params: &BuyerEvidenceReviewCreate,
    ) -> Result<BuyerEvidenceReviewDetail> {
        params.validate()?;
        self.post(evidence_id, "reviews", &to_json_vec(params)?)
            .await
    }

    /// A note the shop's team and DeloPay read, never the buyer.
    /// `POST /buyer-evidence/{evidence_id}/notes`
    pub async fn note(
        &self,
        evidence_id: &str,
        params: &BuyerEvidenceNote,
    ) -> Result<BuyerEvidenceReviewDetail> {
        self.post(evidence_id, "notes", &to_json_vec(params)?).await
    }

    async fn post(
        &self,
        evidence_id: &str,
        step: &str,
        body: &[u8],
    ) -> Result<BuyerEvidenceReviewDetail> {
        let path = format!("{}/{step}", evidence_path(evidence_id));
        self.inner
            .request_body_keyed(HttpMethod::Post, &path, Some(body), None)
            .await
    }
}

/// `/buyer-evidence/{evidence_id}`, percent-encoded.
fn evidence_path(evidence_id: &str) -> String {
    format!("/buyer-evidence/{}", encode_segment(evidence_id))
}

/// Where a case's evidence stands.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum BuyerEvidenceState {
    /// Waiting for the buyer's evidence.
    AwaitingBuyer,
    /// Waiting for the review.
    AwaitingReview,
    /// The buyer was asked for more.
    InformationRequested,
    /// A result closed the review.
    Reviewed,
}

impl BuyerEvidenceState {
    /// The wire token.
    pub fn as_str(self) -> &'static str {
        match self {
            Self::AwaitingBuyer => "awaiting_buyer",
            Self::AwaitingReview => "awaiting_review",
            Self::InformationRequested => "information_requested",
            Self::Reviewed => "reviewed",
        }
    }
}

/// Filters for [`BuyerEvidenceReviews::list`].
#[derive(Debug, Clone, Default)]
pub struct BuyerEvidenceQueueParams {
    /// Only cases in this state.
    pub state: Option<BuyerEvidenceState>,
    /// Only cases whose next step is (or is not) overdue.
    pub overdue: Option<bool>,
    /// Only cases where the buyer asked (or did not ask) for more time.
    pub extension_requested: Option<bool>,
    /// `true` for test cases only, `false` for live only.
    pub test_mode: Option<bool>,
    /// Page size.
    pub limit: Option<u32>,
    /// Cases to skip.
    pub offset: Option<u32>,
}

impl BuyerEvidenceQueueParams {
    fn to_query(&self) -> Vec<(&'static str, String)> {
        let mut q = Vec::new();
        if let Some(v) = self.state {
            q.push(("state", v.as_str().to_string()));
        }
        if let Some(v) = self.overdue {
            q.push(("overdue", v.to_string()));
        }
        if let Some(v) = self.extension_requested {
            q.push(("extension_requested", v.to_string()));
        }
        if let Some(v) = self.test_mode {
            q.push(("test_mode", v.to_string()));
        }
        if let Some(v) = self.limit {
            q.push(("limit", v.to_string()));
        }
        if let Some(v) = self.offset {
            q.push(("offset", v.to_string()));
        }
        q
    }
}

/// Rejects an `extra` key that collides with one of `named`, so the body
/// never carries a duplicate key.
fn reject_extra_collisions(
    extra: &serde_json::Map<String, Value>,
    named: &[&str],
    type_name: &str,
) -> Result<()> {
    for key in extra.keys() {
        if named.contains(&key.as_str()) {
            return Err(DelopayError::InvalidRequest(format!(
                "`extra` key `{key}` collides with a named field on {type_name}"
            )));
        }
    }
    Ok(())
}

/// Parameters for [`BuyerEvidenceReviews::request_information`].
#[derive(Debug, Clone, Default, Serialize)]
pub struct BuyerEvidenceInformationRequest {
    /// What to ask the buyer.
    pub question: String,
    /// The cut-off, ISO 8601. Omitted, the policy's supplement window applies.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub due_at: Option<String>,
    /// Any additional fields, merged verbatim.
    #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
    pub extra: serde_json::Map<String, Value>,
}

impl BuyerEvidenceInformationRequest {
    /// Ask the buyer `question`.
    pub fn new(question: impl Into<String>) -> Self {
        Self {
            question: question.into(),
            ..Default::default()
        }
    }

    /// Set the cut-off, ISO 8601.
    #[must_use]
    pub fn due_at(mut self, due_at: impl Into<String>) -> Self {
        self.due_at = Some(due_at.into());
        self
    }
}

/// Names of `BuyerEvidenceInformationRequest`'s fields as they appear on the
/// wire (`extra` excluded).
const BUYER_EVIDENCE_INFORMATION_REQUEST_NAMED: &[&str] = &["question", "due_at"];

impl ValidateRequest for BuyerEvidenceInformationRequest {
    fn validate(&self) -> Result<()> {
        reject_extra_collisions(
            &self.extra,
            BUYER_EVIDENCE_INFORMATION_REQUEST_NAMED,
            "BuyerEvidenceInformationRequest",
        )
    }
}

/// Parameters for [`BuyerEvidenceReviews::reply`].
#[derive(Debug, Clone, Default, Serialize)]
pub struct BuyerEvidenceReply {
    /// The answer the buyer sees.
    pub body: String,
}

impl BuyerEvidenceReply {
    /// Answer the buyer with `body`.
    pub fn new(body: impl Into<String>) -> Self {
        Self { body: body.into() }
    }
}

/// Parameters for [`BuyerEvidenceReviews::note`].
#[derive(Debug, Clone, Default, Serialize)]
pub struct BuyerEvidenceNote {
    /// The note, never shown to the buyer.
    pub body: String,
}

impl BuyerEvidenceNote {
    /// A note reading `body`.
    pub fn new(body: impl Into<String>) -> Self {
        Self { body: body.into() }
    }
}

/// A review's result.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
#[serde(rename_all = "snake_case")]
#[non_exhaustive]
pub enum BuyerEvidenceOutcome {
    /// The evidence supports the buyer.
    SupportsBuyer,
    /// The evidence does not support the buyer.
    DoesNotSupportBuyer,
    /// The evidence decides nothing.
    Inconclusive,
}

/// Parameters for [`BuyerEvidenceReviews::review`].
#[derive(Debug, Clone, Serialize)]
pub struct BuyerEvidenceReviewCreate {
    /// The result.
    pub outcome: BuyerEvidenceOutcome,
    /// What the buyer is told.
    pub response: String,
    /// A note for the shop's team and DeloPay.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub note: Option<String>,
    /// Any additional fields, merged verbatim.
    #[serde(flatten, skip_serializing_if = "serde_json::Map::is_empty")]
    pub extra: serde_json::Map<String, Value>,
}

impl BuyerEvidenceReviewCreate {
    /// Record `outcome`, telling the buyer `response`.
    pub fn new(outcome: BuyerEvidenceOutcome, response: impl Into<String>) -> Self {
        Self {
            outcome,
            response: response.into(),
            note: None,
            extra: serde_json::Map::new(),
        }
    }

    /// Add a note for the shop's team and DeloPay.
    #[must_use]
    pub fn note(mut self, note: impl Into<String>) -> Self {
        self.note = Some(note.into());
        self
    }
}

/// Names of `BuyerEvidenceReviewCreate`'s fields as they appear on the wire
/// (`extra` excluded).
const BUYER_EVIDENCE_REVIEW_CREATE_NAMED: &[&str] = &["outcome", "response", "note"];

impl ValidateRequest for BuyerEvidenceReviewCreate {
    fn validate(&self) -> Result<()> {
        reject_extra_collisions(
            &self.extra,
            BUYER_EVIDENCE_REVIEW_CREATE_NAMED,
            "BuyerEvidenceReviewCreate",
        )
    }
}

#[cfg(test)]
mod tests {
    use super::*;
    use crate::http::mock::{Step, client_with};
    use serde_json::json;

    const SUMMARY_FIELDS: &str = r#"
        "id": "bev_1", "merchant_id": "mer_1", "profile_id": "pro_1",
        "customer_id": "cus_1", "case_kind": "dispute", "case_category": "bank_chargeback",
        "case_opened_at": "2026-01-01T00:00:00Z", "test_mode": false,
        "state": "awaiting_review", "next_actor": "reviewer", "overdue": false,
        "policy_source": "merchant", "created_at": "2026-01-01T00:00:00Z",
        "modified_at": "2026-01-02T00:00:00Z""#;

    fn detail_json() -> String {
        format!(
            r#"{{{SUMMARY_FIELDS},
                "case": {{"id": "case_1", "kind": "dispute", "category": "bank_chargeback",
                    "origin": "bank_card_issuer", "state": "open", "next_actor": "merchant",
                    "outcome": "pending", "shop_name": "Main", "amount": 1500,
                    "currency": "EUR", "created_at": "2026-01-01T00:00:00Z",
                    "updated_at": "2026-01-02T00:00:00Z",
                    "events": [{{"at": "2026-01-01T00:00:00Z", "kind": "opened", "actor": "provider"}}],
                    "history_complete": true}},
                "policy": {{"case_categories": ["dispute"], "max_files": 5,
                    "max_file_megabytes": 10, "file_types": ["pdf", "png"],
                    "explanation_required": true, "initial_hours": 72,
                    "supplement_hours": 48, "review_target_hours": 24,
                    "merchant_access": "review"}},
                "history": [{{"id": "h_1", "kind": "submitted", "actor": "buyer",
                    "at": "2026-01-01T00:00:00Z", "body": "see receipt",
                    "files": [{{"id": "f_1", "file_name": "receipt.pdf", "file_type": "pdf",
                        "size_bytes": 2048, "uploaded_at": "2026-01-01T00:00:00Z",
                        "submitted": true}}],
                    "public": true}}],
                "files": [{{"id": "f_1", "file_name": "receipt.pdf", "file_type": "pdf",
                    "size_bytes": 2048, "uploaded_at": "2026-01-01T00:00:00Z",
                    "submitted": true, "sha256": "ab12"}}],
                "detail_surprise": 1}}"#
        )
    }

    #[tokio::test]
    async fn list_sends_the_filters() {
        let (client, mock) = client_with(vec![Step::ok(&format!(
            r#"{{"data":[{{{SUMMARY_FIELDS}, "row_surprise": 1}}],"total":1}}"#
        ))]);
        let params = BuyerEvidenceQueueParams {
            state: Some(BuyerEvidenceState::AwaitingReview),
            overdue: Some(true),
            test_mode: Some(false),
            limit: Some(10),
            ..Default::default()
        };
        let queue = client
            .buyer_evidence_reviews()
            .list(Some(&params))
            .await
            .unwrap();
        assert_eq!(queue.total, 1);
        assert_eq!(queue.data[0].state, "awaiting_review");
        assert_eq!(queue.data[0].extra["row_surprise"], 1);

        let seen = mock.seen.lock().unwrap();
        assert_eq!(seen[0].method, "GET");
        assert_eq!(
            seen[0].url,
            "https://api.test/buyer-evidence?state=awaiting_review&overdue=true\
             &test_mode=false&limit=10"
        );
    }

    #[tokio::test]
    async fn retrieve_encodes_the_evidence_id() {
        let (client, mock) = client_with(vec![Step::ok(&detail_json())]);
        let detail = client
            .buyer_evidence_reviews()
            .retrieve("bev/1")
            .await
            .unwrap();
        assert_eq!(detail.policy.max_files, 5);
        assert_eq!(detail.history[0].files[0].size_bytes, 2048);
        assert_eq!(detail.files[0].sha256, "ab12");
        assert_eq!(detail.case.as_ref().unwrap()["id"], "case_1");
        assert_eq!(detail.extra["detail_surprise"], 1);

        let seen = mock.seen.lock().unwrap();
        assert_eq!(seen[0].method, "GET");
        assert_eq!(seen[0].url, "https://api.test/buyer-evidence/bev%2F1");
    }

    #[tokio::test]
    async fn download_file_returns_the_bytes_of_the_encoded_file() {
        let (client, mock) = client_with(vec![Step::ok("%PDF-1.4")]);
        let bytes = client
            .buyer_evidence_reviews()
            .download_file("bev_1", "f/1")
            .await
            .unwrap();
        assert_eq!(bytes, b"%PDF-1.4");

        let seen = mock.seen.lock().unwrap();
        assert_eq!(seen[0].method, "GET");
        assert_eq!(
            seen[0].url,
            "https://api.test/buyer-evidence/bev_1/files/f%2F1"
        );
        assert_eq!(seen[0].header("accept"), Some("*/*"));
    }

    #[tokio::test]
    async fn request_information_posts_the_question() {
        let (client, mock) = client_with(vec![Step::ok(&detail_json())]);
        let req = BuyerEvidenceInformationRequest::new("Can you send the tracking number?")
            .due_at("2026-01-05T00:00:00Z");
        client
            .buyer_evidence_reviews()
            .request_information("bev_1", &req)
            .await
            .unwrap();

        let seen = mock.seen.lock().unwrap();
        assert_eq!(seen[0].method, "POST");
        assert_eq!(
            seen[0].url,
            "https://api.test/buyer-evidence/bev_1/information-requests"
        );
        assert_eq!(
            seen[0].body_json(),
            json!({"question": "Can you send the tracking number?", "due_at": "2026-01-05T00:00:00Z"})
        );
    }

    #[tokio::test]
    async fn reply_posts_to_the_replies_path() {
        let (client, mock) = client_with(vec![Step::ok(&detail_json())]);
        client
            .buyer_evidence_reviews()
            .reply("bev_1", &BuyerEvidenceReply::new("Thanks, reviewing"))
            .await
            .unwrap();

        let seen = mock.seen.lock().unwrap();
        assert_eq!(seen[0].method, "POST");
        assert_eq!(seen[0].url, "https://api.test/buyer-evidence/bev_1/replies");
        assert_eq!(seen[0].body_json(), json!({"body": "Thanks, reviewing"}));
    }

    #[tokio::test]
    async fn review_posts_the_outcome() {
        let (client, mock) = client_with(vec![Step::ok(&detail_json())]);
        let req = BuyerEvidenceReviewCreate::new(
            BuyerEvidenceOutcome::DoesNotSupportBuyer,
            "The parcel was delivered",
        )
        .note("carrier proof attached");
        client
            .buyer_evidence_reviews()
            .review("bev_1", &req)
            .await
            .unwrap();

        let seen = mock.seen.lock().unwrap();
        assert_eq!(seen[0].method, "POST");
        assert_eq!(seen[0].url, "https://api.test/buyer-evidence/bev_1/reviews");
        assert_eq!(
            seen[0].body_json(),
            json!({
                "outcome": "does_not_support_buyer",
                "response": "The parcel was delivered",
                "note": "carrier proof attached"
            })
        );
    }

    #[tokio::test]
    async fn note_posts_to_the_notes_path() {
        let (client, mock) = client_with(vec![Step::ok(&detail_json())]);
        client
            .buyer_evidence_reviews()
            .note("bev_1", &BuyerEvidenceNote::new("internal"))
            .await
            .unwrap();

        let seen = mock.seen.lock().unwrap();
        assert_eq!(seen[0].method, "POST");
        assert_eq!(seen[0].url, "https://api.test/buyer-evidence/bev_1/notes");
        assert_eq!(seen[0].body_json(), json!({"body": "internal"}));
    }

    fn assert_named_complete<T: Serialize>(req: &T, named: &[&str]) {
        let value = serde_json::to_value(req).unwrap();
        for key in value.as_object().expect("serializes to an object").keys() {
            assert!(
                named.contains(&key.as_str()),
                "NAMED is missing wire key `{key}`"
            );
        }
    }

    /// Drift guard for `BUYER_EVIDENCE_INFORMATION_REQUEST_NAMED`.
    #[test]
    fn buyer_evidence_information_request_named_fields_are_complete() {
        let req = BuyerEvidenceInformationRequest::new("q").due_at("2026-01-05T00:00:00Z");
        assert_named_complete(&req, BUYER_EVIDENCE_INFORMATION_REQUEST_NAMED);
    }

    /// Drift guard for `BUYER_EVIDENCE_REVIEW_CREATE_NAMED`.
    #[test]
    fn buyer_evidence_review_create_named_fields_are_complete() {
        let req = BuyerEvidenceReviewCreate::new(BuyerEvidenceOutcome::Inconclusive, "r").note("n");
        assert_named_complete(&req, BUYER_EVIDENCE_REVIEW_CREATE_NAMED);
    }

    #[test]
    fn review_validate_rejects_colliding_extra_key() {
        let mut req = BuyerEvidenceReviewCreate::new(BuyerEvidenceOutcome::SupportsBuyer, "r");
        req.extra
            .insert("outcome".to_string(), json!("inconclusive"));
        match req.validate().unwrap_err() {
            DelopayError::InvalidRequest(msg) => assert!(msg.contains("outcome")),
            other => panic!("expected InvalidRequest, got {other:?}"),
        }
    }

    /// Every write here ignores the client-wide idempotency key: none sends
    /// it, and none is replayed after a `503`. Switching a call site back to
    /// `request(.., None)` makes it send the key and retry.
    #[tokio::test]
    async fn writes_ignore_the_client_wide_idempotency_key() {
        let steps = (0..4)
            .map(|_| Step::status(503, r#"{"error":{"message":"down"}}"#))
            .collect();
        let (client, mock) = crate::http::mock::client_with_retries(steps, 2);
        let client = client.with_idempotency_key("client-key");
        client
            .buyer_evidence_reviews()
            .request_information("bev_1", &BuyerEvidenceInformationRequest::new("q"))
            .await
            .unwrap_err();
        client
            .buyer_evidence_reviews()
            .reply("bev_1", &BuyerEvidenceReply::new("r"))
            .await
            .unwrap_err();
        client
            .buyer_evidence_reviews()
            .review(
                "bev_1",
                &BuyerEvidenceReviewCreate::new(BuyerEvidenceOutcome::Inconclusive, "r"),
            )
            .await
            .unwrap_err();
        client
            .buyer_evidence_reviews()
            .note("bev_1", &BuyerEvidenceNote::new("n"))
            .await
            .unwrap_err();
        assert_eq!(mock.call_count(), 4);
        for seen in mock.seen.lock().unwrap().iter() {
            assert!(
                !seen.had_idempotency_key(),
                "{} sent the client key",
                seen.url
            );
        }
    }
}