diff --git a/README.md b/README.md index ac33cb72374eedb98e04535912c606e1c2027665..43ec1ee72072ce83b26c05fc78a656a7154439b0 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 c7ea26923e429042941523e6cef533fb7d09061f..c764679dd8003e751fbdac27a7e41e1ff3572545 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 bca92c8d9c537e28bcafda5a21c53ed649fe9d17..4f7400f2d6789af95fb6847b4b24e9450989790e 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 da60a2a5133ecca991d5824d52bb8a37585baf33..1036ddbc43f71e3dd1b31059ac443451897dc3c7 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 5fb8842c20f45570559f56bb069f4cf12d03c6f9..181c47089d1fc9c36652b3177bb24cfb9182c092 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 b4a08b591d9168cfe4a9ad0be127c932afd45244..a1b539103602aeced2ff1fa706279c43a479fe36 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 cabeafa0a72636c662dec74bf3280caec5257ec9..e3903a4c6f367ea4c6b624cf4f2d9107c0c2a0f5 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 8ed4a310122383cec2bac150a744ed73e252a96f..1a6ec6fdfc0074b08c02d7d0ea1db695506d6732 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 76f74b5e8dc44dfeecc7b25cd7ffee8d6ef18c5d..c1c2a0ecd6863341a8005dd51157114f5592282a 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 058d2fb968e767f1526ec58537a4f7e9b3881949..076800e9cb6a7436061abdcf332e9df28d4689a0 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 570308fd3b3b53866eca3700ef7c9ea095b4d9d9..7e536cc5745e5b5b8a4759d147e0124644a74505 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 9388b0d27ba2c5782d54ccda2967d1860f0c362c..824ac50a344a35496899f256130f2176e231e6a4 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); }