pain001-sdk 0.0.88

Typed blocking client for the pain001 REST API (ISO 20022 pain.001 and pain.008)
Documentation
// 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.
#![forbid(unsafe_code)]
#![warn(missing_docs)]

mod client;
mod error;
mod retry;
mod types;

#[cfg(test)]
mod stub;

/// 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.
#[cfg(any(fuzzing, test, feature = "internals"))]
#[doc(hidden)]
pub mod fuzzing;

pub use client::{Client, DEFAULT_TIMEOUT, USER_AGENT, VERSION};
pub use error::Error;
pub use retry::RetryPolicy;
pub use types::{
    CheckFinding, CheckResponse, FaceInfo, FaceResponse, GenerateResponse, HealthResponse,
    LossReport, MessageType, RequestError, RowError, ValidationResponse,
};

/// Compiles the README's Rust snippets as doctests.
#[cfg(doctest)]
#[doc = include_str!("../README.md")]
struct ReadmeDoctests;