diff --git a/Main/Program.cs b/Main/Program.cs index e90d304a630ca5806a13ffef70a7d02b9993b568..0cb61f649ae22d30247c61b31350164273d6719e 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/README.md b/README.md index 4f64a2a4936095678a5878c688be6d879682d38f..d2f830f385becdff9a0095eb1b021e610abac747 100644 --- a/README.md +++ b/README.md @@ -242,6 +242,11 @@ await devkitConnector.AddSensorData(sensorContracts); * `GetDemoFile(fileName)` - Get byte representation of the specified demo file * `GetUnityLastVersion(platform)` - Get the last version of the Unity app * `GetUnityBundleInfo(bundleName)` - Get information (version, size, name) about the Unity Bundle + * **Generic methods** + * `Get(string subUrl)` + * `Post(string subUrl, object body)` + * `Patch(string subUrl, object body)` + * `Delete(string subUrl)` ## Future features - **protobuffers** serialization diff --git a/SDK/Connection/DevkitConnector.cs b/SDK/Connection/DevkitConnector.cs index 540498ab3300643a8d7d7fb330168975aaccfd6e..044459824295ad63b781fa723343e9b230933e7a 100644 --- a/SDK/Connection/DevkitConnector.cs +++ b/SDK/Connection/DevkitConnector.cs @@ -1,5 +1,6 @@ using SDK.Exceptions; using System; +using System.Net; using System.Net.Http; using System.Text; using System.Text.Json; @@ -32,6 +33,7 @@ namespace SDK { this.connectionOptions = connectionOptions; this.httpClient = httpClient; + this.httpClient.DefaultRequestVersion = HttpVersion.Version30; httpClient.BaseAddress = new Uri(connectionOptions.Url + "/" + connectionOptions.Version + "/"); ResetHttpClientHeaders(); diff --git a/SDK/Connection/V3/Utils.cs b/SDK/Connection/V3/Utils.cs index 8905ca41ce7d686374d27244cfdc7ffe5c94fc34..50ec82f94e1034b1a5988d5449210e239881fdc2 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,50 @@ namespace SDK return response; } + + /// <summary> + /// Generic GET request + /// </summary> + /// <typeparam name="T">Returns type of T</typeparam> + /// <param name="subUrl"></param> + /// <returns></returns> + public async Task<T> Get<T>(string subUrl) + { + return await GetRequest<T>(subUrl); + } + + /// <summary> + /// Generic POST request + /// </summary> + /// <typeparam name="T">Returns type of T</typeparam> + /// <param name="subUrl"></param> + /// <param name="body"></param> + /// <returns></returns> + public async Task<T> Post<T>(string subUrl, object body) + { + return await PostRequest<T>(subUrl, body); + } + + /// <summary> + /// Generic PATCH request + /// </summary> + /// <typeparam name="T"></typeparam> + /// <param name="subUrl"></param> + /// <param name="body"></param> + /// <returns></returns> + public async Task Patch(string subUrl, object body) + { + await PatchRequest(subUrl, body); + } + + /// <summary> + /// Generic DELETE request + /// </summary> + /// <param name="subUrl"></param> + /// <returns></returns> + public async Task Delete(string subUrl) + { + await DeleteRequest(subUrl); + } } } diff --git a/SDK/SDK.csproj b/SDK/SDK.csproj index 8571b4cd71593475248074df825436d0cbaee2b3..e89d2af42d89719a712228a176ea7f13f76200bd 100644 --- a/SDK/SDK.csproj +++ b/SDK/SDK.csproj @@ -5,7 +5,7 @@ <TargetFramework>net8.0</TargetFramework> <AssemblyVersion>2021.6.28.25</AssemblyVersion> <FileVersion>2021.6.28.25</FileVersion> - <Version>4.11.0</Version> + <Version>4.12.0</Version> <GeneratePackageOnBuild>true</GeneratePackageOnBuild> </PropertyGroup> diff --git a/tDevkit.sln b/tDevkit.sln index a1f2e0b1f7a5a738d64907bbd2ee7a6ac91f64a1..c473bc29c25b369a300f350ebbdd2d8ecd4336f8 100644 --- a/tDevkit.sln +++ b/tDevkit.sln @@ -9,6 +9,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Test", "Test\Test\Test.cspr EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Main", "Main\Main.csproj", "{E30C5B8F-0CA9-4947-8D83-95DC4612F4E1}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5BFAF4E7-6401-497C-B5F3-EF757BD49BDB}" + ProjectSection(SolutionItems) = preProject + README.md = README.md + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU