Skip to main content

Client

Struct Client 

Source
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

Source

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.

Source

pub fn api_key(self, key: impl Into<String>) -> Self

Sends Authorization: Bearer <key> on every call (the server’s PAIN001_API_KEY).

Source

pub fn timeout(self, timeout: Duration) -> Self

Sets the timeout for a whole call.

Source

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.

Source

pub fn base_url(&self) -> &str

The base URL, without a trailing /.

Source

pub fn health(&self) -> Result<HealthResponse, Error>

GET /api/v1/health.

Source

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).

Source

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.

Source

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.

Source

pub fn faces(&self) -> Result<Vec<FaceInfo>, Error>

GET /api/v1/faces: the faces a document can be projected into.

Source

pub fn project_face( &self, face: &str, xml: &str, version: Option<&str>, bindings: Option<&Map<String, Value>>, ) -> Result<FaceResponse, Error>

POST /api/v1/faces/{face}: projects a pain.001 document into face. version is detected from the namespace when None.

Source

pub fn request( &self, method: &str, path: &str, body: Option<&Value>, ) -> Result<(u16, Value), Error>

Sends any request and returns the status with the parsed body, whatever the status. An empty body parses as null; a body that is not JSON becomes a JSON string. path starts with /.

Trait Implementations§

Source§

impl Clone for Client

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Client

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.