diff --git a/Documentation/all_in_one.md b/Documentation/all_in_one.md new file mode 100644 index 0000000000000000000000000000000000000000..0e3cb313969771b585dc59379148d1669ba03a1a --- /dev/null +++ b/Documentation/all_in_one.md @@ -0,0 +1,16 @@ +# Example + +```csharp +async Task AbstractCall() { + var client = new Client( + FitConnectEndpoints.Create(FitConnectEndpoints.EndpointType.Development), + "clientId", "clientSecret"); + + var success = await client.SendSubmissionAsync(new Submission()); + + var submissions = await client.GetSubmissionsAsync("destinationId"); + + foreach (var submission in submissions) Console.WriteLine(submission.Id); +} + +``` diff --git a/Documentation/detailed_calls.md b/Documentation/detailed_calls.md new file mode 100644 index 0000000000000000000000000000000000000000..27299ca1d0d7af2fcc2900d20680782e755b2f82 --- /dev/null +++ b/Documentation/detailed_calls.md @@ -0,0 +1,30 @@ +# Example + +## Sender + +```csharp +void DetailSenderCall() { + var sender = + new Sender( + FitConnectEndpoints.Create(FitConnectEndpoints.EndpointType.Development)); + sender.CreateSubmissionDto(new Submission()); + /* + .... + */ +} + +``` + +## Subscriber + +```csharp +async Task DetailSubscriberCall() { + var subscriber = + new Subscriber( + FitConnectEndpoints.Create(FitConnectEndpoints.EndpointType.Development)); + var submissions = await subscriber.GetSubmissionsAsync("destinationId"); + /* + .... + */ +} +``` \ No newline at end of file diff --git a/Documentation/documentation.md b/Documentation/documentation.md index abf547283ee95acd8534a696bcb96fbd5e63fe25..14b6b79b9654aec43a254f11fdefd8d4e1112eda 100644 --- a/Documentation/documentation.md +++ b/Documentation/documentation.md @@ -2,6 +2,84 @@ ## Introduction -## Examples +The SDK supports a high-level support as well as a low-level support for the +FitConnect API and a fluent API. + +## All in one + +For not having to deal with the low-level API, the SDK provides a high-level support. + +### Sender + +```mermaid +flowchart TD + client([Create a new FitConnect client]) + send.submission[Create new Submission] + send.send[Send the submission] + send.return[\Return the result/] + + client-->send.submission-->send.send-->send.return + + + subscribe.request[Request submissions] + + client-->subscribe.request-->ToBeDefined +``` + +Simplified call: + +```csharp +bool SendSubmission(Submission submission){ + var client = new Client(...); + return client.SendSubmissionAsync(submission); +} +``` + +### Subscriber + +### Example + +Visit [All in one](./all_in_one.md) to see the code. + +## Fluent Api + +### Sender + +```mermaid +flowchart TD + client([Create a new FitConnect client]) + Sender[Call the Sender interface] + Authenticate + CreateSubmission + UploadAttachments + SendSubmission + + client-->Sender-->Authenticate-->CreateSubmission-->UploadAttachments-->SendSubmission +``` + +### Subscriber + +```mermaid +flowchart TD + client([Create a new FitConnect client]) + subscriber[Call the Subscriber interface] + get.submission["GetSubmissions(submissionId)"] + confirm[\Confirm the submission/] + + client-->subscriber-->authenticate-->PollSubmissions + authenticate-->GetSubmissions + authenticate-->get.submission-->GetAttachments-->DecryptAttachments-->DecryptData-->DecryptMetadata-->confirm +``` + +#### Polling available submissions + +#### Receiving list of submissions + +#### Receiving specific submission + +[Fluent Api Example](./fluent_api.md) + +## Detailed calls + +[Detailed calls](./detailed_calls.md) -[Examples](./example.md) diff --git a/Documentation/example.md b/Documentation/example.md deleted file mode 100644 index 033abed93f0aeb70fbb8a9f82f8decf61c3492d8..0000000000000000000000000000000000000000 --- a/Documentation/example.md +++ /dev/null @@ -1,71 +0,0 @@ -# Example - -```csharp -using FitConnect; -using FitConnect.Models; -``` - -## The easy way to call the FitConnect API - -```csharp -async Task AbstractCall() { - var client = new Client( - FitConnectEndpoints.Create(FitConnectEndpoints.EndpointType.Development), - "clientId", "clientSecret"); - - var success = await client.SendSubmissionAsync(new Submission()); - - var submissions = await client.GetSubmissionsAsync("destinationId"); - - foreach (var submission in submissions) Console.WriteLine(submission.Id); -} - -``` - -## The more verbose way to call the FitConnect API - -### The Fluent Sender Api call -```csharp -void FluentSenderCall() { - var client = - new Client(FitConnectEndpoints.Create(FitConnectEndpoints.EndpointType.Development), - logger: _logger); - client.Sender - .Authenticate(clientId, clientSecret) - .CreateSubmission(new Submission()) - .UploadAttachments(new List<Attachment>()) - .SendSubmission(new Metadata(), new Data()); -} -``` - -### Here to call the **Sender** interface - -```csharp -void DetailSenderCall() { - var sender = - new Sender( - FitConnectEndpoints.Create(FitConnectEndpoints.EndpointType.Development)); - sender.CreateSubmissionDto(new Submission()); - /* - .... - */ -} - -``` - -### Here to call the **Subscriber** interface - -```csharp - - -async Task DetailSubscriberCall() { - var subscriber = - new Subscriber( - FitConnectEndpoints.Create(FitConnectEndpoints.EndpointType.Development)); - var submissions = await subscriber.GetSubmissionsAsync("destinationId"); - /* - .... - */ -} - -``` \ No newline at end of file diff --git a/Documentation/fluent_api.md b/Documentation/fluent_api.md new file mode 100644 index 0000000000000000000000000000000000000000..2f5e4e95fdae5887052f275275688922cb892632 --- /dev/null +++ b/Documentation/fluent_api.md @@ -0,0 +1,42 @@ +# Example + +## Sender + +```csharp +client.Sender + .Authenticate(clientId!, clientSecret!) + .CreateSubmission(new Submission { Attachments = new List<Attachment>() }) + .UploadAttachments() + .SendSubmission(new Metadata(), new Data()); +``` + +## Subscriber + +### Polling available submissions + +```csharp +client.Subscriber + .Authenticate(clientId!, clientSecret!) + .PollSubmissions("destinationId", out var _) +``` + +### Getting list of submissions + +```csharp +client.Subscriber + .Authenticate(clientId!, clientSecret!) + .GetSubmissions("destinationId", out var _) +``` + +### Reading specific submission + +```csharp +client.Subscriber + .Authenticate(clientId!, clientSecret!) + .GetSubmission("destinationId", "submissionId", out var _) + .GetAttachments(out var _) + .DecryptAttachments(out var _) + .DecryptData(out var _) + .DecryptMetadata(out var _) + .ConfirmSubmission(); +```