Class Pain001Client

java.lang.Object
com.pain001.sdk.Pain001Client

public final class Pain001Client extends Object
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.

  • Field Details

    • VERSION

      public static final String VERSION
      This SDK's version, sent as User-Agent: pain001-sdk-java/<version>.
      See Also:
  • Method Details

    • builder

      public static Pain001Client.Builder builder()
      Starts a builder; Pain001Client.Builder.baseUrl is required.
      Returns:
      a new builder with the defaults
    • health

      public HealthResponse health()
      GET /api/v1/health: whether the server is up, and its version.
      Returns:
      the server's status, version and message
    • validate

      public ValidationResponse validate(String content, String filename, String messageType)
      POST /api/v1/ui/validate with no scheme.
      Parameters:
      content - the file's text (CSV, JSON or JSONL)
      filename - a name whose suffix picks the parser, for example payments.csv
      messageType - the ISO 20022 message type, for example pain.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 example payments.csv
      messageType - the ISO 20022 message type, for example pain.001.001.09
      scheme - comma-separated scheme rulebooks to enforce, or null
      Returns:
      the validation result: row errors and scheme violations when not valid
    • generate

      public GenerateResponse generate(String content, String filename, String messageType)
      POST /api/v1/ui/generate with no scheme.
      Parameters:
      content - the file's text (CSV, JSON or JSONL)
      filename - a name whose suffix picks the parser, for example payments.csv
      messageType - the ISO 20022 message type, for example pain.001.001.09
      Returns:
      the generated file; GenerateResponse.xml() holds the XML
      Throws:
      GenerationRefusedException - when the server refuses the data
      NoDocumentException - 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 example payments.csv
      messageType - the ISO 20022 message type, for example pain.001.001.09
      scheme - 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 with success: false); its GenerationRefusedException.response() holds the findings
      NoDocumentException - when a 2xx answer carries no XML (a server older than 0.0.87 answers a refusal with 200 and success: false)
    • check

      public CheckResponse check(String xml)
      POST /api/v1/check with the default rungs.
      Parameters:
      xml - the document as XML text
      Returns:
      the rungs run and their findings
    • check

      public CheckResponse check(String xml, String scheme, String schematron)
      POST /api/v1/check: checks a pain.001 or pain.008 document.
      Parameters:
      xml - the document as XML text
      scheme - comma-separated scheme profiles to add, or null
      schematron - a Schematron preset (sepa, fednow, cbpr), or null
      Returns:
      the rungs run and their findings
    • faces

      public List<FaceInfo> faces()
      GET /api/v1/faces: the faces the server can project to.
      Returns:
      each face's name, description and required bindings
    • projectFace

      public FaceResponse projectFace(String face, String xml)
      POST /api/v1/faces/{face} with the edition detected and no bindings.
      Parameters:
      face - a face name from faces(), for example berlin_group
      xml - the pain.001 document as XML text
      Returns:
      the projected payload and its loss report
      Throws:
      IllegalArgumentException - when face is not a plain name
    • projectFace

      public FaceResponse projectFace(String face, String xml, String version, Map<String,?> bindings)
      POST /api/v1/faces/{face}: projects a pain.001 document onto a target standard.
      Parameters:
      face - a face name from faces(), for example berlin_group
      xml - the pain.001 document as XML text
      version - the pain.001 edition, or null to detect it from the namespace
      bindings - 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 - when face is 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 example GET
      path - 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 a RetryPolicy applies)