From 6a50ac921b11a29ff6c01a63c98ae795ca52f1e1 Mon Sep 17 00:00:00 2001 From: Martin Vogel <martin.vogel@sinc.de> Date: Fri, 16 Sep 2022 11:19:50 +0200 Subject: [PATCH] refactor(docu): add demo example calls --- README.md | 58 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 49c7f48e3..decd06eb9 100644 --- a/README.md +++ b/README.md @@ -68,47 +68,51 @@ _The following steps show how to get the SDK running_ var config = ApplicationConfigLoader.loadConfig("absolute/path/to/config.yml"); var senderClient = ClientFactory.senderClient(config); ```` - -<p align="right">(<a href="#top">back to top</a>)</p> - -### External Configuration - -Configuration properties e.g. for REST-API urls and proxy settings can be found in the YAML config ``config.yml`` within the root folder of the project. - -In order to run the SDK client a configuration needs to be provided as file in the same path as the jar (e.g. when the commandline client is used) or via reference using the environment variable ``FIT_CONNECT_CONFIG`` (e.g. when the SDK is used programmatically). - + <p align="right">(<a href="#top">back to top</a>)</p> ## Usage -#### Sending +### Hand in new submission ```java +ClientFactory.senderClient(config) + .newSubmission() + .withAttachment(Path.of("path/to/attachment.txt").toFile()) // optional + .withJsonData("{ foo: 'bar'}") + .withDestination(UUID.fromString("destinationId")) + .withServiceType("TestService", "Führerscheinbeantragung", "urn:de:fim:leika:leistung:99400048079000") + .submit(); +``` -List<File> attachments = ... // Load e.g from local file system - - ClientFactory.senderClient() - .withDestination(UUID.randomUUID()) - .withServiceType("ServiceName", "leika:key:service") - .withAttachments(attachments) - .withJsonData("{ caseSpecific: 'Data' }") +### Hand in already encrypted submission (e.g. from frontend) + +```java +ClientFactory.senderClient(config) + .newSubmissionWithEncryptedData("$encrpyt€ed d@t@") + .withEncryptedAttachment(UUID.fromString("attachmentId"), "$encrpyt€ed @tt@chment") + .withEncryptedJsonData("{$encrpyt€ed json}") + .withEncryptedMetadata("$encrpyt€ed metadata") + .withDestination(UUID.fromString("destinationId")) + .withServiceType("TestService", "Führerscheinbeantragung", "urn:de:fim:leika:leistung:99400048079000") .submit(); ``` -#### Subscribing +### Retrieve public encryption key ```java +Optional<String> jweKey = ClientFactory.subscriberClient(config).getPublicKey(UUID.fromString("destinationId")); +``` - var client = ClientFactory.subscriberClient(); +### List all submissions for a destination - var submissions = client.getAvailableSubmissions(destinationId); - - var submissionId = ... // filter submission list for requested one ... - - var submission = client.requestSubmission(submissionId) - submission.getAttachments(); - submission.getMetadata(); - submission.getData(); +```java +Set<SubmissionForPickup> submissions = ClientFactory.subscriberClient(config).getAvailableSubmissions(UUID.fromString("destinationId")); +``` +### Receive single submission + +```java +Optional<ReceivedSubmission> submission = ClientFactory.subscriberClient(config).requestSubmission(UUID.fromString("destinationId")); ``` <p align="right">(<a href="#top">back to top</a>)</p> -- GitLab