From 81d04700010b2c4034825707d672892f441b2d80 Mon Sep 17 00:00:00 2001
From: Patrik Pasko <patrik.pasko@twinzo.eu>
Date: Wed, 3 Jul 2024 15:14:01 +0200
Subject: [PATCH] generic methods added

---
 Main/Program.cs            |  2 +-
 SDK/Connection/V3/Utils.cs | 52 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 1 deletion(-)

diff --git a/Main/Program.cs b/Main/Program.cs
index e90d304..0cb61f6 100644
--- a/Main/Program.cs
+++ b/Main/Program.cs
@@ -80,7 +80,7 @@ namespace Main
                     Login = "buffer",
                     SensorData = dataList.ToArray(),
                 };
-
+                
                 // Send sensor with specified data to Twinzo server
                 PostResponseContract[] response = await devkitConnector.AddSensorData(new[] { sensor });
                 Console.WriteLine(response);
diff --git a/SDK/Connection/V3/Utils.cs b/SDK/Connection/V3/Utils.cs
index 8905ca4..5d0eafa 100644
--- a/SDK/Connection/V3/Utils.cs
+++ b/SDK/Connection/V3/Utils.cs
@@ -1,6 +1,7 @@
 
 using SDK.Contracts.Data;
 using SDK.Models;
+using System;
 using System.Threading.Tasks;
 
 namespace SDK
@@ -51,5 +52,56 @@ namespace SDK
 
             return response;
         }
+
+        /// <summary>
+        /// Generic GET request
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="subUrl"></param>
+        /// <returns></returns>
+        public async Task<T> Get<T>(string subUrl)
+        {
+            var response = await GetRequest<T>(subUrl);
+
+            return response;
+        }
+
+        /// <summary>
+        /// Generic POST request
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="subUrl"></param>
+        /// <param name="body"></param>
+        /// <returns></returns>
+        public async Task<T> Post<T>(string subUrl, object body)
+        {
+            var response = await PostRequest<T>(subUrl, body);
+
+            return response;
+        }
+
+        /// <summary>
+        /// Generic PATCH request
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="subUrl"></param>
+        /// <param name="body"></param>
+        /// <returns></returns>
+        public async Task<T> Patch<T>(string subUrl, object body)
+        {
+            var response = await PatchRequest<T>(subUrl, body);
+
+            return response;
+        }
+
+        /// <summary>
+        /// Generic DELETE request
+        /// </summary>
+        /// <param name="subUrl"></param>
+        /// <returns></returns>
+        public async Task Delete(string subUrl)
+        {
+            await DeleteRequest(subUrl);
+        }
     }
 }
-- 
GitLab