pub struct Client { /* private fields */ }Expand description
A client for one pain001 server.
Cheap to clone; clones share the connection pool. Debug output never
shows the API key.
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(base_url: impl Into<String>) -> Self
pub fn new(base_url: impl Into<String>) -> Self
A client for the server at base_url, for example
http://127.0.0.1:8000. A trailing / is ignored.
Sourcepub fn api_key(self, key: impl Into<String>) -> Self
pub fn api_key(self, key: impl Into<String>) -> Self
Sends Authorization: Bearer <key> on every call (the server’s
PAIN001_API_KEY).
Sourcepub fn retry(self, policy: RetryPolicy) -> Self
pub fn retry(self, policy: RetryPolicy) -> Self
Retries GET calls under policy; without this, every call makes
exactly one attempt. POST calls are never retried. See
RetryPolicy.
Sourcepub fn health(&self) -> Result<HealthResponse, Error>
pub fn health(&self) -> Result<HealthResponse, Error>
GET /api/v1/health.
Sourcepub fn validate(
&self,
content: &str,
filename: &str,
message_type: impl AsRef<str>,
scheme: Option<&str>,
) -> Result<ValidationResponse, Error>
pub fn validate( &self, content: &str, filename: &str, message_type: impl AsRef<str>, scheme: Option<&str>, ) -> Result<ValidationResponse, Error>
POST /api/v1/ui/validate: validates a CSV, JSON or JSONL payment
file’s text. filename’s suffix picks the parser; scheme names
rulebooks, comma-separated (for example sepa-sct).
Sourcepub fn generate(
&self,
content: &str,
filename: &str,
message_type: impl AsRef<str>,
scheme: Option<&str>,
) -> Result<GenerateResponse, Error>
pub fn generate( &self, content: &str, filename: &str, message_type: impl AsRef<str>, scheme: Option<&str>, ) -> Result<GenerateResponse, Error>
POST /api/v1/ui/generate: turns a payment file’s text into XML.
§Errors
Error::Refused when the server refuses the rows or a scheme rule
(HTTP 422), carrying the typed findings; Error::Api for any
other non-2xx reply, such as a 400 for an unreadable file;
Error::Decode for a 2xx reply without success: true and the
XML, so an Ok always carries the document.
Sourcepub fn check(
&self,
xml: &str,
scheme: Option<&str>,
schematron: Option<&str>,
) -> Result<CheckResponse, Error>
pub fn check( &self, xml: &str, scheme: Option<&str>, schematron: Option<&str>, ) -> Result<CheckResponse, Error>
POST /api/v1/check: runs the validation ladder on an existing
pain.001 or pain.008 document, adding scheme profiles and a
Schematron preset (sepa, fednow, cbpr) when given.
Sourcepub fn faces(&self) -> Result<Vec<FaceInfo>, Error>
pub fn faces(&self) -> Result<Vec<FaceInfo>, Error>
GET /api/v1/faces: the faces a document can be projected into.