Skip to main content

Crate pain001_sdk

Crate pain001_sdk 

Source
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§

CheckFinding
One problem a rung of the validation ladder found.
CheckResponse
POST /api/v1/check.
Client
A client for one pain001 server.
FaceInfo
One entry of GET /api/v1/faces.
FaceResponse
POST /api/v1/faces/{face}.
GenerateResponse
POST /api/v1/ui/generate.
HealthResponse
GET /api/v1/health.
LossReport
What a projection carried and what it did not, by indexed path.
RequestError
One item of a 422 response’s detail array: FastAPI’s request validation error. See crate::Error::request_errors.
RetryPolicy
When a Client tries a GET call again.
RowError
One field error in a payment file’s rows.
ValidationResponse
POST /api/v1/ui/validate.

Enums§

Error
What went wrong with a call.
MessageType
The ISO 20022 message types the server generates and validates.

Constants§

DEFAULT_TIMEOUT
The timeout a new Client uses for a whole call (connect, send and read), until Client::timeout changes it.
USER_AGENT
The User-Agent every 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.