Skip to content
Snippets Groups Projects
Commit 184b10ae authored by Patrik Paško's avatar Patrik Paško
Browse files

Merge branch 'develop' into 'master'

- added generic requests

See merge request digital-twin/twinzo/tdevkit!41
parents d8373101 21c42ba8
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
......@@ -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
......
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();
......

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);
}
}
}
......@@ -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>
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment