Expand description
Typed blocking client for the pain001 REST API.
pain001 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.
use pain001_sdk::{Client, MessageType};
use std::time::Duration;
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");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.
Structs§
- Check
Finding - One problem a rung of the validation ladder found.
- Check
Response POST /api/v1/check.- Client
- A client for one pain001 server.
- Face
Info - One entry of
GET /api/v1/faces. - Face
Response POST /api/v1/faces/{face}.- Generate
Response POST /api/v1/ui/generate.- Health
Response GET /api/v1/health.- Loss
Report - What a projection carried and what it did not, by indexed path.
- Request
Error - One item of a
422response’sdetailarray: FastAPI’s request validation error. Seecrate::Error::request_errors. - Retry
Policy - When a
Clienttries aGETcall again. - RowError
- One field error in a payment file’s rows.
- Validation
Response POST /api/v1/ui/validate.
Enums§
- Error
- What went wrong with a call.
- Message
Type - The ISO 20022 message types the server generates and validates.
Constants§
- DEFAULT_
TIMEOUT - The timeout a new
Clientuses for a whole call (connect, send and read), untilClient::timeoutchanges it. - USER_
AGENT - The
User-Agentevery request sends:pain001-sdk-rust/<VERSION>, so a server’s access log shows which client and release made a call. - VERSION
- This crate’s version, from
Cargo.toml.