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
// SPDX-License-Identifier: Apache-2.0 OR MIT
//! Typed blocking client for the pain001 REST API.
//!
//! [pain001](https://pain001.com) generates and validates ISO 20022
//! `pain.001` (credit transfer) and `pain.008` (direct debit) payment
//! files. Its engine is a Python server, `pain001 serve`; this crate is a
//! thin typed client for it. Every request and response is JSON, sent with
//! [`ureq`] on the calling thread, with no async runtime.
//!
//! ```no_run
//! use pain001_sdk::{Client, MessageType};
//! use std::time::Duration;
//!
//! # fn main() -> Result<(), pain001_sdk::Error> {
//! let client = Client::new("http://127.0.0.1:8000").timeout(Duration::from_secs(10));
//! let csv = std::fs::read_to_string("payments.csv").expect("read the CSV");
//! let generated = client.generate(&csv, "payments.csv", MessageType::Pain00100109, None)?;
//! assert!(generated.xml.is_some(), "an Ok always carries the XML");
//! # Ok(())
//! # }
//! ```
//!
//! A generate call whose rows fail validation or a scheme rule becomes
//! [`Error::Refused`] (HTTP `422`), carrying the typed findings; any other
//! non-2xx response becomes [`Error::Api`], carrying the HTTP status and
//! the server's `detail` (a string, or an array for a `422`). The client
//! never logs request bodies, which hold payment data, and retries nothing
//! unless given a [`RetryPolicy`], which retries `GET` calls only.
/// The encoding and decoding paths without the network, for `fuzz/` and
/// `benches/`. Not public API: it exists only under `cfg(fuzzing)`, with
/// the `internals` feature, and in unit tests.
pub use ;
pub use Error;
pub use RetryPolicy;
pub use ;
/// Compiles the README's Rust snippets as doctests.
;