From c502c22cec05b9e20851bd379a21238718cfe149 Mon Sep 17 00:00:00 2001
From: Klaus Fischer <klaus.fischer@eloware.com>
Date: Wed, 8 Jun 2022 10:53:32 +0200
Subject: [PATCH] Defined method names

---
 FitConnect/Interfaces/IBaseFunctionality.cs | 18 ++++++++--
 FitConnect/Interfaces/ISender.cs            | 37 ++++++++++++++++-----
 FitConnect/Interfaces/ISubscriber.cs        | 29 ++++++++++++----
 FitConnect/Subscriber.cs                    | 16 +++++----
 4 files changed, 74 insertions(+), 26 deletions(-)

diff --git a/FitConnect/Interfaces/IBaseFunctionality.cs b/FitConnect/Interfaces/IBaseFunctionality.cs
index e751f6c4..49eb075b 100644
--- a/FitConnect/Interfaces/IBaseFunctionality.cs
+++ b/FitConnect/Interfaces/IBaseFunctionality.cs
@@ -3,10 +3,22 @@ using FitConnect.Models;
 namespace FitConnect;
 
 public interface IBaseFunctionality {
+    /// <summary>
+    /// Get OAuth2 token for FitConnect API
+    /// The credentials can be created there:
+    /// https://portal.auth-testing.fit-connect.fitko.dev/login
+    /// </summary>
+    /// <param name="clientId">Your Client ID</param>
+    /// <param name="clientSecret">Your Client Secret</param>
+    /// <param name="scope">The scope of your API token</param>
+    /// <returns></returns>
     Task<OAuthAccessToken> GetTokenAsync(string clientId, string clientSecret,
         string? scope = null);
 
-    Task<SecurityEventToken> GetSetDataAsync();
 
-    // Receive SecurityEventToken and check signature
-}
\ No newline at end of file
+    /// <summary>
+    /// Receive the SET data
+    /// </summary>
+    /// <returns></returns>
+    Task<SecurityEventToken> GetSetDataAsync();
+}
diff --git a/FitConnect/Interfaces/ISender.cs b/FitConnect/Interfaces/ISender.cs
index 86307929..0ce07f52 100644
--- a/FitConnect/Interfaces/ISender.cs
+++ b/FitConnect/Interfaces/ISender.cs
@@ -1,15 +1,34 @@
 namespace FitConnect;
 
 public interface ISender : IBaseFunctionality {
-    // Check public keys
-    Task<bool> CheckPublicKeyAsync(string publicKey);
+    /// <summary>
+    /// Check public keys
+    /// </summary>
+    /// <returns></returns>
+    Task<bool> CheckPublicKeyAsync();
 
-    // Encrypt Data (Fachdaten)
-    byte[] EncryptDataAsync(string data, string publicKey);
 
-    // Encrypt attachments (Anhänge)
-    Task<string> EncryptAttachmentAsync(string attachment, string publicKey);
+    /// <summary>
+    /// Encrypt Data (Fachdaten)
+    /// </summary>
+    /// <param name="data"></param>
+    /// <returns></returns>
+    byte[] EncryptDataAsync(string data);
 
-    // Create Metadata incl. Hash
-    Task<string> CreateMetadataAsync(string data, string attachment, string publicKey);
-}
\ No newline at end of file
+
+    /// <summary>
+    /// Encrypt attachments (Anhänge)
+    /// </summary>
+    /// <param name="attachment"></param>
+    /// <returns></returns>
+    Task<byte[]> EncryptAttachmentAsync(byte[] attachment);
+
+
+    /// <summary>
+    /// Create Metadata incl. Hash
+    /// </summary>
+    /// <param name="data"></param>
+    /// <param name="attachment"></param>
+    /// <returns></returns>
+    Task<string> CreateMetadataAsync(string data, byte[] attachment);
+}
diff --git a/FitConnect/Interfaces/ISubscriber.cs b/FitConnect/Interfaces/ISubscriber.cs
index e39917f5..60cb7330 100644
--- a/FitConnect/Interfaces/ISubscriber.cs
+++ b/FitConnect/Interfaces/ISubscriber.cs
@@ -7,12 +7,16 @@ public interface ISubscriber : IBaseFunctionality {
     /// Decrypt Data (Fachdaten)
     /// </summary>
     /// <param name="data">(Fachdaten)</param>
-    /// <param name="privateKey">Your private key for decryption</param>
     /// <returns></returns>
-    Task<string> DecryptDataAsync(string data, string privateKey);
+    Task<byte[]> DecryptDataAsync(byte[] data);
 
-    // Decrypt attachments (Anhänge)
-    Task<string> DecryptAttachmentAsync(string attachment, string privateKey);
+
+    /// <summary>
+    /// Decrypt attachments (Anhänge)
+    /// </summary>
+    /// <param name="attachment">Encrypted attachments</param>
+    /// <returns></returns>
+    Task<byte[]> DecryptAttachmentAsync(byte[] attachment);
 
     /// <summary>
     /// Checks the validity of the given metadata against the schema.
@@ -21,10 +25,21 @@ public interface ISubscriber : IBaseFunctionality {
     /// <returns></returns>
     Task<bool> CheckMetadataAsync(string jsonMetaData);
 
-    // Check Hash from Metadata
+    /// <summary>
+    /// Check Hash from Metadata
+    /// </summary>
+    /// <param name="metadata">Metadata in JSON Format</param>
+    /// <returns></returns>
     Task<bool> CheckHashAsync(string metadata);
 
-    // Create SecurityEventToken and signature
+
+    /// <summary>
+    /// Create SecurityEventToken and signature
+    /// </summary>
+    /// <param name="data"></param>
+    /// <param name="attachment"></param>
+    /// <param name="privateKey"></param>
+    /// <returns></returns>
     Task<SecurityEventToken> CreateSecurityEventTokenAsync(string data, string attachment,
         string privateKey);
-}
\ No newline at end of file
+}
diff --git a/FitConnect/Subscriber.cs b/FitConnect/Subscriber.cs
index abe4b3ab..7b182347 100644
--- a/FitConnect/Subscriber.cs
+++ b/FitConnect/Subscriber.cs
@@ -10,13 +10,6 @@ public class Subscriber : FunctionalBaseClass, ISubscriber {
     public Subscriber(ILogger logger, FitConnectEndpoints endpoints) : base(logger, endpoints) {
     }
 
-    public async Task<string> DecryptDataAsync(string data, string privateKey) {
-        throw new NotImplementedException();
-    }
-
-    public async Task<string> DecryptAttachmentAsync(string attachment, string privateKey) {
-        throw new NotImplementedException();
-    }
 
     private async Task<string> GetContentFromEmbeddedResource(string filename) {
         var assembly = typeof(Subscriber).GetTypeInfo().Assembly;
@@ -32,6 +25,14 @@ public class Subscriber : FunctionalBaseClass, ISubscriber {
         }
     }
 
+    public async Task<byte[]> DecryptDataAsync(byte[] data) {
+        throw new NotImplementedException();
+    }
+
+    public async Task<byte[]> DecryptAttachmentAsync(byte[] attachment) {
+        throw new NotImplementedException();
+    }
+
     /// <summary>
     /// Checks the validity of the given metadata against the schema.
     /// </summary>
@@ -49,6 +50,7 @@ public class Subscriber : FunctionalBaseClass, ISubscriber {
         throw new NotImplementedException();
     }
 
+
     public async Task<SecurityEventToken> CreateSecurityEventTokenAsync(string data,
         string attachment, string privateKey) {
         throw new NotImplementedException();
-- 
GitLab