From 66f6d4ddaee372c75d10ab63e1b26e4671946135 Mon Sep 17 00:00:00 2001 From: Klaus Fischer <klaus.fischer@eloware.com> Date: Mon, 27 Jun 2022 11:58:17 +0200 Subject: [PATCH] ReAdded explicit confirm --- DummyClient/Program.cs | 52 +++-------------------------- FitConnect/Interfaces/IFluentApi.cs | 3 +- 2 files changed, 6 insertions(+), 49 deletions(-) diff --git a/DummyClient/Program.cs b/DummyClient/Program.cs index 59c40192..631e14d1 100644 --- a/DummyClient/Program.cs +++ b/DummyClient/Program.cs @@ -11,21 +11,6 @@ ILogger _logger; Client client; X509Certificate2 certificate; -/* - * The easy way to call the FitConnect API - */ -async Task AbstractCall() { - 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); -} - void FluentSenderCall() { client.Sender @@ -46,39 +31,10 @@ void FluentSubscriberCall() { .GetAvailableSubmissions(); client.Subscriber.RequestSubmission("submissionId") - .GetAttachments(); -} - -/* - * The more verbose way to call the FitConnect API - * Here to call the **Sender** interface - */ -async Task DetailSenderCall() { - var sender = - Sender.Create( - FitConnectEndpoints.Create(FitConnectEndpoints.EndpointType.Development), certificate); - - var submissionDto = sender.AddSubmission(new Submission()); - var encryptedAttachments = sender.Encrypt(publicKey, new List<Attachment>()); - var success = await sender.UploadAttachmentsAsync(encryptedAttachments); - var encryptedMetadata = sender.Encrypt(publicKey, new Metadata()); - var encryptedData = sender.Encrypt(publicKey, new Data()); - success = await sender.SubmitAsync(encryptedData, encryptedMetadata); -} - -/* - * The more verbose way to call the FitConnect API - * Here to call the **Subscriber** interface - */ - -async Task DetailSubscriberCall() { - var subscriber = - Subscriber.Create( - FitConnectEndpoints.Create(FitConnectEndpoints.EndpointType.Development), certificate); - var submissions = await subscriber.GetSubmissionsAsync("destinationId"); - /* - .... - */ + .GetAttachments((attachments => { + // Check if the attachments are valid + return true; + })); } diff --git a/FitConnect/Interfaces/IFluentApi.cs b/FitConnect/Interfaces/IFluentApi.cs index 8dc63796..7c202199 100644 --- a/FitConnect/Interfaces/IFluentApi.cs +++ b/FitConnect/Interfaces/IFluentApi.cs @@ -36,7 +36,8 @@ public interface IFluentSubscriber { public interface IFluentSubscriberWithSubmission { public Submission Submission { get; } - public IEnumerable<Attachment> GetAttachments(); + public IFluentSenderWithAttachments GetAttachments( + Func<IEnumerable<Attachment>, bool> canSubmitSubmission); public void ConfirmSubmission(string submissionId); } -- GitLab