diff --git a/DummyClient/DummyClient.csproj b/DummyClient/DummyClient.csproj index 19a06c7b74efeeb14ad19ee6669c555a54ee35d8..63a4a9668b6b05f9f8b1f69a46226f7e9a9a2623 100644 --- a/DummyClient/DummyClient.csproj +++ b/DummyClient/DummyClient.csproj @@ -17,4 +17,10 @@ <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" /> </ItemGroup> + <ItemGroup> + <None Update="Test.pdf"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </None> + </ItemGroup> + </Project> diff --git a/DummyClient/Program.cs b/DummyClient/Program.cs index a03392e17bcf968517fb625105b9a019572210ff..df66cb892359ede6cf5de492a9ae22ed3789b7fc 100644 --- a/DummyClient/Program.cs +++ b/DummyClient/Program.cs @@ -4,27 +4,34 @@ using FitConnect.Models; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; -var clientId = ""; -var clientSecret = ""; -PublicKey publicKey; ILogger _logger; Client client; X509Certificate2 certificate; +var destinationId = "aa3704d6-8bd7-4d40-a8af-501851f93934"; +var leikaKey = "urn:de:fim:leika:leistung:99400048079000"; +var clientSecret = "rdlXms-4ikO47AbTmmCTdzFoE4cTSt13JmSbcY5Dhsw"; +var clientId = "73a8ff88-076b-4263-9a80-8ebadac97b0d"; void FluentSenderCall() { - client.GetSender() - .WithDestination("destinationId") - .WithServiceType("", "") - .WithAttachments(Array.Empty<Attachment>()) + + new Client( + FitConnectEndpoints.Create(FitConnectEndpoints.EndpointType.Development), + clientId, clientSecret, + logger: _logger).GetSender() + .WithDestination(destinationId) + .WithServiceType("ServiceName", leikaKey) + .WithAttachments(new List<Attachment>() { + new Attachment { + Id = Guid.NewGuid().ToString(), + Content = File.ReadAllBytes("Test.pdf"), + MimeType = "application/pdf", + Description = "The description of the attachment", + Purpose = "attachment" + } + }) .WithData("{\"data\":\"value\"}") .Submit(); - - client.GetSender() - .WithDestination("destinationId") - .WithServiceType("", "") - .WithAttachments(Array.Empty<Attachment>()) - .Submit(); } void FluentSubscriberCall() { @@ -38,23 +45,23 @@ void FluentSubscriberCall() { }); } -var logger = LoggerFactory.Create( +_logger = LoggerFactory.Create( builder => { builder.AddSimpleConsole(); builder.SetMinimumLevel(LogLevel.Information); }).CreateLogger("FluentSenderTests"); -logger.Log(LogLevel.Information, +_logger.Log(LogLevel.Information, "This is a dummy client to demonstrate the usage of the FIT-Connect SDK for .NET"); client = new Client( FitConnectEndpoints.Create(FitConnectEndpoints.EndpointType.Development), - "clientId", "clientSecret", - logger: logger); + clientId, clientSecret, + logger: _logger); Console.WriteLine( "This is a dummy client to demonstrate the usage of the FIT-Connect SDK for .NET"); FluentSenderCall(); -FluentSubscriberCall(); +// FluentSubscriberCall(); diff --git a/DummyClient/Test.pdf b/DummyClient/Test.pdf new file mode 100644 index 0000000000000000000000000000000000000000..50a038977b732f8c86889b164166410d5d60e0de Binary files /dev/null and b/DummyClient/Test.pdf differ diff --git a/FitConnect/FluentSender.cs b/FitConnect/FluentSender.cs index 435d19d554b97b41d1070ce313992c34bd6b7d3b..90d2a71b851d681c28f5100945aef44496d24582 100644 --- a/FitConnect/FluentSender.cs +++ b/FitConnect/FluentSender.cs @@ -26,7 +26,8 @@ namespace FitConnect; /// .Authenticate(clientId!, clientSecret!) /// .CreateSubmission(new Submission { Attachments = new List() }) /// .UploadAttachments() -/// .SendSubmission(new Metadata(), new Data()); +/// .WithData(data) +/// .Subm@it(); /// </code> /// </example> public class FluentSender : Sender, IFluentSender, IFluentSenderWithDestination, diff --git a/FitConnect/Models/Attachment.cs b/FitConnect/Models/Attachment.cs index d51ee26ab40566f8e249929d285ae6e74225be11..8d1a1cc1bc06a8cf14063aea573985a10c30ad1b 100644 --- a/FitConnect/Models/Attachment.cs +++ b/FitConnect/Models/Attachment.cs @@ -6,7 +6,7 @@ using FitConnect.Models.Api.Metadata; namespace FitConnect.Models; public class Attachment { - public string? Id { get; init; } + public string Id { get; init; } public byte[]? Content { get; init; }