From 081787f692445ba4aac254d3507eeb4ffdf2d0e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrik=20Pa=C5=A1ko?= <patrik.pasko@twinzo.eu> Date: Thu, 1 Aug 2024 17:32:54 +0000 Subject: [PATCH] Develop --- README.md | 14 +++++++------- SDK/Connection/V3/Areas.cs | 6 +++--- SDK/Connection/V3/Beacons.cs | 10 +++------- SDK/Connection/V3/Devices.cs | 11 ++++------- SDK/Connection/V3/Layers.cs | 6 +++--- SDK/Connection/V3/Sectors.cs | 11 ++++------- SDK/Connection/V3/Sensors.cs | 10 +++------- SDK/Connection/V3/Shifts.cs | 10 +++------- SDK/SDK.csproj | 2 +- Test/Test/V3/Areas.cs | 2 +- Test/Test/V3/Layers.cs | 2 +- Test/Test/V3/Shifts.cs | 2 +- 12 files changed, 34 insertions(+), 52 deletions(-) diff --git a/README.md b/README.md index ac33cb7..43ec1ee 100644 --- a/README.md +++ b/README.md @@ -184,7 +184,7 @@ await devkitConnector.AddSensorData(sensorContracts); * `GetAreas()` - Get all areas * `GetArea(id)` - Get area by ID * `AddArea(areaContract)` - Add an area with specified properties - * `UpdateArea(areaContract)` - Update an existing area with new properties + * `UpdateArea(id, areaContract)` - Update an existing area with new properties * `DeleteArea(id)` - Delete an existing area by ID * **Authorization** * `Authenticate(login, password)` - Authenticate with login and password as user/device/sensor @@ -192,7 +192,7 @@ await devkitConnector.AddSensorData(sensorContracts); * `GetBeacons()` - Get all beacons * `GetBeacon(id)` - Get beacon by ID * `AddBeacon(beaconContract)` - Add a beacon with specified properties - * `UpdateBeacon(beaconContract)` - Update an existing beacon with new properties + * `UpdateBeacon(id, beaconContract)` - Update an existing beacon with new properties * `DeleteBeacon(id)` - Delete an existing beacon by ID * **Branches** * `GetBranches()` - Get all branches @@ -210,7 +210,7 @@ await devkitConnector.AddSensorData(sensorContracts); * `GetDynamicDevices()` - Get devices with dynamic position * `GetDynamicDevicesShort()` - Get shortened form of dynamic devices grouped by sectors * `AddDevice(deviceContract)` - Add a device with specified properties - * `UpdateDevice(deviceContract)` - Update an existing device with new properties + * `UpdateDevice(id, deviceContract)` - Update an existing device with new properties * `DeleteDevice(id)` - Delete an existing device by ID * **Layers** * `GetLayers()` - Get all layers @@ -218,7 +218,7 @@ await devkitConnector.AddSensorData(sensorContracts); * `GetNoGoLayers()` - Get all NoGo Layers * `GetLocalizationLayers(deviceLogin)` - Get all localization layers for specified device * `AddLayer(layerContract)` - Add a layer with specified properties - * `UpdateLayer(layerContract)` - Update an existing layer with new properties + * `UpdateLayer(id, layerContract)` - Update an existing layer with new properties * `DeleteLayer(id)` - Delete an existing layer by ID * **Localization** * `AddLocalizationData(deviceLocationContract)` - Add localization data for multiple devices in batch mode @@ -233,14 +233,14 @@ await devkitConnector.AddSensorData(sensorContracts); * `GetSectors()` - Get all sectors * `GetSector(id)` - Get sector by ID * `AddSector(sectorContract)` - Add a sector with specified properties - * `UpdateSector(sectorContract)` - Update an existing sector with new properties + * `UpdateSector(id, sectorContract)` - Update an existing sector with new properties * `DeleteSector(id)` - Delete an existing sector by ID * **Sensors** * `GetSensors()` - Get all sensors * `GetSensor(id)` - Get sensor by ID * `GetSensor(login)` - Get sensor by login * `AddSensor(sensorContract)` - Add a sensor with specified properties - * `UpdateSensor(sensorContract)` - Update an existing sensor with new properties + * `UpdateSensor(id, sensorContract)` - Update an existing sensor with new properties * `DeleteSensor(id)` - Delete an existing sensor by ID * `AddSensorData(sensors)` - Add sensor data for multiple sensors in batch mode * `AddSensorData(sensorData)` - Add sensor data for single sensor (in order to do this you need to be **authenticated** as said sensor - this can be avoided when using the batch mode above - [Example](#sensor-data)) @@ -249,7 +249,7 @@ await devkitConnector.AddSensorData(sensorContracts); * `GetShifts()` - Get all shifts * `GetShift(id)` - Get shift by ID * `AddShift(shiftContract)` - Add a shift with specified properties - * `UpdateShift(shiftContract)` - Update an existing shift with new properties + * `UpdateShift(id, shiftContract)` - Update an existing shift with new properties * `DeleteShift(id)` - Delete an existing shift by ID * **Users** * `GetUserInfo()` - Get information about the current user (in order to do this you need to be **authenticated** as said user) diff --git a/SDK/Connection/V3/Areas.cs b/SDK/Connection/V3/Areas.cs index c7ea269..c764679 100644 --- a/SDK/Connection/V3/Areas.cs +++ b/SDK/Connection/V3/Areas.cs @@ -24,10 +24,10 @@ namespace SDK return await PostRequest<AreaContract>(subUrl, area); } - public async Task UpdateArea(AreaContract area) + public async Task UpdateArea(int id, object changes) { - string subUrl = Address.UrlCombine(Address.Areas, Convert.ToString(area.Id)); - await PatchRequest<AreaContract>(subUrl, area); + string subUrl = Address.UrlCombine(Address.Areas, id.ToString()); + await PatchRequest(subUrl, changes); } public async Task DeleteArea(int id) diff --git a/SDK/Connection/V3/Beacons.cs b/SDK/Connection/V3/Beacons.cs index bca92c8..4f7400f 100644 --- a/SDK/Connection/V3/Beacons.cs +++ b/SDK/Connection/V3/Beacons.cs @@ -36,14 +36,10 @@ namespace SDK return (BeaconContract)response; } - public async Task UpdateBeacon(BeaconContract beaconContract) + public async Task UpdateBeacon(int id, object changes) { - if (beaconContract.Id == 0) - { - throw new BadRequestException(NotFoundException.message + " Beacon object has no Id."); - } - string subUrl = Address.UrlCombine(Address.Beacons, Convert.ToString(beaconContract.Id)); - await PatchRequest<string>(subUrl, beaconContract); + string subUrl = Address.UrlCombine(Address.Beacons, id.ToString()); + await PatchRequest(subUrl, changes); } public async Task DeleteBeacon(int id) diff --git a/SDK/Connection/V3/Devices.cs b/SDK/Connection/V3/Devices.cs index da60a2a..1036ddb 100644 --- a/SDK/Connection/V3/Devices.cs +++ b/SDK/Connection/V3/Devices.cs @@ -4,6 +4,7 @@ using SDK.Exceptions; using SDK.Models; using System; using System.Net.Http; +using System.Threading.Channels; using System.Threading.Tasks; namespace SDK @@ -55,14 +56,10 @@ namespace SDK return await PostRequest<DeviceContract>(subUrl, deviceContract); } - public async Task UpdateDevice(DeviceContract deviceContract) + public async Task UpdateDevice(int id, object changes) { - if (deviceContract.Id == 0) - { - throw new BadRequestException(NotFoundException.message + " Device object has no Id."); - } - string subUrl = Address.Devices + deviceContract.Id; - await PatchRequest(subUrl, deviceContract); + string subUrl = Address.UrlCombine(Address.Devices, id.ToString()); + await PatchRequest(subUrl, changes); } public async Task DeleteDevice(int id) diff --git a/SDK/Connection/V3/Layers.cs b/SDK/Connection/V3/Layers.cs index 5fb8842..181c470 100644 --- a/SDK/Connection/V3/Layers.cs +++ b/SDK/Connection/V3/Layers.cs @@ -56,10 +56,10 @@ namespace SDK return response; } - public async Task UpdateLayer(LayerContract layer) + public async Task UpdateLayer(int id, object changes) { - string subUrl = Address.UrlCombine(Address.Layers, Convert.ToString(layer.Id)); - await PatchRequest<LayerContract>(subUrl, layer); + string subUrl = Address.UrlCombine(Address.Layers, id.ToString()); + await PatchRequest(subUrl, changes); } public async Task DeleteLayer(int id) diff --git a/SDK/Connection/V3/Sectors.cs b/SDK/Connection/V3/Sectors.cs index b4a08b5..a1b5391 100644 --- a/SDK/Connection/V3/Sectors.cs +++ b/SDK/Connection/V3/Sectors.cs @@ -2,6 +2,7 @@ using SDK.Exceptions; using SDK.Models; using System; +using System.Threading.Channels; using System.Threading.Tasks; namespace SDK @@ -37,14 +38,10 @@ namespace SDK return (SectorContract)response; } - public async Task UpdateSector(SectorContract sectorContract) + public async Task UpdateSector(int id, object changes) { - if (sectorContract.Id == 0) - { - throw new BadRequestException(NotFoundException.message + " Sector object has no Id."); - } - string subUrl = Address.UrlCombine(Address.Sectors, Convert.ToString(sectorContract.Id)); - await PatchRequest<string>(subUrl, sectorContract); + string subUrl = Address.UrlCombine(Address.Sectors, id.ToString()); + await PatchRequest(subUrl, changes); } public async Task DeleteSector(int id) diff --git a/SDK/Connection/V3/Sensors.cs b/SDK/Connection/V3/Sensors.cs index cabeafa..e3903a4 100644 --- a/SDK/Connection/V3/Sensors.cs +++ b/SDK/Connection/V3/Sensors.cs @@ -43,14 +43,10 @@ namespace SDK return (SensorContract)response; } - public async Task UpdateSensor(SensorContract sensorContract) + public async Task UpdateSensor(int id, object changes) { - if (sensorContract.Id == 0) - { - throw new BadRequestException(NotFoundException.message + " Sensor object has no Id."); - } - string subUrl = Address.UrlCombine(Address.Sensors, Convert.ToString(sensorContract.Id)); - await PatchRequest(subUrl, sensorContract); + string subUrl = Address.UrlCombine(Address.Sensors, id.ToString()); + await PatchRequest(subUrl, changes); } public async Task DeleteSensor(int id) { diff --git a/SDK/Connection/V3/Shifts.cs b/SDK/Connection/V3/Shifts.cs index 8ed4a31..1a6ec6f 100644 --- a/SDK/Connection/V3/Shifts.cs +++ b/SDK/Connection/V3/Shifts.cs @@ -39,14 +39,10 @@ namespace SDK return (ShiftContract)response; } - public async Task UpdateShift(ShiftContract shiftContract) + public async Task UpdateShift(int id, object changes) { - if (shiftContract.Id == 0) - { - throw new BadRequestException(NotFoundException.message + " Shift object has no Id."); - } - string subUrl = Address.UrlCombine(Address.Shifts, Convert.ToString(shiftContract.Id)); - await PatchRequest<string>(subUrl, shiftContract); + string subUrl = Address.UrlCombine(Address.Shifts, id.ToString()); + await PatchRequest(subUrl, changes); } public async Task DeleteShift(int id) diff --git a/SDK/SDK.csproj b/SDK/SDK.csproj index 76f74b5..c1c2a0e 100644 --- a/SDK/SDK.csproj +++ b/SDK/SDK.csproj @@ -13,7 +13,7 @@ <TargetFrameworks Condition="'$(TargetFrameworkOverride)' != ''">$(TargetFrameworkOverride)</TargetFrameworks> <AssemblyVersion>2021.6.28.25</AssemblyVersion> <FileVersion>2021.6.28.25</FileVersion> - <Version>5.5.4</Version> + <Version>5.6.0</Version> <GeneratePackageOnBuild>true</GeneratePackageOnBuild> </PropertyGroup> diff --git a/Test/Test/V3/Areas.cs b/Test/Test/V3/Areas.cs index 058d2fb..076800e 100644 --- a/Test/Test/V3/Areas.cs +++ b/Test/Test/V3/Areas.cs @@ -60,7 +60,7 @@ namespace Test.V3 server.Given(Request.Create().WithPath(PATH_BASE + AREAS + "/" + bodyContent.Id).UsingPatch()) .RespondWith(Response.Create().WithStatusCode(200).WithBodyAsJson(bodyContent)); - await devkitConnector.UpdateArea(bodyContent); + await devkitConnector.UpdateArea(bodyContent.Id, bodyContent); Assert.IsTrue(true); } diff --git a/Test/Test/V3/Layers.cs b/Test/Test/V3/Layers.cs index 570308f..7e536cc 100644 --- a/Test/Test/V3/Layers.cs +++ b/Test/Test/V3/Layers.cs @@ -86,7 +86,7 @@ namespace Test.V3 .RespondWith(Response.Create().WithStatusCode(200) .WithBodyAsJson(layer)); - await devkitConnector.UpdateLayer(layer); + await devkitConnector.UpdateLayer(layer.Id, layer); } [TestCategory("Layer")] diff --git a/Test/Test/V3/Shifts.cs b/Test/Test/V3/Shifts.cs index 9388b0d..824ac50 100644 --- a/Test/Test/V3/Shifts.cs +++ b/Test/Test/V3/Shifts.cs @@ -61,7 +61,7 @@ namespace Test.V3 server.Given(Request.Create().WithPath(PATH_BASE + SHIFTS + "/" + bodyContent.Id).UsingPatch()) .RespondWith(Response.Create().WithStatusCode(200)); - await devkitConnector.UpdateShift(bodyContent); + await devkitConnector.UpdateShift(bodyContent.Id, bodyContent); Assert.IsTrue(true); } -- GitLab