Package com.pain001.sdk
Class Pain001Client
java.lang.Object
com.pain001.sdk.Pain001Client
A client for the pain001 REST API (
pain001 serve).
Pain001Client client = Pain001Client.builder()
.baseUrl("http://127.0.0.1:8000")
.timeout(Duration.ofSeconds(10))
.build();
GenerateResponse result = client.generate(csv, "payments.csv", "pain.001.001.09");
Typed methods raise Pain001ApiException on a non-2xx response (GenerationRefusedException, with the findings, when generate is refused) and UncheckedIOException when the request cannot be sent or times out (NoDocumentException
when a 2xx from generate carries no XML). The client sends each request once unless a
RetryPolicy is set, which retries GET calls only, and never logs request or
response bodies. Instances are immutable and thread-safe.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic Pain001Client.Builderbuilder()Starts a builder;Pain001Client.Builder.baseUrlis required.POST /api/v1/checkwith the default rungs.POST /api/v1/check: checks a pain.001 or pain.008 document.faces()GET /api/v1/faces: the faces the server can project to.POST /api/v1/ui/generatewith no scheme.POST /api/v1/ui/generate: generates the XML for an uploaded payment file.health()GET /api/v1/health: whether the server is up, and its version.projectFace(String face, String xml) POST /api/v1/faces/{face}with the edition detected and no bindings.POST /api/v1/faces/{face}: projects a pain.001 document onto a target standard.Sends one request and returns the status and parsed body, whatever the status.POST /api/v1/ui/validatewith no scheme.POST /api/v1/ui/validate: validates an uploaded payment file.
-
Field Details
-
VERSION
This SDK's version, sent asUser-Agent: pain001-sdk-java/<version>.- See Also:
-
-
Method Details
-
builder
Starts a builder;Pain001Client.Builder.baseUrlis required.- Returns:
- a new builder with the defaults
-
health
GET /api/v1/health: whether the server is up, and its version.- Returns:
- the server's status, version and message
-
validate
POST /api/v1/ui/validatewith no scheme.- Parameters:
content- the file's text (CSV, JSON or JSONL)filename- a name whose suffix picks the parser, for examplepayments.csvmessageType- the ISO 20022 message type, for examplepain.001.001.09- Returns:
- the validation result
-
validate
public ValidationResponse validate(String content, String filename, String messageType, String scheme) POST /api/v1/ui/validate: validates an uploaded payment file.- Parameters:
content- the file's text (CSV, JSON or JSONL)filename- a name whose suffix picks the parser, for examplepayments.csvmessageType- the ISO 20022 message type, for examplepain.001.001.09scheme- comma-separated scheme rulebooks to enforce, or null- Returns:
- the validation result: row errors and scheme violations when not valid
-
generate
POST /api/v1/ui/generatewith no scheme.- Parameters:
content- the file's text (CSV, JSON or JSONL)filename- a name whose suffix picks the parser, for examplepayments.csvmessageType- the ISO 20022 message type, for examplepain.001.001.09- Returns:
- the generated file;
GenerateResponse.xml()holds the XML - Throws:
GenerationRefusedException- when the server refuses the dataNoDocumentException- when a 2xx answer carries no XML
-
generate
public GenerateResponse generate(String content, String filename, String messageType, String scheme) POST /api/v1/ui/generate: generates the XML for an uploaded payment file.- Parameters:
content- the file's text (CSV, JSON or JSONL)filename- a name whose suffix picks the parser, for examplepayments.csvmessageType- the ISO 20022 message type, for examplepain.001.001.09scheme- comma-separated scheme rulebooks to enforce, or null- Returns:
- the generated file;
GenerateResponse.success()is true - Throws:
GenerationRefusedException- when the server refuses the data (HTTP 422 withsuccess: false); itsGenerationRefusedException.response()holds the findingsNoDocumentException- when a 2xx answer carries no XML (a server older than 0.0.87 answers a refusal with 200 andsuccess: false)
-
check
POST /api/v1/checkwith the default rungs.- Parameters:
xml- the document as XML text- Returns:
- the rungs run and their findings
-
check
POST /api/v1/check: checks a pain.001 or pain.008 document.- Parameters:
xml- the document as XML textscheme- comma-separated scheme profiles to add, or nullschematron- a Schematron preset (sepa,fednow,cbpr), or null- Returns:
- the rungs run and their findings
-
faces
GET /api/v1/faces: the faces the server can project to.- Returns:
- each face's name, description and required bindings
-
projectFace
POST /api/v1/faces/{face}with the edition detected and no bindings.- Parameters:
face- a face name fromfaces(), for exampleberlin_groupxml- the pain.001 document as XML text- Returns:
- the projected payload and its loss report
- Throws:
IllegalArgumentException- whenfaceis not a plain name
-
projectFace
POST /api/v1/faces/{face}: projects a pain.001 document onto a target standard.- Parameters:
face- a face name fromfaces(), for exampleberlin_groupxml- the pain.001 document as XML textversion- the pain.001 edition, or null to detect it from the namespacebindings- side inputs the message does not carry (values may be maps, lists, strings or numbers), or null- Returns:
- the projected payload and its loss report
- Throws:
IllegalArgumentException- whenfaceis not a plain name
-
request
public ApiResponse request(String method, String path, com.fasterxml.jackson.databind.JsonNode body) Sends one request and returns the status and parsed body, whatever the status.This is the low-level call the conformance runner uses; it does not raise on a non-2xx status.
- Parameters:
method- the HTTP method, for exampleGETpath- the path below the base URL, starting with/body- the JSON body, or null to send none- Returns:
- the status and the leniently parsed body
- Throws:
UncheckedIOException- when the request cannot be sent or times out (after the last attempt, when aRetryPolicyapplies)
-