# Structure ## Functional Diagram ```mermaid classDiagram class FitConnectClient{ FitConnectApiService } class FitConnectApiService{ CasesService DestinationService InfoService OAuthService RouteService } FitConnectClient ..> SubmissionSender : public FitConnectClient ..> SubmissionSubscriber : public SubmissionSender --|> FunctionalBaseClass SubmissionSubscriber --|> FunctionalBaseClass FunctionalBaseClass ..> FitConnectApiService : protected FitConnectApiService ..> RouteService : public FitConnectApiService ..> CasesService : public FitConnectApiService ..> DestinationService : public FitConnectApiService ..> InfoService : public FitConnectApiService ..> OAuthService : public RouteService --|> RestCallService : Inheritance CasesService --|> RestCallService : Inheritance DestinationService --|> RestCallService : Inheritance InfoService --|> RestCallService : Inheritance OAuthService --|> RestCallService : Inheritance ``` With that structure the user of the SDK is intended to see the following: (For easier reading all methods are shown sync) ```mermaid classDiagram class FitConnectClient { << Draft >> - Sender - Subscriber + SendSumission(submission) + GetSubmissions(offset, limit) + GetSubmission(id) } class Sender { << Draft >> + bool CheckPublicKey(string publicKey) + bool CheckPublicKey(byte[] publicKey) + string EncryptData(string? data) + string EncryptAttachment(byte[] attachment) + string CreateMetadata(string data, byte[] attachment) ??? * Pruefung von oeffentlichen Schluesseln und Zertifikatsketten + OCSP-Check * Verschluesselung von Fachdaten [JSON, XML] mittels JWE * Verschluesselung von Anhängen [Binaerdaten] mittels JWE * Korrekte Erzeugung eines Metadatensatzes inkl. Hashwerte } class Subscriber { << Draft >> + byte[] DecryptAttachment(string attachment) + SecurityEventToken CreateSecurityEventToken(string data, string attachment, string privateKey) + bool CheckMetadata(string metaData) + string DecryptData(string data) + bool CheckHash(string metaData, string hash) * Entschluesselung von Fachdaten [JSON oder XML] mittels JWE * Entschluesselung von Anhaengen [Binaerdaten] mittels JWE * Pruefung der empfangenen Metadaten gegen das zugehörige JSON-Schema * Pruefung der Hashwerte aus dem Metadatensatz. * SET-Erstellung inkl. Signaturerzeugung } class FunctionalBaseClass{ + GetOAuthTokenAsync(string clientId, string clientSecret, string? scope) + SecurityEventToken GetSetData() * SET-Empfang inkl. Signaturpruefung * Unterstuezung / Abstraktion der API-Nutzung * Abruf des OAuth-Tokens } FitConnectClient <--> Sender FitConnectClient <--> Subscriber Sender --|> FunctionalBaseClass Subscriber --|> FunctionalBaseClass ``` ## Class diagram ```mermaid classDiagram class Client{ } ``` ## Annotation The structure ensures an abstraction of the API calls for the user and a 'simple' way to change the API calls if a new version of the API is released. Currently the API call is not versioned and hard coded. ### Abstractions for API calls - The use of a dependency injection can be added to inject the API calls into the SDK. But is not yet implemented. - Another approach would be using a generic class for the API calls. ## Implementation ### Sender #### WithDestination(string destinationId) 1. Call server to check if the destination is valid. 2. Get public key for the destination and store the public key in the submission. 3. Create the submission to get the submissionId