MC Update all controller for better swagger doc (Location to Place, State to AutomationState and Widget to ScreenWidget) + change type auth response type ! + clean code

This commit is contained in:
Thomas Fransolet 2021-03-30 19:12:35 +02:00
parent 9c5bc07531
commit 2f10433f94
98 changed files with 4756 additions and 4508 deletions

View File

@ -23,12 +23,12 @@ namespace MyCore.Framework.Business
if (string.IsNullOrWhiteSpace(email)) if (string.IsNullOrWhiteSpace(email))
{ {
_logger.LogError($"Authenticate error: No e-mail provided"); _logger.LogError($"Authenticate error: No e-mail provided");
throw new RequestException(StatusCodes.Status401Unauthorized, "Authentication error"); throw new UnauthorizedAccessException("Authentication error");
} }
if (string.IsNullOrEmpty(password)) if (string.IsNullOrEmpty(password))
{ {
_logger.LogError($"Authenticate error: No password provided"); _logger.LogError($"Authenticate error: No password provided");
throw new RequestException(StatusCodes.Status401Unauthorized, "Authentication error"); throw new UnauthorizedAccessException("Authentication error");
} }
return true; return true;

View File

@ -29,7 +29,7 @@ namespace MyCore.Interfaces.DTO
public string ProviderName { get; set; } public string ProviderName { get; set; }
public LocationDTO Location { get; set; } public PlaceDTO Location { get; set; }
public DateTime LastStateDate { get; set; } public DateTime LastStateDate { get; set; }
@ -62,7 +62,7 @@ namespace MyCore.Interfaces.DTO
public List<string> GroupIds { get; set; } public List<string> GroupIds { get; set; }
public Dictionary<string, object> Properties { get; set; } public string Properties { get; set; } // Dictionary<string, object>
public List<string> SupportedOperations { get; set; } public List<string> SupportedOperations { get; set; }
} }

View File

@ -5,7 +5,10 @@ using System.Threading.Tasks;
namespace MyCore.Interfaces.DTO namespace MyCore.Interfaces.DTO
{ {
public class LocationDTO /// <summary>
/// Place DTO
/// </summary>
public class PlaceDTO
{ {
public string Id { get; set; } public string Id { get; set; }
public string Name { get; set; } public string Name { get; set; }

View File

@ -28,7 +28,7 @@ namespace MyCore.Interfaces
public IEnumerable<double> H2h { get; set; } public IEnumerable<double> H2h { get; set; }
} }
public class OddH2H public class OddObject
{ {
public double HomeOdd { get; set; } public double HomeOdd { get; set; }
public double DrawOdd { get; set; } public double DrawOdd { get; set; }
@ -40,6 +40,6 @@ namespace MyCore.Interfaces
public List<string> Teams { get; set; } public List<string> Teams { get; set; }
public int Commence_time { get; set; } public int Commence_time { get; set; }
public string Home_team { get; set; } public string Home_team { get; set; }
public OddH2H Odds { get; set; } public OddObject Odds { get; set; }
} }
} }

View File

@ -96,7 +96,7 @@ namespace MyCore.Interfaces.Models
public class Condition public class Condition
{ {
public string DeviceId { get; set; } public string DeviceId { get; set; }
public State State { get; set; } public AutomationState State { get; set; }
public string StartTime { get; set; } // TIMESPAN JSON SERIALIZED public string StartTime { get; set; } // TIMESPAN JSON SERIALIZED
public string EndTime { get; set; } // TIMESPAN JSON SERIALIZED public string EndTime { get; set; } // TIMESPAN JSON SERIALIZED
public ConditionType Type { get; set; } public ConditionType Type { get; set; }
@ -123,7 +123,7 @@ namespace MyCore.Interfaces.Models
{ {
public string GroupId { get; set; } public string GroupId { get; set; }
public string DeviceId { get; set; } public string DeviceId { get; set; }
public List<State> States { get; set; } public List<AutomationState> States { get; set; }
public string RawRequest { get; set; } // http, mqtt public string RawRequest { get; set; } // http, mqtt
public string ProviderId { get; set; } public string ProviderId { get; set; }
public ActionType Type { get; set; } public ActionType Type { get; set; }
@ -134,7 +134,7 @@ namespace MyCore.Interfaces.Models
public string message { get; set; } public string message { get; set; }
} }
public class State public class AutomationState
{ {
public string Name { get; set; } // example : state public string Name { get; set; } // example : state
public string Value { get; set; } // example : ON public string Value { get; set; } // example : ON

View File

@ -94,7 +94,7 @@ namespace MyCore.Interfaces.Models
public List<string> GroupIds { get; set; } public List<string> GroupIds { get; set; }
[BsonElement("Properties")] [BsonElement("Properties")]
public Dictionary<string, object> Properties { get; set; } public string Properties { get; set; } // Dictionary<string, object>
[BsonElement("SupportedOperations")] [BsonElement("SupportedOperations")]
public List<string> SupportedOperations { get; set; } public List<string> SupportedOperations { get; set; }

View File

@ -7,7 +7,7 @@ namespace MyCore.Interfaces.Models
/// <summary> /// <summary>
/// Location of a device (Room name, garden, ..) /// Location of a device (Room name, garden, ..)
/// </summary> /// </summary>
public class Location public class Place
{ {
[BsonId] [BsonId]
[BsonRepresentation(BsonType.ObjectId)] [BsonRepresentation(BsonType.ObjectId)]
@ -17,9 +17,9 @@ namespace MyCore.Interfaces.Models
[BsonRequired] [BsonRequired]
public string Name { get; set; } public string Name { get; set; }
public LocationDTO ToDTO() public PlaceDTO ToDTO()
{ {
return new LocationDTO() return new PlaceDTO()
{ {
Id = Id, Id = Id,
Name = Name Name = Name

View File

@ -20,7 +20,7 @@ namespace MyCore.Interfaces.Models
public string Type { get; set; } public string Type { get; set; }
[BsonElement("Widgets")] [BsonElement("Widgets")]
public Widget[] Widgets { get; set; } public ScreenWidget[] Widgets { get; set; }
[BsonElement("Height")] [BsonElement("Height")]
public int Height { get; set; } public int Height { get; set; }

View File

@ -8,7 +8,7 @@ using System.Threading.Tasks;
namespace MyCore.Interfaces.Models namespace MyCore.Interfaces.Models
{ {
public class Widget public class ScreenWidget
{ {
[BsonId] [BsonId]
[BsonRepresentation(BsonType.ObjectId)] [BsonRepresentation(BsonType.ObjectId)]

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace MyCore.Interfaces.Models namespace MyCore.Interfaces.Models
{ {
public class WidgetAgenda : Widget public class WidgetAgenda : ScreenWidget
{ {
[BsonElement("Provider")] [BsonElement("Provider")]
public string Provider { get; set; } public string Provider { get; set; }

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace MyCore.Interfaces.Models namespace MyCore.Interfaces.Models
{ {
public class WidgetHourAndDate : Widget public class WidgetHourAndDate : ScreenWidget
{ {
[BsonElement("Timezone")] [BsonElement("Timezone")]
public string Timezone { get; set; } public string Timezone { get; set; }

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace MyCore.Interfaces.Models namespace MyCore.Interfaces.Models
{ {
public class WidgetMessage : Widget public class WidgetMessage : ScreenWidget
{ {
[BsonElement("Message")] [BsonElement("Message")]
public string Message { get; set; } public string Message { get; set; }

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace MyCore.Interfaces.Models namespace MyCore.Interfaces.Models
{ {
public class WidgetNews : Widget public class WidgetNews : ScreenWidget
{ {
[BsonElement("Country")] [BsonElement("Country")]
public string Country { get; set; } public string Country { get; set; }

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace MyCore.Interfaces.Models namespace MyCore.Interfaces.Models
{ {
public class WidgetRadio : Widget public class WidgetRadio : ScreenWidget
{ {
[BsonElement("Provider")] [BsonElement("Provider")]
public string Provider { get; set; } public string Provider { get; set; }

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace MyCore.Interfaces.Models namespace MyCore.Interfaces.Models
{ {
public class WidgetTraffic : Widget public class WidgetTraffic : ScreenWidget
{ {
[BsonElement("WorkAddress")] [BsonElement("WorkAddress")]
public string WorkAddress { get; set; } public string WorkAddress { get; set; }

View File

@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace MyCore.Interfaces.Models namespace MyCore.Interfaces.Models
{ {
public class WidgetWeather : Widget public class WidgetWeather : ScreenWidget
{ {
[BsonElement("City")] [BsonElement("City")]
public string City { get; set; } public string City { get; set; }

View File

@ -53,7 +53,13 @@ namespace MyCore.Service.Controllers
//_mqttOnlineClientService = onlineProvider.MqttOnlineClientService; //_mqttOnlineClientService = onlineProvider.MqttOnlineClientService;
} }
private ActionResult<LoginDTO> Authenticate(string email, string password) /// <summary>
/// Authenticate (business)
/// </summary>
/// <param name="email">user email</param>
/// <param name="password">user password</param>
/// <returns>Token descriptor</returns>
private ObjectResult Authenticate(string email, string password)
{ {
try try
{ {
@ -65,18 +71,19 @@ namespace MyCore.Service.Controllers
// Set user token ? // Set user token ?
var user = _UserDatabaseService.GetByEmail(email.ToLower()); var user = _UserDatabaseService.GetByEmail(email.ToLower());
if (user != null) { if (user == null)
System.Console.WriteLine($"Init userId for MqqClientService ! {user.Email}"); throw new KeyNotFoundException("User not found");
MqttClientService.SetServices(_DeviceDatabaseService, _GroupDatabaseService, _ProviderDatabaseService, _LocationDatabaseService, _ActionService, _AutomationDatabaseService, user.Id);
}
return Ok(token); System.Console.WriteLine($"Init userId for MqqClientService ! {user.Email}");
MqttClientService.SetServices(_DeviceDatabaseService, _GroupDatabaseService, _ProviderDatabaseService, _LocationDatabaseService, _ActionService, _AutomationDatabaseService, user.Id);
return new OkObjectResult(token);
} }
/*catch (UnauthorizedAccessException ex) catch (UnauthorizedAccessException ex)
{ {
_logger?.LogError(ex, $"Authentication error for user '{email}': unauthorized access"); _logger?.LogError(ex, $"Authentication error for user '{email}': unauthorized access");
return Unauthorized(ex); return Unauthorized(ex);
}*/ }
catch (Exception ex) catch (Exception ex)
{ {
_logger?.LogError(ex, $"Authenticate error for user '{email}'"); _logger?.LogError(ex, $"Authenticate error for user '{email}'");
@ -92,10 +99,10 @@ namespace MyCore.Service.Controllers
[AllowAnonymous] [AllowAnonymous]
[HttpPost("Token")] [HttpPost("Token")]
[Consumes("application/x-www-form-urlencoded")] [Consumes("application/x-www-form-urlencoded")]
[SwaggerResponse(HttpStatusCode.OK, typeof(TokenDTO), Description = "Success")] // or ? [ProducesResponseType(typeof(TokenDTO), 200)] [ProducesResponseType(typeof(TokenDTO), (int) HttpStatusCode.OK)]
[SwaggerResponse(HttpStatusCode.Unauthorized, typeof(string), Description = "Invalid credentials")] [ProducesResponseType(typeof(string), (int) HttpStatusCode.Unauthorized)]
[SwaggerResponse(HttpStatusCode.InternalServerError, typeof(string), Description = "Error")] [ProducesResponseType(typeof(string), (int) HttpStatusCode.InternalServerError)]
public ActionResult<LoginDTO> AuthenticateWithForm([FromForm] SwaggerTokenRequest tokenRequest) public ObjectResult AuthenticateWithForm([FromForm] SwaggerTokenRequest tokenRequest)
{ {
return Authenticate(tokenRequest.username, tokenRequest.password); return Authenticate(tokenRequest.username, tokenRequest.password);
} }
@ -108,10 +115,10 @@ namespace MyCore.Service.Controllers
[AllowAnonymous] [AllowAnonymous]
[HttpPost("Authenticate")] [HttpPost("Authenticate")]
[Consumes("application/json")] [Consumes("application/json")]
[SwaggerResponse(HttpStatusCode.OK, typeof(LoginDTO), Description = "Success")] [ProducesResponseType(typeof(TokenDTO), (int)HttpStatusCode.OK)]
[SwaggerResponse(HttpStatusCode.Unauthorized, typeof(string), Description = "Invalid credentials")] [ProducesResponseType(typeof(string), (int)HttpStatusCode.Unauthorized)]
[SwaggerResponse(HttpStatusCode.InternalServerError, typeof(string), Description = "Error")] [ProducesResponseType(typeof(string), (int)HttpStatusCode.InternalServerError)]
public ActionResult<LoginDTO> AuthenticateWithJson([FromBody] LoginDTO login) public ObjectResult AuthenticateWithJson([FromBody] LoginDTO login)
{ {
return Authenticate(login.Email.ToLower(), login.Password); return Authenticate(login.Email.ToLower(), login.Password);
} }

View File

@ -41,6 +41,7 @@ namespace MyCore.Service.Controllers
/// </summary> /// </summary>
/// <param name="userId">Id of user</param> /// <param name="userId">Id of user</param>
[ProducesResponseType(typeof(List<RoomSummaryDTO>), 200)] [ProducesResponseType(typeof(List<RoomSummaryDTO>), 200)]
[ProducesResponseType(typeof(string), 500)]
[HttpGet("{userId}")] [HttpGet("{userId}")]
public ObjectResult GetAll(string userId) public ObjectResult GetAll(string userId)
{ {
@ -63,15 +64,32 @@ namespace MyCore.Service.Controllers
/// </summary> /// </summary>
/// <param name="automationId">automation id</param> /// <param name="automationId">automation id</param>
[ProducesResponseType(typeof(AutomationDetailDTO), 200)] [ProducesResponseType(typeof(AutomationDetailDTO), 200)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)]
[HttpGet("detail/{automationId}")] [HttpGet("detail/{automationId}")]
public ObjectResult GetDetail(string automationId) public ObjectResult GetDetail(string automationId)
{ {
try try
{ {
if (automationId == null)
throw new ArgumentNullException("Incorrect parameters");
Automation automation = _AutomationDatabaseService.GetById(automationId); Automation automation = _AutomationDatabaseService.GetById(automationId);
if (automation == null)
throw new KeyNotFoundException("Automation not found");
return new OkObjectResult(automation.ToDetailDTO()); return new OkObjectResult(automation.ToDetailDTO());
} }
catch (ArgumentNullException ex)
{
return new BadRequestObjectResult(ex.Message) {};
}
catch (KeyNotFoundException ex)
{
return new NotFoundObjectResult(ex.Message) {};
}
catch (Exception ex) catch (Exception ex)
{ {
return new ObjectResult(ex.Message) { StatusCode = 500 }; return new ObjectResult(ex.Message) { StatusCode = 500 };
@ -79,23 +97,29 @@ namespace MyCore.Service.Controllers
} }
//// <summary> /// <summary>
/// Create an automation /// Create an automation
/// </summary> /// </summary>
/// <param name="automationCreateOrUpdateDetail">Automation to create</param> /// <param name="automationCreateOrUpdateDetail">Automation to create</param>
[ProducesResponseType(typeof(AutomationDTO), 200)] [ProducesResponseType(typeof(AutomationDTO), 200)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 500)]
[HttpPost] [HttpPost]
public ObjectResult Create([FromBody] AutomationCreateOrUpdateDetailDTO automationCreateOrUpdateDetail) public ObjectResult Create([FromBody] AutomationCreateOrUpdateDetailDTO automationCreateOrUpdateDetail)
{ {
try try
{ {
if (automationCreateOrUpdateDetail == null) if (automationCreateOrUpdateDetail == null)
throw new KeyNotFoundException("Automation is null"); throw new ArgumentNullException("Incorrect parameters");
AutomationDTO automationCreated = AutomationService.CreateOrUpdate(this._AutomationDatabaseService, automationCreateOrUpdateDetail.UserId, automationCreateOrUpdateDetail, true); AutomationDTO automationCreated = AutomationService.CreateOrUpdate(this._AutomationDatabaseService, automationCreateOrUpdateDetail.UserId, automationCreateOrUpdateDetail, true);
return new OkObjectResult(automationCreated); return new OkObjectResult(automationCreated);
} }
catch (ArgumentNullException ex)
{
return new BadRequestObjectResult(ex.Message) {};
}
catch (Exception ex) catch (Exception ex)
{ {
return new ObjectResult(ex.Message) { StatusCode = 500 }; return new ObjectResult(ex.Message) { StatusCode = 500 };
@ -108,11 +132,17 @@ namespace MyCore.Service.Controllers
/// </summary> /// </summary>
/// <param name="automationCreateOrUpdateDetail">automation to update</param> /// <param name="automationCreateOrUpdateDetail">automation to update</param>
[ProducesResponseType(typeof(AutomationCreateOrUpdateDetailDTO), 200)] [ProducesResponseType(typeof(AutomationCreateOrUpdateDetailDTO), 200)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)]
[HttpPut] [HttpPut]
public ObjectResult Update([FromBody] AutomationCreateOrUpdateDetailDTO automationCreateOrUpdateDetail) public ObjectResult Update([FromBody] AutomationCreateOrUpdateDetailDTO automationCreateOrUpdateDetail)
{ {
try try
{ {
if (automationCreateOrUpdateDetail == null)
throw new ArgumentNullException("Incorrect parameters");
if (!_AutomationDatabaseService.IsExist(automationCreateOrUpdateDetail.Id)) if (!_AutomationDatabaseService.IsExist(automationCreateOrUpdateDetail.Id))
throw new KeyNotFoundException("Automation does not exist"); throw new KeyNotFoundException("Automation does not exist");
@ -120,9 +150,13 @@ namespace MyCore.Service.Controllers
return new OkObjectResult(automationUpdated); return new OkObjectResult(automationUpdated);
} }
catch (ArgumentNullException ex)
{
return new BadRequestObjectResult(ex.Message) {};
}
catch (KeyNotFoundException ex) catch (KeyNotFoundException ex)
{ {
return new BadRequestObjectResult(ex.Message) { StatusCode = 404 }; return new BadRequestObjectResult(ex.Message) {};
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -134,20 +168,32 @@ namespace MyCore.Service.Controllers
/// Delete an automation /// Delete an automation
/// </summary> /// </summary>
/// <param name="automationId">Id of automation to delete</param> /// <param name="automationId">Id of automation to delete</param>
[ProducesResponseType(typeof(string), 202)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)]
[HttpDelete("{automationId}")] [HttpDelete("{automationId}")]
public ObjectResult Delete(string automationId) public ObjectResult Delete(string automationId)
{ {
try try
{ {
if (automationId != null) if (automationId == null)
{ throw new ArgumentNullException("Incorrect parameters");
if (_AutomationDatabaseService.IsExist(automationId))
{
_AutomationDatabaseService.Remove(automationId);
}
}
return new OkObjectResult(201); if (!_AutomationDatabaseService.IsExist(automationId))
throw new KeyNotFoundException("Automation does not exist");
_AutomationDatabaseService.Remove(automationId);
return new ObjectResult("The automation has been deleted") { StatusCode = 202 };
}
catch (ArgumentNullException ex)
{
return new BadRequestObjectResult(ex.Message) {};
}
catch (KeyNotFoundException ex)
{
return new NotFoundObjectResult(ex.Message) {};
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -159,20 +205,32 @@ namespace MyCore.Service.Controllers
/// Delete all automation for a specified /// Delete all automation for a specified
/// </summary> /// </summary>
/// <param name="userId">Id of user</param> /// <param name="userId">Id of user</param>
[ProducesResponseType(typeof(string), 202)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)]
[HttpDelete("user/{userId}")] [HttpDelete("user/{userId}")]
public ObjectResult DeleteAllForUser(string userId) public ObjectResult DeleteAllForUser(string userId)
{ {
try try
{ {
if (userId != null) if (userId == null)
{ throw new ArgumentNullException("Incorrect parameters");
if (_UserDatabaseService.IsExist(userId))
{
_AutomationDatabaseService.RemoveForUser(userId);
}
}
return new OkObjectResult(201); if (!_UserDatabaseService.IsExist(userId))
throw new KeyNotFoundException("User does not exist");
_AutomationDatabaseService.RemoveForUser(userId);
return new ObjectResult("All automation linked with specified user has been successfully deleted") { StatusCode = 202 };
}
catch (ArgumentNullException ex)
{
return new BadRequestObjectResult(ex.Message) {};
}
catch (KeyNotFoundException ex)
{
return new NotFoundObjectResult(ex.Message) {};
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@ -39,12 +39,12 @@ namespace MyCore.Controllers
//this._mqttOnlineClientService = onlineProvider.MqttOnlineClientService; //this._mqttOnlineClientService = onlineProvider.MqttOnlineClientService;
} }
// GET: Devices
/// <summary> /// <summary>
/// Get all devices summary /// Get all devices summary
/// </summary> /// </summary>
/// <param name="userId">Id of user</param> /// <param name="userId">Id of user</param>
[ProducesResponseType(typeof(List<DeviceSummaryDTO>), 200)] [ProducesResponseType(typeof(List<DeviceSummaryDTO>), 200)]
[ProducesResponseType(typeof(string), 500)]
[HttpGet("{userId}")] [HttpGet("{userId}")]
public ObjectResult GetAll(string userId) public ObjectResult GetAll(string userId)
{ {
@ -72,15 +72,32 @@ namespace MyCore.Controllers
/// </summary> /// </summary>
/// <param name="deviceId">id of device</param> /// <param name="deviceId">id of device</param>
[ProducesResponseType(typeof(DeviceDetailDTO), 200)] [ProducesResponseType(typeof(DeviceDetailDTO), 200)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)]
[HttpGet("detail/{deviceId}")] [HttpGet("detail/{deviceId}")]
public ObjectResult GetDetail(string deviceId) public ObjectResult GetDetail(string deviceId)
{ {
try try
{ {
if (deviceId == null)
throw new ArgumentNullException("Incorrect parameters");
Device device = _DeviceDatabaseService.GetById(deviceId); Device device = _DeviceDatabaseService.GetById(deviceId);
if (device == null)
throw new KeyNotFoundException("Device does not exist");
return new OkObjectResult(device.ToDTO()); return new OkObjectResult(device.ToDTO());
} }
catch (ArgumentNullException ex)
{
return new BadRequestObjectResult(ex.Message) { };
}
catch (KeyNotFoundException ex)
{
return new NotFoundObjectResult(ex.Message) { };
}
catch (Exception ex) catch (Exception ex)
{ {
return new ObjectResult(ex.Message) { StatusCode = 500 }; return new ObjectResult(ex.Message) { StatusCode = 500 };
@ -93,22 +110,24 @@ namespace MyCore.Controllers
/// <param name="userId">user Id</param> /// <param name="userId">user Id</param>
/// <param name="type">device type</param> /// <param name="type">device type</param>
[ProducesResponseType(typeof(List<DeviceDetailDTO>), 200)] [ProducesResponseType(typeof(List<DeviceDetailDTO>), 200)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 500)]
[HttpGet("{userId}/type/{type}")] [HttpGet("{userId}/type/{type}")]
public ObjectResult GetDevicesByType(string userId, DeviceType type) public ObjectResult GetDevicesByType(string userId, DeviceType type)
{ {
try try
{ {
if (userId == null) if (userId == null)
throw new InvalidOperationException("User not found"); throw new ArgumentNullException("Incorrect parameters");
List<Device> devices = _DeviceDatabaseService.GetByType(userId, type); List<Device> devices = _DeviceDatabaseService.GetByType(userId, type);
return new OkObjectResult(devices.Select(d => d.ToDTO())); return new OkObjectResult(devices.Select(d => d.ToDTO()));
} }
catch (InvalidOperationException ex) catch (ArgumentNullException ex)
{ {
return new BadRequestObjectResult(ex.Message) { StatusCode = 400 }; return new BadRequestObjectResult(ex.Message) { };
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -121,26 +140,34 @@ namespace MyCore.Controllers
/// </summary> /// </summary>
/// <param name="deviceDetailDTO">Device to create</param> /// <param name="deviceDetailDTO">Device to create</param>
[ProducesResponseType(typeof(DeviceDetailDTO), 200)] [ProducesResponseType(typeof(DeviceDetailDTO), 200)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 409)]
[ProducesResponseType(typeof(string), 500)]
[HttpPost] [HttpPost]
public ObjectResult Create([FromBody] DeviceDetailDTO deviceDetailDTO) public ObjectResult Create([FromBody] DeviceDetailDTO deviceDetailDTO)
{ {
try try
{ {
if (deviceDetailDTO == null) if (deviceDetailDTO == null)
throw new KeyNotFoundException("Device detail not found"); throw new ArgumentNullException("Incorrect parameters");
DeviceDetailDTO deviceCreated = DeviceService.CreateOrUpdate(this._DeviceDatabaseService, this._ProviderDatabaseService, this._LocationDatabaseService, deviceDetailDTO.UserId, deviceDetailDTO, true); DeviceDetailDTO deviceCreated = DeviceService.CreateOrUpdate(this._DeviceDatabaseService, this._ProviderDatabaseService, this._LocationDatabaseService, deviceDetailDTO.UserId, deviceDetailDTO, true);
return new OkObjectResult(deviceCreated); return new OkObjectResult(deviceCreated);
} }
catch (ArgumentNullException ex)
{
return new BadRequestObjectResult(ex.Message) { };
}
catch (DuplicateWaitObjectException ex) catch (DuplicateWaitObjectException ex)
{ {
return new BadRequestObjectResult(ex.Message) { StatusCode = 400 }; return new ConflictObjectResult(ex.Message) { };
} }
catch (KeyNotFoundException ex) catch (KeyNotFoundException ex)
{ {
return new BadRequestObjectResult(ex.Message) { StatusCode = 404 }; return new NotFoundObjectResult(ex.Message) { };
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -154,13 +181,18 @@ namespace MyCore.Controllers
/// <param name="userId">User Id</param> /// <param name="userId">User Id</param>
/// <param name="providerId">Id of Provider</param> /// <param name="providerId">Id of Provider</param>
[ProducesResponseType(typeof(List<DeviceDetailDTO>), 200)] [ProducesResponseType(typeof(List<DeviceDetailDTO>), 200)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 401)]
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 421)]
[ProducesResponseType(typeof(string), 500)]
[HttpPost("{userId}/fromProvider/{providerId}")] [HttpPost("{userId}/fromProvider/{providerId}")]
public async Task<ObjectResult> CreateDevicesFromProvider(string userId, string providerId) public async Task<ObjectResult> CreateDevicesFromProvider(string userId, string providerId)
{ {
try try
{ {
if (userId == null) if (userId == null)
throw new InvalidOperationException("User not found"); throw new ArgumentNullException("Invalid paramaters");
if (!UserService.IsExist(_UserDatabaseService, userId)) if (!UserService.IsExist(_UserDatabaseService, userId))
throw new KeyNotFoundException("User not found"); throw new KeyNotFoundException("User not found");
@ -173,17 +205,17 @@ namespace MyCore.Controllers
return new OkObjectResult(devices); return new OkObjectResult(devices);
} }
catch (InvalidOperationException ex) catch (ArgumentNullException ex)
{ {
return new BadRequestObjectResult(ex.Message) { StatusCode = 400 }; return new BadRequestObjectResult(ex.Message) {};
} }
catch (KeyNotFoundException ex) catch (KeyNotFoundException ex)
{ {
return new BadRequestObjectResult(ex.Message) { StatusCode = 404 }; return new NotFoundObjectResult(ex.Message) {};
} }
catch (AuthenticationException ex) catch (AuthenticationException ex)
{ {
return new BadRequestObjectResult(ex.Message) { StatusCode = 401 }; return new UnauthorizedObjectResult(ex.Message) {};
} }
catch (HttpRequestException ex) // Not ok if not http request.. catch (HttpRequestException ex) // Not ok if not http request..
{ {
@ -200,13 +232,16 @@ namespace MyCore.Controllers
/// </summary> /// </summary>
/// <param name="userId">User Id</param> /// <param name="userId">User Id</param>
[ProducesResponseType(typeof(List<DeviceDetailDTO>), 200)] [ProducesResponseType(typeof(List<DeviceDetailDTO>), 200)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)]
[HttpGet("zigbee2Mqtt/{userId}")] [HttpGet("zigbee2Mqtt/{userId}")]
public ObjectResult GetDevicesFromZigbee2Mqtt(string userId) public ObjectResult GetDevicesFromZigbee2Mqtt(string userId)
{ {
try try
{ {
if (userId == null) if (userId == null)
throw new InvalidOperationException("User not found"); throw new ArgumentNullException("Invalid paramaters");
if (!UserService.IsExist(_UserDatabaseService, userId)) if (!UserService.IsExist(_UserDatabaseService, userId))
throw new KeyNotFoundException("User not found"); throw new KeyNotFoundException("User not found");
@ -216,9 +251,13 @@ namespace MyCore.Controllers
return new OkObjectResult(devices); return new OkObjectResult(devices);
} }
catch (InvalidOperationException ex) catch (ArgumentNullException ex)
{ {
return new BadRequestObjectResult(ex.Message) { StatusCode = 400 }; return new BadRequestObjectResult(ex.Message) {};
}
catch (KeyNotFoundException ex)
{
return new NotFoundObjectResult(ex.Message) {};
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -232,16 +271,16 @@ namespace MyCore.Controllers
/// <param name="userId">User Id</param> /// <param name="userId">User Id</param>
/// <param name="providerId">Id of Provider</param> /// <param name="providerId">Id of Provider</param>
[ProducesResponseType(typeof(List<DeviceDetailDTO>), 200)] [ProducesResponseType(typeof(List<DeviceDetailDTO>), 200)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)]
[HttpGet("{userId}/fromProvider/{providerId}")] [HttpGet("{userId}/fromProvider/{providerId}")]
public ObjectResult GetDevicesFromProvider(string userId, string providerId) public ObjectResult GetDevicesFromProvider(string userId, string providerId)
{ {
try try
{ {
if (userId == null) if (userId == null || providerId == null)
throw new InvalidOperationException("User not found"); throw new ArgumentNullException("Invalid paramaters");
if (providerId == null)
throw new InvalidOperationException("Provider not found");
if (!_UserDatabaseService.IsExist(userId)) if (!_UserDatabaseService.IsExist(userId))
throw new KeyNotFoundException("User does not exist"); throw new KeyNotFoundException("User does not exist");
@ -254,13 +293,13 @@ namespace MyCore.Controllers
return new OkObjectResult(devices.Select(d => d.ToDTO())); return new OkObjectResult(devices.Select(d => d.ToDTO()));
} }
catch (InvalidOperationException ex) catch (ArgumentNullException ex)
{ {
return new BadRequestObjectResult(ex.Message) { StatusCode = 400 }; return new BadRequestObjectResult(ex.Message) {};
} }
catch (KeyNotFoundException ex) catch (KeyNotFoundException ex)
{ {
return new BadRequestObjectResult(ex.Message) { StatusCode = 404 }; return new BadRequestObjectResult(ex.Message) {};
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -273,6 +312,8 @@ namespace MyCore.Controllers
/// </summary> /// </summary>
/// <param name="deviceDetailDTO">Device to update</param> /// <param name="deviceDetailDTO">Device to update</param>
[ProducesResponseType(typeof(DeviceDetailDTO), 200)] [ProducesResponseType(typeof(DeviceDetailDTO), 200)]
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)]
[HttpPut("{deviceId}")] [HttpPut("{deviceId}")]
public ObjectResult Update([FromBody] DeviceDetailDTO deviceDetailDTO) public ObjectResult Update([FromBody] DeviceDetailDTO deviceDetailDTO)
{ {
@ -287,7 +328,7 @@ namespace MyCore.Controllers
} }
catch (KeyNotFoundException ex) catch (KeyNotFoundException ex)
{ {
return new BadRequestObjectResult(ex.Message) { StatusCode = 404 }; return new BadRequestObjectResult(ex.Message) {};
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -299,13 +340,17 @@ namespace MyCore.Controllers
/// Delete a device /// Delete a device
/// </summary> /// </summary>
/// <param name="deviceId">Id of device to delete</param> /// <param name="deviceId">Id of device to delete</param>
[ProducesResponseType(typeof(string), 202)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)]
[HttpDelete("{deviceId}")] [HttpDelete("{deviceId}")]
public ObjectResult Delete(string deviceId) public ObjectResult Delete(string deviceId)
{ {
try try
{ {
if (deviceId == null) if (deviceId == null)
throw new InvalidOperationException("Device not found"); throw new ArgumentNullException("Invalid paramaters");
if (!_DeviceDatabaseService.IsExist(deviceId)) if (!_DeviceDatabaseService.IsExist(deviceId))
throw new KeyNotFoundException("Device does not exist"); throw new KeyNotFoundException("Device does not exist");
@ -313,16 +358,16 @@ namespace MyCore.Controllers
// TODO REMOVE DEVICE ID IN AUTOMATION and delete automation if none device ? // TODO REMOVE DEVICE ID IN AUTOMATION and delete automation if none device ?
_DeviceDatabaseService.Remove(deviceId); _DeviceDatabaseService.Remove(deviceId);
return new OkObjectResult(200);
return new ObjectResult("Device has been deleted") { StatusCode = 202 };
} }
catch (InvalidOperationException ex) catch (ArgumentNullException ex)
{ {
return new BadRequestObjectResult(ex.Message) { StatusCode = 400 }; return new BadRequestObjectResult(ex.Message) {};
} }
catch (KeyNotFoundException ex) catch (KeyNotFoundException ex)
{ {
return new BadRequestObjectResult(ex.Message) { StatusCode = 404 }; return new NotFoundObjectResult(ex.Message) {};
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -335,16 +380,17 @@ namespace MyCore.Controllers
/// </summary> /// </summary>
/// <param name="userId">User Id</param> /// <param name="userId">User Id</param>
/// <param name="providerId">Id of Provider</param> /// <param name="providerId">Id of Provider</param>
[ProducesResponseType(typeof(string), 202)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)]
[HttpDelete("{userId}/fromProvider/{providerId}")] [HttpDelete("{userId}/fromProvider/{providerId}")]
public ObjectResult DeleteDevicesFromProvider(string userId, string providerId) public ObjectResult DeleteDevicesFromProvider(string userId, string providerId)
{ {
try try
{ {
if (userId == null) if (userId == null || providerId == null)
throw new InvalidOperationException("User not found"); throw new ArgumentNullException("Invalid paramaters");
if (providerId == null)
throw new InvalidOperationException("Provider not found");
if (!_UserDatabaseService.IsExist(userId)) if (!_UserDatabaseService.IsExist(userId))
throw new KeyNotFoundException("User does not exist"); throw new KeyNotFoundException("User does not exist");
@ -354,15 +400,15 @@ namespace MyCore.Controllers
// TODO REMOVE DEVICE ID IN AUTOMATION and delete automation if none device ? // TODO REMOVE DEVICE ID IN AUTOMATION and delete automation if none device ?
_DeviceDatabaseService.RemoveForProvider(providerId); _DeviceDatabaseService.RemoveForProvider(providerId);
return new OkObjectResult(200); return new ObjectResult("Provider devices has been successfully deleted") { StatusCode = 202 };
} }
catch (InvalidOperationException ex) catch (ArgumentNullException ex)
{ {
return new BadRequestObjectResult(ex.Message) { StatusCode = 400 }; return new BadRequestObjectResult(ex.Message) {};
} }
catch (KeyNotFoundException ex) catch (KeyNotFoundException ex)
{ {
return new BadRequestObjectResult(ex.Message) { StatusCode = 404 }; return new NotFoundObjectResult(ex.Message) {};
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -371,31 +417,35 @@ namespace MyCore.Controllers
} }
/// <summary> /// <summary>
/// Delete all device for a specified /// Delete all device for a specified user
/// </summary> /// </summary>
/// <param name="userId">Id of user</param> /// <param name="userId">Id of user</param>
[ProducesResponseType(typeof(string), 202)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)]
[HttpDelete("user/{userId}")] [HttpDelete("user/{userId}")]
public ObjectResult DeleteAllForUser(string userId) public ObjectResult DeleteAllForUser(string userId)
{ {
try try
{ {
if (userId == null) if (userId == null)
throw new InvalidOperationException("User not found"); throw new ArgumentNullException("Invalid paramaters");
if (!_UserDatabaseService.IsExist(userId)) if (!_UserDatabaseService.IsExist(userId))
throw new KeyNotFoundException("User does not exist"); throw new KeyNotFoundException("User does not exist");
// TODO REMOVE DEVICE ID IN AUTOMATION and delete automation if none device ? // TODO REMOVE DEVICE ID IN AUTOMATION and delete automation if none device ?
_DeviceDatabaseService.RemoveForUser(userId); _DeviceDatabaseService.RemoveForUser(userId);
return new OkObjectResult(200); return new ObjectResult("User devices has been successfully deleted") { StatusCode = 202 };
} }
catch (InvalidOperationException ex) catch (ArgumentNullException ex)
{ {
return new BadRequestObjectResult(ex.Message) { StatusCode = 400 }; return new BadRequestObjectResult(ex.Message) {};
} }
catch (KeyNotFoundException ex) catch (KeyNotFoundException ex)
{ {
return new BadRequestObjectResult(ex.Message) { StatusCode = 404 }; return new NotFoundObjectResult(ex.Message) {};
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@ -38,6 +38,7 @@ namespace MyCore.Controllers
/// <param name="oddRequest">Odd Maximum value</param> /// <param name="oddRequest">Odd Maximum value</param>
[AllowAnonymous] [AllowAnonymous]
[ProducesResponseType(typeof(List<OddNice>), 200)] [ProducesResponseType(typeof(List<OddNice>), 200)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 404)] [ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)] [ProducesResponseType(typeof(string), 500)]
[HttpGet("country/{id}/{oddRequest}")] [HttpGet("country/{id}/{oddRequest}")]
@ -45,6 +46,9 @@ namespace MyCore.Controllers
{ {
try try
{ {
if (id == null)
throw new ArgumentNullException("Incorrect parameters");
try try
{ {
League leagueTest = new League(id); League leagueTest = new League(id);
@ -58,6 +62,10 @@ namespace MyCore.Controllers
return Ok(result); return Ok(result);
} }
catch (ArgumentNullException ex)
{
return new BadRequestObjectResult(ex.Message) { };
}
catch (Exception e) catch (Exception e)
{ {
Console.WriteLine(e); Console.WriteLine(e);
@ -116,7 +124,7 @@ namespace MyCore.Controllers
oddNice.Commence_time = odd.Commence_time; oddNice.Commence_time = odd.Commence_time;
oddNice.Home_team = odd.Home_team; oddNice.Home_team = odd.Home_team;
oddNice.Teams = odd.Teams; oddNice.Teams = odd.Teams;
oddNice.Odds = new OddH2H(); oddNice.Odds = new OddObject();
oddNice.Odds.HomeOdd = unibet.Odds.H2h.ToArray()[0]; oddNice.Odds.HomeOdd = unibet.Odds.H2h.ToArray()[0];
oddNice.Odds.VisitOdd = unibet.Odds.H2h.ToArray()[1]; oddNice.Odds.VisitOdd = unibet.Odds.H2h.ToArray()[1];
oddNice.Odds.DrawOdd = unibet.Odds.H2h.ToArray()[2]; oddNice.Odds.DrawOdd = unibet.Odds.H2h.ToArray()[2];

View File

@ -14,169 +14,194 @@ using MyCore.Services.MyControlPanel;
namespace MyCore.Controllers namespace MyCore.Controllers
{ {
//[Authorize(Roles = "Admin")] //[Authorize(Roles = "Admin")]
[Authorize] [Authorize]
[Route("api/provider")] [Route("api/provider")]
[ApiController] [ApiController]
public class ProviderController : ControllerBase public class ProviderController : ControllerBase
{
private DeviceDatabaseService _DeviceDatabaseService;
private ProviderDatabaseService _ProviderDatabaseService;
private LocationDatabaseService _LocationDatabaseService;
private UserDatabaseService _UserDatabaseService;
public ProviderController(DeviceDatabaseService DeviceDatabaseService, ProviderDatabaseService ProviderDatabaseService, LocationDatabaseService LocationDatabaseService, UserDatabaseService UserDatabaseService)
{ {
private DeviceDatabaseService _DeviceDatabaseService; this._DeviceDatabaseService = DeviceDatabaseService;
private ProviderDatabaseService _ProviderDatabaseService; this._ProviderDatabaseService = ProviderDatabaseService;
private LocationDatabaseService _LocationDatabaseService; this._LocationDatabaseService = LocationDatabaseService;
private UserDatabaseService _UserDatabaseService; this._UserDatabaseService = UserDatabaseService;
}
public ProviderController(DeviceDatabaseService DeviceDatabaseService, ProviderDatabaseService ProviderDatabaseService, LocationDatabaseService LocationDatabaseService, UserDatabaseService UserDatabaseService) /// <summary>
/// Get all user providers
/// </summary>
/// <param name="userId">Id of user</param>
[ProducesResponseType(typeof(List<ProviderDTO>), 200)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)]
[HttpGet("{userId}")]
public ObjectResult GetAll(string userId)
{
try
{ {
this._DeviceDatabaseService = DeviceDatabaseService; if (userId == null)
this._ProviderDatabaseService = ProviderDatabaseService; throw new ArgumentNullException("Incorrect parameters");
this._LocationDatabaseService = LocationDatabaseService;
this._UserDatabaseService = UserDatabaseService; if (!UserService.IsExist(_UserDatabaseService, userId))
throw new KeyNotFoundException("User not found");
List<Provider> providers = ProviderService.GetAll(this._ProviderDatabaseService, userId);
List<ProviderDTO> providersDTO = providers.Select(p => p.ToDTO()).ToList();
return new OkObjectResult(providersDTO);
} }
catch (ArgumentNullException ex)
// GET: Devices
/// <summary>
/// Get all user providers
/// </summary>
[ProducesResponseType(typeof(List<ProviderDTO>), 200)]
[HttpGet("{userId}")]
public ObjectResult GetAll(string userId)
{ {
try return new BadRequestObjectResult(ex.Message) {};
{
if (userId == null)
throw new InvalidOperationException("User not found");
if (!UserService.IsExist(_UserDatabaseService, userId))
throw new KeyNotFoundException("User not found");
List<Provider> providers = ProviderService.GetAll(this._ProviderDatabaseService, userId);
List<ProviderDTO> providersDTO = providers.Select(p => p.ToDTO()).ToList();
return new OkObjectResult(providersDTO);
}
catch (InvalidOperationException ex)
{
return new BadRequestObjectResult(ex.Message) { StatusCode = 400 };
}
catch (KeyNotFoundException ex)
{
return new BadRequestObjectResult(ex.Message) { StatusCode = 404 };
}
catch (Exception ex)
{
return new ObjectResult(ex.Message) { StatusCode = 500 };
}
} }
catch (KeyNotFoundException ex)
/// <summary>
/// Create a provider
/// </summary>
/// <param name="providerDTO">Provider to create</param>
[ProducesResponseType(typeof(ProviderDTO), 200)]
[HttpPost]
public ObjectResult Create([FromBody] ProviderDTO providerDTO)
{ {
try return new NotFoundObjectResult(ex.Message) {};
{
if (providerDTO.UserId == null)
throw new InvalidOperationException("User not found");
if (!UserService.IsExist(_UserDatabaseService, providerDTO.UserId))
throw new KeyNotFoundException("User not found");
if (providerDTO == null)
throw new KeyNotFoundException("Provider is null");
if (_ProviderDatabaseService.AlreadyExistForUser(providerDTO.UserId, providerDTO.Name))
throw new ArgumentException("Provider already exists");
ProviderDTO providerCreated = ProviderService.CreateOrUpdate(this._ProviderDatabaseService, providerDTO.UserId, providerDTO, true);
return new OkObjectResult(providerCreated);
}
catch (InvalidOperationException ex)
{
return new BadRequestObjectResult(ex.Message) { StatusCode = 400 };
}
catch (KeyNotFoundException ex)
{
return new BadRequestObjectResult(ex.Message) { StatusCode = 404 };
}
catch (ArgumentException ex)
{
return new BadRequestObjectResult(ex.Message) { StatusCode = 409 };
}
catch (Exception ex)
{
return new ObjectResult(ex.Message) { StatusCode = 500 };
}
} }
catch (Exception ex)
/// <summary>
/// Update a provider
/// </summary>
/// <param name="providerDTO">Provider to update</param>
[ProducesResponseType(typeof(DeviceDetailDTO), 200)]
[HttpPut]
public ObjectResult Update([FromBody] ProviderDTO providerDTO)
{ {
try return new ObjectResult(ex.Message) { StatusCode = 500 };
{
if (providerDTO.UserId == null)
throw new InvalidOperationException("User not found");
if (!UserService.IsExist(_UserDatabaseService, providerDTO.UserId))
throw new KeyNotFoundException("User not found");
if (!ProviderService.IsExist(this._ProviderDatabaseService, providerDTO.UserId, providerDTO.Id))
throw new KeyNotFoundException("Provider does not exist");
ProviderDTO providerUpdated = ProviderService.CreateOrUpdate(this._ProviderDatabaseService, providerDTO.UserId, providerDTO, false);
return new OkObjectResult(providerUpdated);
}
catch (InvalidOperationException ex)
{
return new BadRequestObjectResult(ex.Message) { StatusCode = 400 };
}
catch (KeyNotFoundException ex)
{
return new BadRequestObjectResult(ex.Message) { StatusCode = 404 };
}
catch (Exception ex)
{
return new ObjectResult(ex.Message) { StatusCode = 500 };
}
} }
}
/// <summary> /// <summary>
/// Delete a provider /// Create a provider
/// </summary> /// </summary>
/// <param name="providerId">Id of provider to delete</param> /// <param name="providerDTO">Provider to create</param>
[HttpDelete("{providerId}")] [ProducesResponseType(typeof(ProviderDTO), 200)]
public ObjectResult Delete(string providerId) [ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 409)]
[ProducesResponseType(typeof(string), 500)]
[HttpPost]
public ObjectResult Create([FromBody] ProviderDTO providerDTO)
{
try
{ {
try
{
// TODO DELETE ALL DEVICES linked
if (providerId == null)
throw new InvalidOperationException("Provider is null");
if (!_ProviderDatabaseService.IsExist(providerId)) if (providerDTO == null)
throw new InvalidOperationException("Provider is null"); throw new ArgumentNullException("Incorrect parameters");
_ProviderDatabaseService.Remove(providerId); if (providerDTO.UserId == null)
throw new ArgumentNullException("User not found");
return new OkObjectResult(201); if (!UserService.IsExist(_UserDatabaseService, providerDTO.UserId))
} throw new KeyNotFoundException("User not found");
catch (Exception ex)
{ if (_ProviderDatabaseService.AlreadyExistForUser(providerDTO.UserId, providerDTO.Name))
return new ObjectResult(ex.Message) { StatusCode = 500 }; throw new InvalidOperationException("Provider already exists");
}
ProviderDTO providerCreated = ProviderService.CreateOrUpdate(this._ProviderDatabaseService, providerDTO.UserId, providerDTO, true);
return new OkObjectResult(providerCreated);
}
catch (ArgumentNullException ex)
{
return new BadRequestObjectResult(ex.Message) {};
}
catch (KeyNotFoundException ex)
{
return new NotFoundObjectResult(ex.Message) {};
}
catch (InvalidOperationException ex)
{
return new ConflictObjectResult(ex.Message) {};
}
catch (Exception ex)
{
return new ObjectResult(ex.Message) { StatusCode = 500 };
}
}
/// <summary>
/// Update a provider
/// </summary>
/// <param name="providerDTO">Provider to update</param>
[ProducesResponseType(typeof(DeviceDetailDTO), 200)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)]
[HttpPut]
public ObjectResult Update([FromBody] ProviderDTO providerDTO)
{
try
{
if (providerDTO == null)
throw new ArgumentNullException("Incorrect parameters");
if (providerDTO.UserId == null)
throw new ArgumentNullException("User not found");
if (!UserService.IsExist(_UserDatabaseService, providerDTO.UserId))
throw new KeyNotFoundException("User not found");
if (!ProviderService.IsExist(this._ProviderDatabaseService, providerDTO.UserId, providerDTO.Id))
throw new KeyNotFoundException("Provider does not exist");
ProviderDTO providerUpdated = ProviderService.CreateOrUpdate(this._ProviderDatabaseService, providerDTO.UserId, providerDTO, false);
return new OkObjectResult(providerUpdated);
}
catch (ArgumentNullException ex)
{
return new BadRequestObjectResult(ex.Message) {};
}
catch (KeyNotFoundException ex)
{
return new NotFoundObjectResult(ex.Message) {};
}
catch (Exception ex)
{
return new ObjectResult(ex.Message) { StatusCode = 500 };
}
}
/// <summary>
/// Delete a provider
/// </summary>
/// <param name="providerId">Id of provider to delete</param>
[ProducesResponseType(typeof(string), 202)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)]
[HttpDelete("{providerId}")]
public ObjectResult Delete(string providerId)
{
try
{
// TODO DELETE ALL DEVICES linked
if (providerId == null)
throw new ArgumentNullException("Incorrect parameters");
if (!_ProviderDatabaseService.IsExist(providerId))
throw new KeyNotFoundException("Provider is null");
_ProviderDatabaseService.Remove(providerId);
return new ObjectResult("The provider has been deleted") { StatusCode = 202 };
}
catch (ArgumentNullException ex)
{
return new BadRequestObjectResult(ex.Message) {};
}
catch (KeyNotFoundException ex)
{
return new NotFoundObjectResult(ex.Message) {};
}
catch (Exception ex)
{
return new ObjectResult(ex.Message) { StatusCode = 500 };
} }
} }
} }
}

View File

@ -23,11 +23,11 @@ namespace MyCore.Controllers
_ScreenDeviceDatabaseService = ScreenDeviceDatabaseService; _ScreenDeviceDatabaseService = ScreenDeviceDatabaseService;
} }
// GET: Devices
/// <summary> /// <summary>
/// /// Get all screen devices
/// </summary> /// </summary>
[ProducesResponseType(typeof(List<ScreenDevice>), 200)] [ProducesResponseType(typeof(List<ScreenDevice>), 200)]
[ProducesResponseType(typeof(string), 500)]
[HttpGet] [HttpGet]
public ObjectResult GetAllScreenDevices() public ObjectResult GetAllScreenDevices()
{ {
@ -43,39 +43,63 @@ namespace MyCore.Controllers
} }
} }
// GET: ScreenDevice
/// <summary> /// <summary>
/// /// Get screen device info
/// </summary> /// </summary>
/// <param name="screenDeviceId">Id of the screen device you want to get information</param> /// <param name="screenDeviceId">Id of the screen device you want to get information</param>
[ProducesResponseType(typeof(ScreenDevice), 200)] [ProducesResponseType(typeof(ScreenDevice), 200)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)]
[HttpGet("{screenDeviceId}")] [HttpGet("{screenDeviceId}")]
public ObjectResult GetDeviceInfo(string screenDeviceId) public ObjectResult GetDeviceInfo(string screenDeviceId)
{ {
try try
{ {
if (screenDeviceId == null)
throw new ArgumentNullException("Incorrect parameters");
ScreenDevice screenDevice = _ScreenDeviceDatabaseService.GetInfo(screenDeviceId); ScreenDevice screenDevice = _ScreenDeviceDatabaseService.GetInfo(screenDeviceId);
if (screenDevice == null)
throw new KeyNotFoundException("Screen device not found");
return new OkObjectResult(screenDevice); return new OkObjectResult(screenDevice);
} }
catch (ArgumentNullException ex)
{
return new BadRequestObjectResult(ex.Message) {};
}
catch (KeyNotFoundException ex)
{
return new NotFoundObjectResult(ex.Message) {};
}
catch (Exception ex) catch (Exception ex)
{ {
return new ObjectResult(ex.Message) { StatusCode = 500 }; return new ObjectResult(ex.Message) { StatusCode = 500 };
} }
} }
// POST: Device/Create
/// <summary> /// <summary>
/// /// Create screen device
/// </summary> /// </summary>
/// <param name="screenDevice">Screen device to create</param>
[ProducesResponseType(typeof(ScreenDevice), 200)]
[ProducesResponseType(typeof(string), 400)]
[HttpPost] [HttpPost]
public ObjectResult CreateDevice([FromBody] ScreenDevice screenDevice) public ObjectResult CreateDevice([FromBody] ScreenDevice screenDevice)
{ {
try try
{ {
if (screenDevice == null)
throw new ArgumentNullException("Incorrect parameters");
_ScreenDeviceDatabaseService.Create(screenDevice); _ScreenDeviceDatabaseService.Create(screenDevice);
return new OkObjectResult(201); return new OkObjectResult(screenDevice);
}
catch (ArgumentNullException ex)
{
return new BadRequestObjectResult(ex.Message) {};
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -83,18 +107,36 @@ namespace MyCore.Controllers
} }
} }
// PUT: Device/Update
/// <summary> /// <summary>
/// /// Update screen device
/// </summary> /// </summary>
[HttpPut("{screenDeviceId}")] /// <param name="screenDevice">Screen device to update</param>
public ObjectResult UpdateDevice(int screenDeviceId, [FromBody] ScreenDevice screenDevice) [ProducesResponseType(typeof(ScreenDevice), 200)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)]
[HttpPut()]
public ObjectResult UpdateDevice([FromBody] ScreenDevice screenDevice)
{ {
try try
{ {
if (screenDevice == null)
throw new ArgumentNullException("Incorrect parameters");
if (!_ScreenDeviceDatabaseService.IsExist(screenDevice.Id))
throw new KeyNotFoundException("Screen device does not exist");
_ScreenDeviceDatabaseService.Update(screenDevice.Id, screenDevice); _ScreenDeviceDatabaseService.Update(screenDevice.Id, screenDevice);
return new OkObjectResult(201); return new OkObjectResult(screenDevice);
}
catch (ArgumentNullException ex)
{
return new BadRequestObjectResult(ex.Message) {};
}
catch (KeyNotFoundException ex)
{
return new NotFoundObjectResult(ex.Message) {};
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -102,18 +144,36 @@ namespace MyCore.Controllers
} }
} }
// Delete: Device/Delete
/// <summary> /// <summary>
/// /// Delete device
/// </summary> /// </summary>
/// <param name="deviceId">Screen device id to update</param>
[ProducesResponseType(typeof(string), 202)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)]
[HttpDelete("{deviceId}")] [HttpDelete("{deviceId}")]
public ObjectResult DeleteDevice(string deviceId) public ObjectResult DeleteDevice(string deviceId)
{ {
try try
{ {
if (deviceId == null)
throw new ArgumentNullException("Incorrect parameters");
if (!_ScreenDeviceDatabaseService.IsExist(deviceId))
throw new KeyNotFoundException("Device does not exist");
_ScreenDeviceDatabaseService.Remove(deviceId); _ScreenDeviceDatabaseService.Remove(deviceId);
return new OkObjectResult(201); return new ObjectResult("The screen device has been successfully deleted") { StatusCode = 202 };
}
catch (ArgumentNullException ex)
{
return new BadRequestObjectResult(ex.Message) {};
}
catch (KeyNotFoundException ex)
{
return new NotFoundObjectResult(ex.Message) {};
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@ -45,17 +45,26 @@ namespace MyCore.Service.Controllers
/// </summary> /// </summary>
/// <param name="userId">Id of user</param> /// <param name="userId">Id of user</param>
[ProducesResponseType(typeof(List<GroupSummaryDTO>), 200)] [ProducesResponseType(typeof(List<GroupSummaryDTO>), 200)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 500)]
[HttpGet("{userId}")] [HttpGet("{userId}")]
public ObjectResult GetAll(string userId) public ObjectResult GetAll(string userId)
{ {
try try
{ {
if (userId == null)
throw new ArgumentNullException("Incorrect parameters");
List<Group> Groups = _GroupDatabaseService.GetAll(userId); List<Group> Groups = _GroupDatabaseService.GetAll(userId);
List<GroupSummaryDTO> groupsSummaryDTO = Groups.Select(d => d.ToSummaryDTO()).ToList(); List<GroupSummaryDTO> groupsSummaryDTO = Groups.Select(d => d.ToSummaryDTO()).ToList();
return new OkObjectResult(groupsSummaryDTO); return new OkObjectResult(groupsSummaryDTO);
} }
catch (ArgumentNullException ex)
{
return new BadRequestObjectResult(ex.Message) { };
}
catch (Exception ex) catch (Exception ex)
{ {
return new ObjectResult(ex.Message) { StatusCode = 500 }; return new ObjectResult(ex.Message) { StatusCode = 500 };
@ -65,32 +74,35 @@ namespace MyCore.Service.Controllers
/// <summary> /// <summary>
/// Get detail info of a specified group /// Get detail info of a specified group
/// </summary> /// </summary>
/// <param name="userId">user id</param>
/// <param name="groupId">groupid</param> /// <param name="groupId">groupid</param>
[ProducesResponseType(typeof(GroupDetailDTO), 200)] [ProducesResponseType(typeof(GroupDetailDTO), 200)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)]
[HttpGet("detail/{groupId}")] [HttpGet("detail/{groupId}")]
public ObjectResult GetDetail(string userId, string groupId) public ObjectResult GetDetail(string groupId)
{ {
try try
{ {
if (userId != null && groupId != null) if (groupId == null)
{ throw new ArgumentNullException("Incorrect parameters");
Group group = _GroupDatabaseService.GetById(groupId);
if (group == null)
throw new KeyNotFoundException("Group not found");
List<Device> devices = _DeviceDatabaseService.GetByLocation(group.UserId, groupId); Group group = _GroupDatabaseService.GetById(groupId);
if (group == null)
throw new KeyNotFoundException("Group not found");
return new OkObjectResult(group.ToDTO(devices.Select(d => d.ToDTO()).ToList())); List<Device> devices = _DeviceDatabaseService.GetByLocation(group.UserId, groupId);
}
else return new OkObjectResult(group.ToDTO(devices.Select(d => d.ToDTO()).ToList()));
{
return new ObjectResult("Invalid parameters") { StatusCode = 400 }; }
} catch (ArgumentNullException ex)
{
return new BadRequestObjectResult(ex.Message) {};
} }
catch (KeyNotFoundException ex) catch (KeyNotFoundException ex)
{ {
return new BadRequestObjectResult(ex.Message) { StatusCode = 404 }; return new NotFoundObjectResult(ex.Message) {};
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -104,21 +116,61 @@ namespace MyCore.Service.Controllers
/// <param name="userId">user Id</param> /// <param name="userId">user Id</param>
/// <param name="type">group type</param> /// <param name="type">group type</param>
[ProducesResponseType(typeof(List<GroupSummaryDTO>), 200)] [ProducesResponseType(typeof(List<GroupSummaryDTO>), 200)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 500)]
[HttpGet("{userId}/type/{type}")] [HttpGet("{userId}/type/{type}")]
public ObjectResult GetGroupsByType(string userId, string type) // Change string type to enum ? Lights etc ? public ObjectResult GetGroupsByType(string userId, string type) // Change string type to enum ? Lights etc ?
{ {
try try
{ {
if (userId != null) if (userId == null || type == null)
{ throw new ArgumentNullException("Incorrect parameters");
List<Group> groups = _GroupDatabaseService.GetByType(userId, type);
return new OkObjectResult(groups.Select(d => d.ToSummaryDTO())); List<Group> groups = _GroupDatabaseService.GetByType(userId, type);
}
else return new OkObjectResult(groups.Select(d => d.ToSummaryDTO()));
{ }
return new ObjectResult("Invalid parameters") { StatusCode = 400 }; catch (ArgumentNullException ex)
} {
return new BadRequestObjectResult(ex.Message) {};
}
catch (Exception ex)
{
return new ObjectResult(ex.Message) { StatusCode = 500 };
}
}
/// <summary>
/// Get all zigbee2Mqtt groups
/// </summary>
/// <param name="userId">User Id</param>
[ProducesResponseType(typeof(List<GroupDetailDTO>), 200)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)]
[HttpGet("zigbee2Mqtt/{userId}")]
public ObjectResult GetGroupsFromZigbee2Mqtt(string userId)
{
try
{
if (userId == null)
throw new ArgumentNullException("Incorrect parameters");
if (!UserService.IsExist(_UserDatabaseService, userId))
throw new KeyNotFoundException("User not found");
// GET ALL LOCAL GROUPS
var groups = MqttClientService.groups; // Be carefull, we only got the exact result after each connection
return new OkObjectResult(groups);
}
catch (ArgumentNullException ex)
{
return new BadRequestObjectResult(ex.Message) {};
}
catch (KeyNotFoundException ex)
{
return new BadRequestObjectResult(ex.Message) {};
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -131,18 +183,24 @@ namespace MyCore.Service.Controllers
/// </summary> /// </summary>
/// <param name="groupCreateOrUpdateDetail">Group to create</param> /// <param name="groupCreateOrUpdateDetail">Group to create</param>
[ProducesResponseType(typeof(GroupDetailDTO), 200)] [ProducesResponseType(typeof(GroupDetailDTO), 200)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 500)]
[HttpPost] [HttpPost]
public ObjectResult Create([FromBody] GroupCreateOrUpdateDetailDTO groupCreateOrUpdateDetail) public ObjectResult Create([FromBody] GroupCreateOrUpdateDetailDTO groupCreateOrUpdateDetail)
{ {
try try
{ {
if (groupCreateOrUpdateDetail == null) if (groupCreateOrUpdateDetail == null)
throw new KeyNotFoundException("Group is null"); throw new ArgumentNullException("Incorrect parameters");
GroupDetailDTO groupCreated = GroupService.CreateOrUpdate(this._GroupDatabaseService, this._DeviceDatabaseService, groupCreateOrUpdateDetail.UserId, groupCreateOrUpdateDetail, true); GroupDetailDTO groupCreated = GroupService.CreateOrUpdate(this._GroupDatabaseService, this._DeviceDatabaseService, groupCreateOrUpdateDetail.UserId, groupCreateOrUpdateDetail, true);
return new OkObjectResult(groupCreated); return new OkObjectResult(groupCreated);
} }
catch (ArgumentNullException ex)
{
return new BadRequestObjectResult(ex.Message) {};
}
catch (Exception ex) catch (Exception ex)
{ {
return new ObjectResult(ex.Message) { StatusCode = 500 }; return new ObjectResult(ex.Message) { StatusCode = 500 };
@ -154,13 +212,16 @@ namespace MyCore.Service.Controllers
/// </summary> /// </summary>
/// <param name="userId">User Id</param> /// <param name="userId">User Id</param>
[ProducesResponseType(typeof(List<GroupDetailDTO>), 200)] [ProducesResponseType(typeof(List<GroupDetailDTO>), 200)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)]
[HttpPost("{userId}/fromZigbee")] [HttpPost("{userId}/fromZigbee")]
public ObjectResult CreateDevicesFromZigbee2Mqtt(string userId) public ObjectResult CreateDevicesFromZigbee2Mqtt(string userId)
{ {
try try
{ {
if (userId == null) if (userId == null)
throw new InvalidOperationException("User not found"); throw new ArgumentNullException("Incorrect parameters");
if (!UserService.IsExist(_UserDatabaseService, userId)) if (!UserService.IsExist(_UserDatabaseService, userId))
throw new KeyNotFoundException("User not found"); throw new KeyNotFoundException("User not found");
@ -176,6 +237,14 @@ namespace MyCore.Service.Controllers
return new OkObjectResult(groupsDetail); return new OkObjectResult(groupsDetail);
} }
catch (ArgumentNullException ex)
{
return new BadRequestObjectResult(ex.Message) {};
}
catch (KeyNotFoundException ex)
{
return new BadRequestObjectResult(ex.Message) {};
}
catch (Exception ex) catch (Exception ex)
{ {
return new ObjectResult(ex.Message) { StatusCode = 500 }; return new ObjectResult(ex.Message) { StatusCode = 500 };
@ -187,11 +256,17 @@ namespace MyCore.Service.Controllers
/// </summary> /// </summary>
/// <param name="groupCreateOrUpdateDetail">group to update</param> /// <param name="groupCreateOrUpdateDetail">group to update</param>
[ProducesResponseType(typeof(GroupCreateOrUpdateDetailDTO), 200)] [ProducesResponseType(typeof(GroupCreateOrUpdateDetailDTO), 200)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)]
[HttpPut] [HttpPut]
public ObjectResult Update([FromBody] GroupCreateOrUpdateDetailDTO groupCreateOrUpdateDetail) public ObjectResult Update([FromBody] GroupCreateOrUpdateDetailDTO groupCreateOrUpdateDetail)
{ {
try try
{ {
if (groupCreateOrUpdateDetail == null)
throw new ArgumentNullException("Incorrect parameters");
if (!_GroupDatabaseService.IsExist(groupCreateOrUpdateDetail.Id)) if (!_GroupDatabaseService.IsExist(groupCreateOrUpdateDetail.Id))
throw new KeyNotFoundException("Group does not exist"); throw new KeyNotFoundException("Group does not exist");
@ -199,9 +274,13 @@ namespace MyCore.Service.Controllers
return new OkObjectResult(groupUpdated); return new OkObjectResult(groupUpdated);
} }
catch (ArgumentNullException ex)
{
return new BadRequestObjectResult(ex.Message) {};
}
catch (KeyNotFoundException ex) catch (KeyNotFoundException ex)
{ {
return new BadRequestObjectResult(ex.Message) { StatusCode = 404 }; return new NotFoundObjectResult(ex.Message) {};
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -214,33 +293,45 @@ namespace MyCore.Service.Controllers
/// </summary> /// </summary>
/// <param name="deviceId">Id of device to delete from the group</param> /// <param name="deviceId">Id of device to delete from the group</param>
/// <param name="groupId">Id of group </param> /// <param name="groupId">Id of group </param>
[ProducesResponseType(typeof(string), 202)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)]
[HttpDelete("{groupId}/device/{deviceId}")] [HttpDelete("{groupId}/device/{deviceId}")]
public ObjectResult Delete(string deviceId, string groupId) public ObjectResult Delete(string deviceId, string groupId)
{ {
try try
{ {
if (groupId != null && deviceId != null) if (groupId == null || deviceId == null)
{ throw new ArgumentNullException("Incorrect parameters");
if (_GroupDatabaseService.IsExist(groupId))
{
// Update group
Group group = _GroupDatabaseService.GetById(groupId);
group.DevicesIds = group.DevicesIds.Where(d => d != deviceId).ToList();
group.UpdatedDate = DateTime.Now;
_GroupDatabaseService.Update(group);
// Update device if (!_GroupDatabaseService.IsExist(groupId))
Device device = _DeviceDatabaseService.GetById(deviceId); throw new KeyNotFoundException("Group does not exist");
if (device != null)
{
device.GroupIds = device.GroupIds.Where(g => g != groupId).ToList();
device.UpdatedDate = DateTime.Now;
_DeviceDatabaseService.Update(device);
}
}
}
return new OkObjectResult(201); // Update group
Group group = _GroupDatabaseService.GetById(groupId);
group.DevicesIds = group.DevicesIds.Where(d => d != deviceId).ToList();
group.UpdatedDate = DateTime.Now;
_GroupDatabaseService.Update(group);
// Update device
Device device = _DeviceDatabaseService.GetById(deviceId);
if (device == null)
throw new KeyNotFoundException("Device does not exist");
device.GroupIds = device.GroupIds.Where(g => g != groupId).ToList();
device.UpdatedDate = DateTime.Now;
_DeviceDatabaseService.Update(device);
return new ObjectResult("Device has been successfully removed from specified group") { StatusCode = 202 };
}
catch (ArgumentNullException ex)
{
return new BadRequestObjectResult(ex.Message) {};
}
catch (KeyNotFoundException ex)
{
return new NotFoundObjectResult(ex.Message) {};
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -252,61 +343,42 @@ namespace MyCore.Service.Controllers
/// Delete a group /// Delete a group
/// </summary> /// </summary>
/// <param name="groupId">Id of group to delete</param> /// <param name="groupId">Id of group to delete</param>
[ProducesResponseType(typeof(string), 202)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)]
[HttpDelete("{groupId}")] [HttpDelete("{groupId}")]
public ObjectResult Delete(string groupId) public ObjectResult Delete(string groupId)
{ {
try try
{ {
if (groupId != null) if (groupId == null)
throw new ArgumentNullException("Incorrect parameters");
if (!_GroupDatabaseService.IsExist(groupId))
throw new KeyNotFoundException("Group does not exist");
Group group = _GroupDatabaseService.GetById(groupId);
// Delete group from all devices
List<Device> devices = _DeviceDatabaseService.GetByLocation(group.UserId, groupId);
foreach (var device in devices)
{ {
if (_GroupDatabaseService.IsExist(groupId)) device.GroupIds = device.GroupIds.Where(g => g != groupId).ToList();
{ device.UpdatedDate = DateTime.Now;
Group group = _GroupDatabaseService.GetById(groupId); _DeviceDatabaseService.Update(device);
// Delete group from all devices
List<Device> devices = _DeviceDatabaseService.GetByLocation(group.UserId, groupId);
foreach (var device in devices)
{
device.GroupIds = device.GroupIds.Where(g => g != groupId).ToList();
device.UpdatedDate = DateTime.Now;
_DeviceDatabaseService.Update(device);
}
// Delete group
_GroupDatabaseService.Remove(groupId);
}
} }
// Delete group
_GroupDatabaseService.Remove(groupId);
return new OkObjectResult(201); return new ObjectResult("The group has been successfully deleted") { StatusCode = 202 };
} }
catch (Exception ex) catch (ArgumentNullException ex)
{ {
return new ObjectResult(ex.Message) { StatusCode = 500 }; return new BadRequestObjectResult(ex.Message) {};
} }
} catch (KeyNotFoundException ex)
/// <summary>
/// Get all zigbee2Mqtt groups
/// </summary>
/// <param name="userId">User Id</param>
[ProducesResponseType(typeof(List<GroupDetailDTO>), 200)]
[HttpGet("zigbee2Mqtt/{userId}")]
public ObjectResult GetGroupsFromZigbee2Mqtt(string userId)
{
try
{ {
if (userId == null) return new NotFoundObjectResult(ex.Message) {};
throw new InvalidOperationException("User not found");
if (!UserService.IsExist(_UserDatabaseService, userId))
throw new KeyNotFoundException("User not found");
// GET ALL LOCAL GROUPS
var groups = MqttClientService.groups; // Be carefull, we only got the exact result after each connection
return new OkObjectResult(groups);
}
catch (InvalidOperationException ex)
{
return new BadRequestObjectResult(ex.Message) { StatusCode = 400 };
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -318,20 +390,32 @@ namespace MyCore.Service.Controllers
/// Delete all group for a specified /// Delete all group for a specified
/// </summary> /// </summary>
/// <param name="userId">Id of user</param> /// <param name="userId">Id of user</param>
[ProducesResponseType(typeof(string), 202)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)]
[HttpDelete("user/{userId}")] [HttpDelete("user/{userId}")]
public ObjectResult DeleteAllForUser(string userId) public ObjectResult DeleteAllForUser(string userId)
{ {
try try
{ {
if (userId != null) if (userId == null)
{ throw new ArgumentNullException("Incorrect parameters");
if (_UserDatabaseService.IsExist(userId))
{
_GroupDatabaseService.RemoveForUser(userId);
}
}
return new OkObjectResult(201); if (!_UserDatabaseService.IsExist(userId))
throw new KeyNotFoundException("User does not exist");
_GroupDatabaseService.RemoveForUser(userId);
return new ObjectResult("All group linked with specified user has been successfully deleted") { StatusCode = 202 };
}
catch (ArgumentNullException ex)
{
return new BadRequestObjectResult(ex.Message) {};
}
catch (KeyNotFoundException ex)
{
return new NotFoundObjectResult(ex.Message) {};
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@ -33,13 +33,15 @@ namespace MyCore.Controllers
/// </summary> /// </summary>
/// <param name="mqttMessageDTO">Message to send</param> /// <param name="mqttMessageDTO">Message to send</param>
[ProducesResponseType(typeof(bool), 200)] [ProducesResponseType(typeof(bool), 200)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 500)]
[HttpPost] [HttpPost]
public async Task<ObjectResult> PublishMessage([FromBody] MqttMessageDTO mqttMessageDTO) public async Task<ObjectResult> PublishMessage([FromBody] MqttMessageDTO mqttMessageDTO)
{ {
try try
{ {
if (mqttMessageDTO == null) if (mqttMessageDTO == null)
throw new KeyNotFoundException("message is null"); throw new ArgumentNullException("Incorrect parameters");
bool isSucess = false; bool isSucess = false;
@ -68,6 +70,10 @@ namespace MyCore.Controllers
return new OkObjectResult(isSucess); return new OkObjectResult(isSucess);
} }
catch (ArgumentNullException ex)
{
return new BadRequestObjectResult(ex.Message) {};
}
catch (Exception ex) catch (Exception ex)
{ {
return new ObjectResult(ex.Message) { StatusCode = 500 }; return new ObjectResult(ex.Message) { StatusCode = 500 };

View File

@ -19,10 +19,10 @@ namespace MyCore.Controllers
public class LayoutController : ControllerBase public class LayoutController : ControllerBase
{ {
// GET api/values
/// <summary> /// <summary>
/// It's a test ! :) /// It's a test ! :)
/// </summary> /// </summary>
[ProducesResponseType(typeof(IEnumerable<PanelSection>), 200)]
[AllowAnonymous] [AllowAnonymous]
[HttpGet("panelSection")] [HttpGet("panelSection")]
public ActionResult<IEnumerable<PanelSection>> Get() public ActionResult<IEnumerable<PanelSection>> Get()

View File

@ -31,20 +31,43 @@ namespace MyCore.Controllers
_userService = userService; _userService = userService;
} }
/// <summary>
/// Connect user
/// </summary>
/// <param name="loginDTO">login info</param>
[ProducesResponseType(typeof(UserInfo), 200)]
[ProducesResponseType(typeof(string), 401)]
[ProducesResponseType(typeof(string), 500)]
[AllowAnonymous] [AllowAnonymous]
[HttpPost] [HttpPost]
public ActionResult<UserInfo> ConnectUser([FromBody] LoginDTO loginDTO) public ActionResult<UserInfo> ConnectUser([FromBody] LoginDTO loginDTO)
{ {
//string test = _TokenService.GenerateSHA256String(password); try
if (IsValidUserAndPasswordCombination(loginDTO.Email, loginDTO.Password))
{ {
UserInfo user = _userService.GetByEmail(loginDTO.Email); UserInfo user = null;
user.Token = _tokenService.GenerateToken(loginDTO.Email).ToString(); if (IsValidUserAndPasswordCombination(loginDTO.Email, loginDTO.Password))
{
user = _userService.GetByEmail(loginDTO.Email);
user.Token = _tokenService.GenerateToken(loginDTO.Email).ToString();
}
return user; if (user != null)
{
return new OkObjectResult(user);
}
else {
throw new UnauthorizedAccessException("Bad credential");
}
}
catch (UnauthorizedAccessException ex)
{
return new UnauthorizedObjectResult(ex.Message) {};
}
catch (Exception ex)
{
return new ObjectResult(ex.Message) { StatusCode = 500 };
} }
return BadRequest();
} }
private bool IsValidUserAndPasswordCombination(string email, string password) private bool IsValidUserAndPasswordCombination(string email, string password)

View File

@ -29,11 +29,11 @@ namespace MyCore.Controllers
_tokenService = tokenService; _tokenService = tokenService;
} }
// GET api/user
/// <summary> /// <summary>
/// Get a list of user /// Get a list of user
/// </summary> /// </summary>
[ProducesResponseType(typeof(List<UserInfo>), 200)] [ProducesResponseType(typeof(List<UserInfo>), 200)]
[ProducesResponseType(typeof(string), 500)]
[HttpGet] [HttpGet]
public ObjectResult Get() public ObjectResult Get()
{ {
@ -50,64 +50,71 @@ namespace MyCore.Controllers
} }
// GET api/user/5
/// <summary> /// <summary>
/// Get a specific user /// Get a specific user
/// </summary> /// </summary>
/// <param name="id">id user</param> /// <param name="id">id user</param>
[ProducesResponseType(typeof(UserInfoDetailDTO), 200)] [ProducesResponseType(typeof(UserInfoDetailDTO), 200)]
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)]
[HttpGet("{id}")] [HttpGet("{id}")]
public ObjectResult Get(string id) public ObjectResult Get(string id)
{ {
try try
{ {
// TODO ! Add object id verification
UserInfo user = _userService.GetById(id); UserInfo user = _userService.GetById(id);
if (user == null) if (user == null)
{ throw new KeyNotFoundException("This user was not found");
return Conflict("This user was not found");
}
return new OkObjectResult(user.ToDTO()); return new OkObjectResult(user.ToDTO());
} }
catch (KeyNotFoundException ex)
{
return new NotFoundObjectResult(ex.Message) {};
}
catch (Exception ex) catch (Exception ex)
{ {
return new ObjectResult(ex.Message) { StatusCode = 500 }; return new ObjectResult(ex.Message) { StatusCode = 500 };
} }
} }
// POST: User/Create
/// <summary> /// <summary>
/// /// Create an user
/// </summary> /// </summary>
/// <param name="newUser">New user info</param>
[AllowAnonymous] [AllowAnonymous]
[ProducesResponseType(typeof(UserInfoDetailDTO), 200)] [ProducesResponseType(typeof(UserInfoDetailDTO), 200)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 409)]
[ProducesResponseType(typeof(string), 500)]
[HttpPost] [HttpPost]
public ObjectResult CreateUser([FromBody] UserInfo newUser) public ObjectResult CreateUser([FromBody] UserInfo newUser)
{ {
try try
{ {
if (newUser != null) if (newUser == null)
{ throw new ArgumentNullException("User param is null");
newUser.Token = _tokenService.GenerateToken(newUser.Email).ToString();
newUser.DateCreation = DateTime.Now;
List<UserInfo> users = _userService.GetAll(); newUser.Token = _tokenService.GenerateToken(newUser.Email).ToString();
newUser.DateCreation = DateTime.Now;
if (users.Select(u => u.Email).Contains(newUser.Email)) List<UserInfo> users = _userService.GetAll();
{
return Conflict("This Email is already used");
}
UserInfo userCreated = _userService.Create(newUser); if (users.Select(u => u.Email).Contains(newUser.Email))
throw new InvalidOperationException("This Email is already used");
return new OkObjectResult(userCreated.ToDTO()); UserInfo userCreated = _userService.Create(newUser);
}
else { return new OkObjectResult(userCreated.ToDTO());
// TODO }
return new ObjectResult("An error has occurred") { StatusCode = 500 }; catch (ArgumentNullException ex)
} {
return new BadRequestObjectResult(ex.Message) {};
}
catch (InvalidOperationException ex)
{
return new ConflictObjectResult(ex.Message) {};
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -116,35 +123,38 @@ namespace MyCore.Controllers
} }
// PUT: User/Update
/// <summary> /// <summary>
/// /// Update an user
/// </summary> /// </summary>
/// <param name="updatedUser">User to update</param>
[ProducesResponseType(typeof(UserInfoDetailDTO), 200)] [ProducesResponseType(typeof(UserInfoDetailDTO), 200)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)]
[HttpPut] [HttpPut]
public ObjectResult UpdateUser([FromBody] UserInfo updatedUser) public ObjectResult UpdateUser([FromBody] UserInfo updatedUser)
{ {
try try
{ {
// TODO ! Add object id verification if (updatedUser == null)
throw new ArgumentNullException("User param is null");
if (updatedUser != null) UserInfo user = _userService.GetById(updatedUser.Id);
{
UserInfo user = _userService.GetById(updatedUser.Id);
if (user != null) if (user == null)
{ throw new KeyNotFoundException("User does not exist");
return NotFound("The user was not found");
}
UserInfo userModified = _userService.Update(updatedUser.Id, updatedUser); UserInfo userModified = _userService.Update(updatedUser.Id, updatedUser);
return new OkObjectResult(userModified.ToDTO()); return new OkObjectResult(userModified.ToDTO());
} }
else { catch (ArgumentNullException ex)
// TODO {
return new ObjectResult("An error has occurred") { StatusCode = 500 }; return new BadRequestObjectResult(ex.Message) {};
} }
catch (KeyNotFoundException ex)
{
return new NotFoundObjectResult(ex.Message) {};
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -153,32 +163,39 @@ namespace MyCore.Controllers
} }
// DELETE: User/Delete /// <summary>
/// Delete an user
/// </summary>
/// <param name="id">Id of user to delete</param>
[ProducesResponseType(typeof(string), 202)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)]
[HttpDelete("{id}")] [HttpDelete("{id}")]
public ObjectResult DeleteUser(string id) public ObjectResult DeleteUser(string id)
{ {
try try
{ {
// TODO ! Add object id verification if (id == null)
throw new ArgumentNullException("User param is null");
if (id != null) UserInfo user = _userService.GetById(id);
{
UserInfo user = _userService.GetById(id);
if (user != null) if (user == null)
{ throw new KeyNotFoundException("User does not exist");
return NotFound("The user was not found");
}
_userService.Remove(id); _userService.Remove(id);
return Accepted("The user has been deleted"); return new ObjectResult("The user has been deleted") { StatusCode = 202 };
}
else }
{ catch (ArgumentNullException ex)
// TODO {
return new ObjectResult("An error has occurred") { StatusCode = 500 }; return new BadRequestObjectResult(ex.Message) { };
} }
catch (KeyNotFoundException ex)
{
return new NotFoundObjectResult(ex.Message) { };
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@ -42,6 +42,7 @@ namespace MyCore.Service.Controllers
/// </summary> /// </summary>
/// <param name="userId">Id of user</param> /// <param name="userId">Id of user</param>
[ProducesResponseType(typeof(List<RoomSummaryDTO>), 200)] [ProducesResponseType(typeof(List<RoomSummaryDTO>), 200)]
[ProducesResponseType(typeof(string), 500)]
[HttpGet("{userId}")] [HttpGet("{userId}")]
public ObjectResult GetAll(string userId) public ObjectResult GetAll(string userId)
{ {
@ -65,21 +66,32 @@ namespace MyCore.Service.Controllers
/// <param name="userId">user id</param> /// <param name="userId">user id</param>
/// <param name="roomId">room id</param> /// <param name="roomId">room id</param>
[ProducesResponseType(typeof(RoomDetailDTO), 200)] [ProducesResponseType(typeof(RoomDetailDTO), 200)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)]
[HttpGet("detail/{roomId}")] [HttpGet("detail/{roomId}")]
public ObjectResult GetDetail(string userId, string roomId) public ObjectResult GetDetail(string userId, string roomId)
{ {
try try
{ {
if (userId != null && roomId != null) if (userId == null || roomId == null)
{ throw new ArgumentNullException("Incorrect parameters");
Room room = _RoomDatabaseService.GetById(roomId);
List<Device> devices = _DeviceDatabaseService.GetByLocation(room.UserId, roomId);
return new OkObjectResult(room.ToDTO(devices.Select(d => d.ToDTO()).ToList())); Room room = _RoomDatabaseService.GetById(roomId);
} if (room == null)
else { throw new KeyNotFoundException("Room does not exist");
return new ObjectResult("Invalid parameters") { StatusCode = 400 }; List<Device> devices = _DeviceDatabaseService.GetByLocation(room.UserId, roomId);
}
return new OkObjectResult(room.ToDTO(devices.Select(d => d.ToDTO()).ToList()));
}
catch (ArgumentNullException ex)
{
return new BadRequestObjectResult(ex.Message) { };
}
catch (KeyNotFoundException ex)
{
return new NotFoundObjectResult(ex.Message) { };
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -92,18 +104,24 @@ namespace MyCore.Service.Controllers
/// </summary> /// </summary>
/// <param name="roomCreateOrUpdateDetail">Room to create</param> /// <param name="roomCreateOrUpdateDetail">Room to create</param>
[ProducesResponseType(typeof(RoomDetailDTO), 200)] [ProducesResponseType(typeof(RoomDetailDTO), 200)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 500)]
[HttpPost] [HttpPost]
public ObjectResult Create([FromBody] RoomCreateOrUpdateDetailDTO roomCreateOrUpdateDetail) public ObjectResult Create([FromBody] RoomCreateOrUpdateDetailDTO roomCreateOrUpdateDetail)
{ {
try try
{ {
if (roomCreateOrUpdateDetail == null) if (roomCreateOrUpdateDetail == null)
throw new KeyNotFoundException("Room is null"); throw new ArgumentNullException("Incorrect parameters");
RoomDetailDTO roomCreated = RoomService.CreateOrUpdate(this._RoomDatabaseService, this._DeviceDatabaseService, roomCreateOrUpdateDetail.UserId, roomCreateOrUpdateDetail, true); RoomDetailDTO roomCreated = RoomService.CreateOrUpdate(this._RoomDatabaseService, this._DeviceDatabaseService, roomCreateOrUpdateDetail.UserId, roomCreateOrUpdateDetail, true);
return new OkObjectResult(roomCreated); return new OkObjectResult(roomCreated);
} }
catch (ArgumentNullException ex)
{
return new BadRequestObjectResult(ex.Message) { };
}
catch (Exception ex) catch (Exception ex)
{ {
return new ObjectResult(ex.Message) { StatusCode = 500 }; return new ObjectResult(ex.Message) { StatusCode = 500 };
@ -115,6 +133,8 @@ namespace MyCore.Service.Controllers
/// </summary> /// </summary>
/// <param name="roomCreateOrUpdateDetail">room to update</param> /// <param name="roomCreateOrUpdateDetail">room to update</param>
[ProducesResponseType(typeof(RoomCreateOrUpdateDetailDTO), 200)] [ProducesResponseType(typeof(RoomCreateOrUpdateDetailDTO), 200)]
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)]
[HttpPut] [HttpPut]
public ObjectResult Update([FromBody] RoomCreateOrUpdateDetailDTO roomCreateOrUpdateDetail) public ObjectResult Update([FromBody] RoomCreateOrUpdateDetailDTO roomCreateOrUpdateDetail)
{ {
@ -129,7 +149,7 @@ namespace MyCore.Service.Controllers
} }
catch (KeyNotFoundException ex) catch (KeyNotFoundException ex)
{ {
return new BadRequestObjectResult(ex.Message) { StatusCode = 404 }; return new NotFoundObjectResult(ex.Message) {};
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -142,32 +162,47 @@ namespace MyCore.Service.Controllers
/// </summary> /// </summary>
/// <param name="deviceId">Id of device to delete from the room</param> /// <param name="deviceId">Id of device to delete from the room</param>
/// <param name="roomId">Id of room </param> /// <param name="roomId">Id of room </param>
[ProducesResponseType(typeof(string), 202)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)]
[HttpDelete("{roomId}/device/{deviceId}")] [HttpDelete("{roomId}/device/{deviceId}")]
public ObjectResult Delete(string deviceId, string roomId) public ObjectResult Delete(string deviceId, string roomId)
{ {
try try
{ {
if (roomId != null && deviceId != null) if (roomId == null && deviceId == null)
{ throw new ArgumentNullException("Incorrect parameters");
if (_RoomDatabaseService.IsExist(roomId))
{
// Update room
Room room = _RoomDatabaseService.GetById(roomId);
room.DevicesIds = room.DevicesIds.Where(d => d != deviceId).ToList();
room.UpdatedDate = DateTime.Now;
_RoomDatabaseService.Update(room);
// Update device if (!_RoomDatabaseService.IsExist(roomId))
Device device = _DeviceDatabaseService.GetById(deviceId); throw new KeyNotFoundException("Room does not exist");
if (device != null) {
device.LocationId = null;
device.UpdatedDate = DateTime.Now;
_DeviceDatabaseService.Update(device);
}
}
}
return new OkObjectResult(201); // Update room
Room room = _RoomDatabaseService.GetById(roomId);
room.DevicesIds = room.DevicesIds.Where(d => d != deviceId).ToList();
room.UpdatedDate = DateTime.Now;
_RoomDatabaseService.Update(room);
// Update device
Device device = _DeviceDatabaseService.GetById(deviceId);
if (device == null)
throw new KeyNotFoundException("Device does not exist");
device.LocationId = null;
device.UpdatedDate = DateTime.Now;
_DeviceDatabaseService.Update(device);
return new OkObjectResult("Device has been removed from specified room") { StatusCode = 202 };
}
catch (ArgumentNullException ex)
{
return new BadRequestObjectResult(ex.Message) { };
}
catch (KeyNotFoundException ex)
{
return new NotFoundObjectResult(ex.Message) { };
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -179,30 +214,42 @@ namespace MyCore.Service.Controllers
/// Delete a room /// Delete a room
/// </summary> /// </summary>
/// <param name="roomId">Id of room to delete</param> /// <param name="roomId">Id of room to delete</param>
[ProducesResponseType(typeof(string), 202)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)]
[HttpDelete("{roomId}")] [HttpDelete("{roomId}")]
public ObjectResult Delete(string roomId) public ObjectResult Delete(string roomId)
{ {
try try
{ {
if (roomId != null) if (roomId == null)
{ throw new ArgumentNullException("Incorrect parameters");
if (_RoomDatabaseService.IsExist(roomId))
{ if (!_RoomDatabaseService.IsExist(roomId))
Room room = _RoomDatabaseService.GetById(roomId); throw new KeyNotFoundException("Room does not exist");
// Delete location from all devices
List<Device> devices = _DeviceDatabaseService.GetByLocation(room.UserId, roomId);
foreach (var device in devices)
{
device.LocationId = null;
device.UpdatedDate = DateTime.Now;
_DeviceDatabaseService.Update(device);
}
// Delete room
_RoomDatabaseService.Remove(roomId);
}
}
return new OkObjectResult(201); Room room = _RoomDatabaseService.GetById(roomId);
// Delete location from all devices
List<Device> devices = _DeviceDatabaseService.GetByLocation(room.UserId, roomId);
foreach (var device in devices)
{
device.LocationId = null;
device.UpdatedDate = DateTime.Now;
_DeviceDatabaseService.Update(device);
}
// Delete room
_RoomDatabaseService.Remove(roomId);
return new OkObjectResult("Room has been successfully deleted") { StatusCode = 202 };
}
catch (ArgumentNullException ex)
{
return new BadRequestObjectResult(ex.Message) { };
}
catch (KeyNotFoundException ex)
{
return new NotFoundObjectResult(ex.Message) { };
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -211,23 +258,35 @@ namespace MyCore.Service.Controllers
} }
/// <summary> /// <summary>
/// Delete all room for a specified /// Delete all room for a specified user
/// </summary> /// </summary>
/// <param name="userId">Id of user</param> /// <param name="userId">Id of user</param>
[ProducesResponseType(typeof(string), 202)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)]
[HttpDelete("user/{userId}")] [HttpDelete("user/{userId}")]
public ObjectResult DeleteAllForUser(string userId) public ObjectResult DeleteAllForUser(string userId)
{ {
try try
{ {
if (userId != null) if (userId == null)
{ throw new ArgumentNullException("Incorrect parameters");
if (_UserDatabaseService.IsExist(userId))
{
_RoomDatabaseService.RemoveForUser(userId);
}
}
return new OkObjectResult(201); if (!_UserDatabaseService.IsExist(userId))
throw new KeyNotFoundException("User does not exist");
_RoomDatabaseService.RemoveForUser(userId);
return new OkObjectResult("All room associated to specified user has been removed") { StatusCode = 202 };
}
catch (ArgumentNullException ex)
{
return new BadRequestObjectResult(ex.Message) { };
}
catch (KeyNotFoundException ex)
{
return new NotFoundObjectResult(ex.Message) { };
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@ -108,7 +108,7 @@ namespace Mqtt.Client.AspNetCore.Services
throw new AuthenticationException("Bad service username or password"); throw new AuthenticationException("Bad service username or password");
} }
string stringForMD5 = resultToken.userid + resultToken.key; string stringForMD5 = resultToken?.userid + resultToken?.key;
string hashed_password = CreateMD5(stringForMD5).ToLower(); string hashed_password = CreateMD5(stringForMD5).ToLower();
// Check if we can hardcode it -> seems ok 20/01/2020 // Check if we can hardcode it -> seems ok 20/01/2020
@ -117,13 +117,13 @@ namespace Mqtt.Client.AspNetCore.Services
GenerateClientAndAppId(uuid); GenerateClientAndAppId(uuid);
options = new MqttClientOptionsBuilder() options = new MqttClientOptionsBuilder()
.WithClientId(clientId) .WithClientId(clientId)
.WithTcpServer(domain, port) .WithTcpServer(domain, port)
.WithCredentials(resultToken.userid, hashed_password) .WithCredentials(resultToken?.userid, hashed_password)
.WithCleanSession() .WithCleanSession()
.WithTls() .WithTls()
.WithProtocolVersion(MqttProtocolVersion.V311) .WithProtocolVersion(MqttProtocolVersion.V311)
.Build(); .Build();
client = new MqttFactory().CreateMqttClient(); client = new MqttFactory().CreateMqttClient();
@ -256,35 +256,43 @@ namespace Mqtt.Client.AspNetCore.Services
var message = BuildMQTTMessage(method, namespaceVar, payloadVar); var message = BuildMQTTMessage(method, namespaceVar, payloadVar);
PublishMessage(topic, message); if (message != null) {
PublishMessage(topic, message);
}
} }
private static string BuildMQTTMessage(Method method, string namespaceVar, string payloadVar) private static string BuildMQTTMessage(Method method, string namespaceVar, string payloadVar)
{ {
HeaderMqtt headerMqtt = new HeaderMqtt(); HeaderMqtt headerMqtt = new HeaderMqtt();
headerMqtt.from = $"/app/{resultToken.userid}-{appId.ToLower()}/subscribe"; if (resultToken != null)
headerMqtt.messageId = CreateMD5(GenerateNonce(16).ToUpper()).ToLower(); {
headerMqtt.method = method.ToString(); headerMqtt.from = $"/app/{resultToken.userid}-{appId.ToLower()}/subscribe";
headerMqtt.Namespace = namespaceVar; headerMqtt.messageId = CreateMD5(GenerateNonce(16).ToUpper()).ToLower();
headerMqtt.payloadVersion = 1; headerMqtt.method = method.ToString();
headerMqtt.timestamp = new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds(); headerMqtt.Namespace = namespaceVar;
headerMqtt.sign = CreateMD5($"{headerMqtt.messageId}{resultToken.key}{(headerMqtt.timestamp).ToString()}").ToLower(); headerMqtt.payloadVersion = 1;
headerMqtt.timestamp = new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds();
headerMqtt.sign = CreateMD5($"{headerMqtt.messageId}{resultToken.key}{(headerMqtt.timestamp).ToString()}").ToLower();
RequestMQTT requestMQTT = new RequestMQTT(); RequestMQTT requestMQTT = new RequestMQTT();
requestMQTT.header = headerMqtt; requestMQTT.header = headerMqtt;
if (payloadVar != null) if (payloadVar != null)
requestMQTT.payload = JsonConvert.DeserializeObject(payloadVar); requestMQTT.payload = JsonConvert.DeserializeObject(payloadVar);
else else
requestMQTT.payload = new Object(); requestMQTT.payload = new Object();
var data = JsonConvert.SerializeObject(requestMQTT); var data = JsonConvert.SerializeObject(requestMQTT);
// Change Namespace to namespace // Change Namespace to namespace
data = data.Replace("Namespace", "namespace"); data = data.Replace("Namespace", "namespace");
return data; return data;
}
else {
return null;
}
} }
public async Task HandleDisconnectedAsync(MqttClientDisconnectedEventArgs eventArgs) public async Task HandleDisconnectedAsync(MqttClientDisconnectedEventArgs eventArgs)

View File

@ -226,10 +226,10 @@ namespace MyCore.Services.Devices
System.Console.WriteLine($"Yeelight type !"); System.Console.WriteLine($"Yeelight type !");
// Get device last state // Get device last state
var dic = new List<State>(); var dic = new List<AutomationState>();
if (actionDeviceToTest.LastState != null) if (actionDeviceToTest.LastState != null)
{ {
dic = JsonConvert.DeserializeObject<List<State>>(actionDeviceToTest.LastState); dic = JsonConvert.DeserializeObject<List<AutomationState>>(actionDeviceToTest.LastState);
} }
try try
@ -628,8 +628,8 @@ namespace MyCore.Services.Devices
if (zigbeeDevice != null && eventConvert.type == "device_announce") // Check if we can not hardcode that.. if (zigbeeDevice != null && eventConvert.type == "device_announce") // Check if we can not hardcode that..
{ {
var status = new List<State>(); var status = new List<AutomationState>();
var state = new State(); var state = new AutomationState();
state.Name = "state"; state.Name = "state";
state.Value = "on"; state.Value = "on";
status.Add(state); status.Add(state);

View File

@ -315,7 +315,7 @@ namespace MyCore.Services.Devices
properties.Add("presignedLastImageUrl", arlo.presignedLastImageUrl); properties.Add("presignedLastImageUrl", arlo.presignedLastImageUrl);
properties.Add("presignedFullFrameSnapshotUrl", arlo.presignedFullFrameSnapshotUrl); properties.Add("presignedFullFrameSnapshotUrl", arlo.presignedFullFrameSnapshotUrl);
properties.Add("presignedSnapshotUrl", arlo.presignedSnapshotUrl); properties.Add("presignedSnapshotUrl", arlo.presignedSnapshotUrl);
deviceDetailDTO.Properties = properties; deviceDetailDTO.Properties = JsonConvert.SerializeObject(properties);
break; break;
case "siren": case "siren":
deviceDetailDTO.Type = DeviceType.Sound; deviceDetailDTO.Type = DeviceType.Sound;
@ -420,7 +420,7 @@ namespace MyCore.Services.Devices
{ {
properties.Add(property.Key, property.Value); properties.Add(property.Key, property.Value);
} }
deviceDetailDTO.Properties = properties; deviceDetailDTO.Properties = JsonConvert.SerializeObject(properties);
List<string> supportedOperationsDTO = new List<string>(); List<string> supportedOperationsDTO = new List<string>();
foreach (var supportedOperation in light.SupportedOperations) foreach (var supportedOperation in light.SupportedOperations)
{ {

View File

@ -10,36 +10,36 @@ namespace MyCore.Services.MyControlPanel
{ {
public class LocationDatabaseService public class LocationDatabaseService
{ {
private readonly IMongoCollection<Location> _Locations; private readonly IMongoCollection<Place> _Locations;
public LocationDatabaseService(IConfiguration config) public LocationDatabaseService(IConfiguration config)
{ {
var client = new MongoClient(config.GetConnectionString("MyCoreDb")); var client = new MongoClient(config.GetConnectionString("MyCoreDb"));
var database = client.GetDatabase("MyCoreDb"); var database = client.GetDatabase("MyCoreDb");
_Locations = database.GetCollection<Location>("Locations"); _Locations = database.GetCollection<Place>("Locations");
} }
public List<Location> GetAll() public List<Place> GetAll()
{ {
return _Locations.Find(l => true).ToList(); return _Locations.Find(l => true).ToList();
} }
public Location GetById(string id) public Place GetById(string id)
{ {
return _Locations.Find<Location>(l => l.Id == id).FirstOrDefault(); return _Locations.Find<Place>(l => l.Id == id).FirstOrDefault();
} }
public bool IsExist(string id) public bool IsExist(string id)
{ {
return _Locations.Find<Location>(p => p.Id == id).FirstOrDefault() != null ? true : false; return _Locations.Find<Place>(p => p.Id == id).FirstOrDefault() != null ? true : false;
} }
public Location Create(Location location) public Place Create(Place location)
{ {
_Locations.InsertOne(location); _Locations.InsertOne(location);
return location; return location;
} }
public Location Update(string id, Location locationIn) public Place Update(string id, Place locationIn)
{ {
_Locations.ReplaceOne(location => location.Id == id, locationIn); _Locations.ReplaceOne(location => location.Id == id, locationIn);
return locationIn; return locationIn;

View File

@ -29,6 +29,11 @@ namespace MyCore.Services
return _screenDevices.Find<ScreenDevice>(m => m.Id == id).FirstOrDefault(); return _screenDevices.Find<ScreenDevice>(m => m.Id == id).FirstOrDefault();
} }
public bool IsExist(string id)
{
return _screenDevices.Find<ScreenDevice>(d => d.Id == id).FirstOrDefault() != null ? true : false;
}
public ScreenDevice Create(ScreenDevice device) public ScreenDevice Create(ScreenDevice device)
{ {
_screenDevices.InsertOne(device); _screenDevices.InsertOne(device);

View File

@ -84,11 +84,11 @@ namespace MyCore.Service.Services
scope = Security.Scope scope = Security.Scope
}; };
} }
/*catch (UnauthorizedAccessException ex) catch (UnauthorizedAccessException ex)
{ {
_logger?.LogError(ex, $"Authenticate error for user '{email}': unauthorized access"); _logger?.LogError(ex, $"Authenticate error for user '{email}': unauthorized access");
throw; throw;
}*/ }
catch (Exception ex) catch (Exception ex)
{ {
_logger?.LogError(ex, $"Authenticate error for user '{email}': {ex.Message}"); _logger?.LogError(ex, $"Authenticate error for user '{email}': {ex.Message}");

View File

@ -1,5 +1,4 @@
.gitignore .gitignore
.openapi-generator-ignore
.travis.yml .travis.yml
README.md README.md
doc/Action.md doc/Action.md
@ -12,6 +11,7 @@ doc/AutomationCreateOrUpdateDetailDTOAllOf.md
doc/AutomationDTO.md doc/AutomationDTO.md
doc/AutomationDetailDTO.md doc/AutomationDetailDTO.md
doc/AutomationDetailDTOAllOf.md doc/AutomationDetailDTOAllOf.md
doc/AutomationState.md
doc/AzureADAuthModel.md doc/AzureADAuthModel.md
doc/AzureApi.md doc/AzureApi.md
doc/Book.md doc/Book.md
@ -47,8 +47,8 @@ doc/MQTTApi.md
doc/MeansOfCommunication.md doc/MeansOfCommunication.md
doc/MqttMessageDTO.md doc/MqttMessageDTO.md
doc/OddApi.md doc/OddApi.md
doc/OddH2H.md
doc/OddNice.md doc/OddNice.md
doc/OddObject.md
doc/PanelMenuItem.md doc/PanelMenuItem.md
doc/PanelSection.md doc/PanelSection.md
doc/Provider.md doc/Provider.md
@ -61,10 +61,11 @@ doc/RoomSummaryDTO.md
doc/ScreenConfiguration.md doc/ScreenConfiguration.md
doc/ScreenDevice.md doc/ScreenDevice.md
doc/ScreenDeviceApi.md doc/ScreenDeviceApi.md
doc/ScreenWidget.md
doc/SmartGardenMessage.md doc/SmartGardenMessage.md
doc/SmartPrinterMessage.md doc/SmartPrinterMessage.md
doc/State.md
doc/TokenApi.md doc/TokenApi.md
doc/TokenDTO.md
doc/Trigger.md doc/Trigger.md
doc/TriggerType.md doc/TriggerType.md
doc/TwitterApi.md doc/TwitterApi.md
@ -75,7 +76,6 @@ doc/UserInfo.md
doc/UserInfoDetailDTO.md doc/UserInfoDetailDTO.md
doc/ValuesApi.md doc/ValuesApi.md
doc/ViewBy.md doc/ViewBy.md
doc/Widget.md
git_push.sh git_push.sh
lib/api.dart lib/api.dart
lib/api/authentication_api.dart lib/api/authentication_api.dart
@ -114,6 +114,7 @@ lib/model/automation_create_or_update_detail_dto_all_of.dart
lib/model/automation_detail_dto.dart lib/model/automation_detail_dto.dart
lib/model/automation_detail_dto_all_of.dart lib/model/automation_detail_dto_all_of.dart
lib/model/automation_dto.dart lib/model/automation_dto.dart
lib/model/automation_state.dart
lib/model/azure_ad_auth_model.dart lib/model/azure_ad_auth_model.dart
lib/model/book.dart lib/model/book.dart
lib/model/condition.dart lib/model/condition.dart
@ -138,8 +139,8 @@ lib/model/location_dto.dart
lib/model/login_dto.dart lib/model/login_dto.dart
lib/model/means_of_communication.dart lib/model/means_of_communication.dart
lib/model/mqtt_message_dto.dart lib/model/mqtt_message_dto.dart
lib/model/odd_h2_h.dart
lib/model/odd_nice.dart lib/model/odd_nice.dart
lib/model/odd_object.dart
lib/model/panel_menu_item.dart lib/model/panel_menu_item.dart
lib/model/panel_section.dart lib/model/panel_section.dart
lib/model/provider.dart lib/model/provider.dart
@ -149,9 +150,10 @@ lib/model/room_detail_dto.dart
lib/model/room_summary_dto.dart lib/model/room_summary_dto.dart
lib/model/screen_configuration.dart lib/model/screen_configuration.dart
lib/model/screen_device.dart lib/model/screen_device.dart
lib/model/screen_widget.dart
lib/model/smart_garden_message.dart lib/model/smart_garden_message.dart
lib/model/smart_printer_message.dart lib/model/smart_printer_message.dart
lib/model/state.dart lib/model/token_dto.dart
lib/model/trigger.dart lib/model/trigger.dart
lib/model/trigger_type.dart lib/model/trigger_type.dart
lib/model/twitter_auth_model.dart lib/model/twitter_auth_model.dart
@ -159,79 +161,4 @@ lib/model/user.dart
lib/model/user_info.dart lib/model/user_info.dart
lib/model/user_info_detail_dto.dart lib/model/user_info_detail_dto.dart
lib/model/view_by.dart lib/model/view_by.dart
lib/model/widget.dart
pubspec.yaml pubspec.yaml
test/action_test.dart
test/action_type_test.dart
test/authentication_api_test.dart
test/automation_api_test.dart
test/automation_create_or_update_detail_dto_all_of_test.dart
test/automation_create_or_update_detail_dto_test.dart
test/automation_detail_dto_all_of_test.dart
test/automation_detail_dto_test.dart
test/automation_dto_test.dart
test/automation_test.dart
test/azure_ad_auth_model_test.dart
test/azure_api_test.dart
test/book_test.dart
test/books_api_test.dart
test/condition_test.dart
test/condition_type_test.dart
test/condition_value_test.dart
test/connection_status_test.dart
test/device_api_test.dart
test/device_detail_dto_all_of_test.dart
test/device_detail_dto_test.dart
test/device_summary_dto_test.dart
test/device_test.dart
test/device_type_test.dart
test/electricity_production_test.dart
test/energy_api_test.dart
test/facebook_api_test.dart
test/facebook_auth_model_test.dart
test/google_api_test.dart
test/google_auth_model_test.dart
test/group_api_test.dart
test/group_create_or_update_detail_dto_all_of_test.dart
test/group_create_or_update_detail_dto_test.dart
test/group_detail_dto_all_of_test.dart
test/group_detail_dto_test.dart
test/group_summary_dto_test.dart
test/group_test.dart
test/iot_api_test.dart
test/layout_api_test.dart
test/location_dto_test.dart
test/login_dto_test.dart
test/means_of_communication_test.dart
test/mqtt_api_test.dart
test/mqtt_message_dto_test.dart
test/odd_api_test.dart
test/odd_h2_h_test.dart
test/odd_nice_test.dart
test/panel_menu_item_test.dart
test/panel_section_test.dart
test/provider_api_test.dart
test/provider_dto_test.dart
test/provider_test.dart
test/room_api_test.dart
test/room_create_or_update_detail_dto_test.dart
test/room_detail_dto_test.dart
test/room_summary_dto_test.dart
test/screen_configuration_test.dart
test/screen_device_api_test.dart
test/screen_device_test.dart
test/smart_garden_message_test.dart
test/smart_printer_message_test.dart
test/state_test.dart
test/token_api_test.dart
test/trigger_test.dart
test/trigger_type_test.dart
test/twitter_api_test.dart
test/twitter_auth_model_test.dart
test/user_api_test.dart
test/user_info_detail_dto_test.dart
test/user_info_test.dart
test/user_test.dart
test/values_api_test.dart
test/view_by_test.dart
test/widget_test.dart

View File

@ -60,13 +60,13 @@ try {
## Documentation for API Endpoints ## Documentation for API Endpoints
All URIs are relative to *http://192.168.31.140* All URIs are relative to *http://localhost:25049*
Class | Method | HTTP request | Description Class | Method | HTTP request | Description
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
*AuthenticationApi* | [**authenticationAuthenticateWithForm**](doc\/AuthenticationApi.md#authenticationauthenticatewithform) | **POST** /api/Authentication/Token | Authenticate with form parameters (used by Swagger test client) *AuthenticationApi* | [**authenticationAuthenticateWithForm**](doc\/AuthenticationApi.md#authenticationauthenticatewithform) | **POST** /api/Authentication/Token | Authenticate with form parameters (used by Swagger test client)
*AuthenticationApi* | [**authenticationAuthenticateWithJson**](doc\/AuthenticationApi.md#authenticationauthenticatewithjson) | **POST** /api/Authentication/Authenticate | Authenticate with Json parameters (used by most clients) *AuthenticationApi* | [**authenticationAuthenticateWithJson**](doc\/AuthenticationApi.md#authenticationauthenticatewithjson) | **POST** /api/Authentication/Authenticate | Authenticate with Json parameters (used by most clients)
*AutomationApi* | [**automationCreate**](doc\/AutomationApi.md#automationcreate) | **POST** /api/automation | *AutomationApi* | [**automationCreate**](doc\/AutomationApi.md#automationcreate) | **POST** /api/automation | Create an automation
*AutomationApi* | [**automationDelete**](doc\/AutomationApi.md#automationdelete) | **DELETE** /api/automation/{automationId} | Delete an automation *AutomationApi* | [**automationDelete**](doc\/AutomationApi.md#automationdelete) | **DELETE** /api/automation/{automationId} | Delete an automation
*AutomationApi* | [**automationDeleteAllForUser**](doc\/AutomationApi.md#automationdeleteallforuser) | **DELETE** /api/automation/user/{userId} | Delete all automation for a specified *AutomationApi* | [**automationDeleteAllForUser**](doc\/AutomationApi.md#automationdeleteallforuser) | **DELETE** /api/automation/user/{userId} | Delete all automation for a specified
*AutomationApi* | [**automationGetAll**](doc\/AutomationApi.md#automationgetall) | **GET** /api/automation/{userId} | Get all automations for the specified user *AutomationApi* | [**automationGetAll**](doc\/AutomationApi.md#automationgetall) | **GET** /api/automation/{userId} | Get all automations for the specified user
@ -81,7 +81,7 @@ Class | Method | HTTP request | Description
*DeviceApi* | [**deviceCreate**](doc\/DeviceApi.md#devicecreate) | **POST** /api/device | Create a device *DeviceApi* | [**deviceCreate**](doc\/DeviceApi.md#devicecreate) | **POST** /api/device | Create a device
*DeviceApi* | [**deviceCreateDevicesFromProvider**](doc\/DeviceApi.md#devicecreatedevicesfromprovider) | **POST** /api/device/{userId}/fromProvider/{providerId} | Create devices from provider *DeviceApi* | [**deviceCreateDevicesFromProvider**](doc\/DeviceApi.md#devicecreatedevicesfromprovider) | **POST** /api/device/{userId}/fromProvider/{providerId} | Create devices from provider
*DeviceApi* | [**deviceDelete**](doc\/DeviceApi.md#devicedelete) | **DELETE** /api/device/{deviceId} | Delete a device *DeviceApi* | [**deviceDelete**](doc\/DeviceApi.md#devicedelete) | **DELETE** /api/device/{deviceId} | Delete a device
*DeviceApi* | [**deviceDeleteAllForUser**](doc\/DeviceApi.md#devicedeleteallforuser) | **DELETE** /api/device/user/{userId} | Delete all device for a specified *DeviceApi* | [**deviceDeleteAllForUser**](doc\/DeviceApi.md#devicedeleteallforuser) | **DELETE** /api/device/user/{userId} | Delete all device for a specified user
*DeviceApi* | [**deviceDeleteDevicesFromProvider**](doc\/DeviceApi.md#devicedeletedevicesfromprovider) | **DELETE** /api/device/{userId}/fromProvider/{providerId} | Delete devices from provider *DeviceApi* | [**deviceDeleteDevicesFromProvider**](doc\/DeviceApi.md#devicedeletedevicesfromprovider) | **DELETE** /api/device/{userId}/fromProvider/{providerId} | Delete devices from provider
*DeviceApi* | [**deviceGetAll**](doc\/DeviceApi.md#devicegetall) | **GET** /api/device/{userId} | Get all devices summary *DeviceApi* | [**deviceGetAll**](doc\/DeviceApi.md#devicegetall) | **GET** /api/device/{userId} | Get all devices summary
*DeviceApi* | [**deviceGetDetail**](doc\/DeviceApi.md#devicegetdetail) | **GET** /api/device/detail/{deviceId} | Get a specific device info *DeviceApi* | [**deviceGetDetail**](doc\/DeviceApi.md#devicegetdetail) | **GET** /api/device/detail/{deviceId} | Get a specific device info
@ -116,23 +116,23 @@ Class | Method | HTTP request | Description
*RoomApi* | [**roomCreate**](doc\/RoomApi.md#roomcreate) | **POST** /api/room | Create a room *RoomApi* | [**roomCreate**](doc\/RoomApi.md#roomcreate) | **POST** /api/room | Create a room
*RoomApi* | [**roomDelete**](doc\/RoomApi.md#roomdelete) | **DELETE** /api/room/{roomId}/device/{deviceId} | Delete device from a room *RoomApi* | [**roomDelete**](doc\/RoomApi.md#roomdelete) | **DELETE** /api/room/{roomId}/device/{deviceId} | Delete device from a room
*RoomApi* | [**roomDelete2**](doc\/RoomApi.md#roomdelete2) | **DELETE** /api/room/{roomId} | Delete a room *RoomApi* | [**roomDelete2**](doc\/RoomApi.md#roomdelete2) | **DELETE** /api/room/{roomId} | Delete a room
*RoomApi* | [**roomDeleteAllForUser**](doc\/RoomApi.md#roomdeleteallforuser) | **DELETE** /api/room/user/{userId} | Delete all room for a specified *RoomApi* | [**roomDeleteAllForUser**](doc\/RoomApi.md#roomdeleteallforuser) | **DELETE** /api/room/user/{userId} | Delete all room for a specified user
*RoomApi* | [**roomGetAll**](doc\/RoomApi.md#roomgetall) | **GET** /api/room/{userId} | Get all rooms for the specified user *RoomApi* | [**roomGetAll**](doc\/RoomApi.md#roomgetall) | **GET** /api/room/{userId} | Get all rooms for the specified user
*RoomApi* | [**roomGetDetail**](doc\/RoomApi.md#roomgetdetail) | **GET** /api/room/detail/{roomId} | Get detail info of a specified room *RoomApi* | [**roomGetDetail**](doc\/RoomApi.md#roomgetdetail) | **GET** /api/room/detail/{roomId} | Get detail info of a specified room
*RoomApi* | [**roomUpdate**](doc\/RoomApi.md#roomupdate) | **PUT** /api/room | Update a room *RoomApi* | [**roomUpdate**](doc\/RoomApi.md#roomupdate) | **PUT** /api/room | Update a room
*ScreenDeviceApi* | [**screenDeviceCreateDevice**](doc\/ScreenDeviceApi.md#screendevicecreatedevice) | **POST** /api/device/screen | *ScreenDeviceApi* | [**screenDeviceCreateDevice**](doc\/ScreenDeviceApi.md#screendevicecreatedevice) | **POST** /api/device/screen | Create screen device
*ScreenDeviceApi* | [**screenDeviceDeleteDevice**](doc\/ScreenDeviceApi.md#screendevicedeletedevice) | **DELETE** /api/device/screen/{deviceId} | *ScreenDeviceApi* | [**screenDeviceDeleteDevice**](doc\/ScreenDeviceApi.md#screendevicedeletedevice) | **DELETE** /api/device/screen/{deviceId} | Delete device
*ScreenDeviceApi* | [**screenDeviceGetAllScreenDevices**](doc\/ScreenDeviceApi.md#screendevicegetallscreendevices) | **GET** /api/device/screen | *ScreenDeviceApi* | [**screenDeviceGetAllScreenDevices**](doc\/ScreenDeviceApi.md#screendevicegetallscreendevices) | **GET** /api/device/screen | Get all screen devices
*ScreenDeviceApi* | [**screenDeviceGetDeviceInfo**](doc\/ScreenDeviceApi.md#screendevicegetdeviceinfo) | **GET** /api/device/screen/{screenDeviceId} | *ScreenDeviceApi* | [**screenDeviceGetDeviceInfo**](doc\/ScreenDeviceApi.md#screendevicegetdeviceinfo) | **GET** /api/device/screen/{screenDeviceId} | Get screen device info
*ScreenDeviceApi* | [**screenDeviceUpdateDevice**](doc\/ScreenDeviceApi.md#screendeviceupdatedevice) | **PUT** /api/device/screen/{screenDeviceId} | *ScreenDeviceApi* | [**screenDeviceUpdateDevice**](doc\/ScreenDeviceApi.md#screendeviceupdatedevice) | **PUT** /api/device/screen | Update screen device
*TokenApi* | [**tokenConnectUser**](doc\/TokenApi.md#tokenconnectuser) | **POST** /api/token | *TokenApi* | [**tokenConnectUser**](doc\/TokenApi.md#tokenconnectuser) | **POST** /api/token | Connect user
*TokenApi* | [**tokenCreate**](doc\/TokenApi.md#tokencreate) | **POST** /token | *TokenApi* | [**tokenCreate**](doc\/TokenApi.md#tokencreate) | **POST** /token |
*TwitterApi* | [**twitterCreate**](doc\/TwitterApi.md#twittercreate) | **POST** /twitter | *TwitterApi* | [**twitterCreate**](doc\/TwitterApi.md#twittercreate) | **POST** /twitter |
*UserApi* | [**userCreateUser**](doc\/UserApi.md#usercreateuser) | **POST** /api/user | *UserApi* | [**userCreateUser**](doc\/UserApi.md#usercreateuser) | **POST** /api/user | Create an user
*UserApi* | [**userDeleteUser**](doc\/UserApi.md#userdeleteuser) | **DELETE** /api/user/{id} | *UserApi* | [**userDeleteUser**](doc\/UserApi.md#userdeleteuser) | **DELETE** /api/user/{id} | Delete an user
*UserApi* | [**userGet**](doc\/UserApi.md#userget) | **GET** /api/user | Get a list of user *UserApi* | [**userGet**](doc\/UserApi.md#userget) | **GET** /api/user/{id} | Get a specific user
*UserApi* | [**userGet2**](doc\/UserApi.md#userget2) | **GET** /api/user/{id} | Get a specific user *UserApi* | [**userGetAll**](doc\/UserApi.md#usergetall) | **GET** /api/user | Get a list of user
*UserApi* | [**userUpdateUser**](doc\/UserApi.md#userupdateuser) | **PUT** /api/user | *UserApi* | [**userUpdateUser**](doc\/UserApi.md#userupdateuser) | **PUT** /api/user | Update an user
*ValuesApi* | [**valuesDelete**](doc\/ValuesApi.md#valuesdelete) | **DELETE** /api/test/{id} | *ValuesApi* | [**valuesDelete**](doc\/ValuesApi.md#valuesdelete) | **DELETE** /api/test/{id} |
*ValuesApi* | [**valuesGet**](doc\/ValuesApi.md#valuesget) | **GET** /api/test/{id} | *ValuesApi* | [**valuesGet**](doc\/ValuesApi.md#valuesget) | **GET** /api/test/{id} |
*ValuesApi* | [**valuesGetAll**](doc\/ValuesApi.md#valuesgetall) | **GET** /api/test | It's a test ! :) *ValuesApi* | [**valuesGetAll**](doc\/ValuesApi.md#valuesgetall) | **GET** /api/test | It's a test ! :)
@ -150,6 +150,7 @@ Class | Method | HTTP request | Description
- [AutomationDTO](doc\/AutomationDTO.md) - [AutomationDTO](doc\/AutomationDTO.md)
- [AutomationDetailDTO](doc\/AutomationDetailDTO.md) - [AutomationDetailDTO](doc\/AutomationDetailDTO.md)
- [AutomationDetailDTOAllOf](doc\/AutomationDetailDTOAllOf.md) - [AutomationDetailDTOAllOf](doc\/AutomationDetailDTOAllOf.md)
- [AutomationState](doc\/AutomationState.md)
- [AzureADAuthModel](doc\/AzureADAuthModel.md) - [AzureADAuthModel](doc\/AzureADAuthModel.md)
- [Book](doc\/Book.md) - [Book](doc\/Book.md)
- [Condition](doc\/Condition.md) - [Condition](doc\/Condition.md)
@ -174,8 +175,8 @@ Class | Method | HTTP request | Description
- [LoginDTO](doc\/LoginDTO.md) - [LoginDTO](doc\/LoginDTO.md)
- [MeansOfCommunication](doc\/MeansOfCommunication.md) - [MeansOfCommunication](doc\/MeansOfCommunication.md)
- [MqttMessageDTO](doc\/MqttMessageDTO.md) - [MqttMessageDTO](doc\/MqttMessageDTO.md)
- [OddH2H](doc\/OddH2H.md)
- [OddNice](doc\/OddNice.md) - [OddNice](doc\/OddNice.md)
- [OddObject](doc\/OddObject.md)
- [PanelMenuItem](doc\/PanelMenuItem.md) - [PanelMenuItem](doc\/PanelMenuItem.md)
- [PanelSection](doc\/PanelSection.md) - [PanelSection](doc\/PanelSection.md)
- [Provider](doc\/Provider.md) - [Provider](doc\/Provider.md)
@ -185,9 +186,10 @@ Class | Method | HTTP request | Description
- [RoomSummaryDTO](doc\/RoomSummaryDTO.md) - [RoomSummaryDTO](doc\/RoomSummaryDTO.md)
- [ScreenConfiguration](doc\/ScreenConfiguration.md) - [ScreenConfiguration](doc\/ScreenConfiguration.md)
- [ScreenDevice](doc\/ScreenDevice.md) - [ScreenDevice](doc\/ScreenDevice.md)
- [ScreenWidget](doc\/ScreenWidget.md)
- [SmartGardenMessage](doc\/SmartGardenMessage.md) - [SmartGardenMessage](doc\/SmartGardenMessage.md)
- [SmartPrinterMessage](doc\/SmartPrinterMessage.md) - [SmartPrinterMessage](doc\/SmartPrinterMessage.md)
- [State](doc\/State.md) - [TokenDTO](doc\/TokenDTO.md)
- [Trigger](doc\/Trigger.md) - [Trigger](doc\/Trigger.md)
- [TriggerType](doc\/TriggerType.md) - [TriggerType](doc\/TriggerType.md)
- [TwitterAuthModel](doc\/TwitterAuthModel.md) - [TwitterAuthModel](doc\/TwitterAuthModel.md)
@ -195,7 +197,6 @@ Class | Method | HTTP request | Description
- [UserInfo](doc\/UserInfo.md) - [UserInfo](doc\/UserInfo.md)
- [UserInfoDetailDTO](doc\/UserInfoDetailDTO.md) - [UserInfoDetailDTO](doc\/UserInfoDetailDTO.md)
- [ViewBy](doc\/ViewBy.md) - [ViewBy](doc\/ViewBy.md)
- [Widget](doc\/Widget.md)
## Documentation For Authorization ## Documentation For Authorization

View File

@ -10,7 +10,7 @@ Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**groupId** | **String** | | [optional] **groupId** | **String** | | [optional]
**deviceId** | **String** | | [optional] **deviceId** | **String** | | [optional]
**states** | [**List<State>**](State.md) | | [optional] [default to const []] **states** | [**List<AutomationState>**](AutomationState.md) | | [optional] [default to const []]
**rawRequest** | **String** | | [optional] **rawRequest** | **String** | | [optional]
**providerId** | **String** | | [optional] **providerId** | **String** | | [optional]
**type** | [**ActionType**](ActionType.md) | | [optional] **type** | [**ActionType**](ActionType.md) | | [optional]

View File

@ -5,7 +5,7 @@
import 'package:mycoreapi/api.dart'; import 'package:mycoreapi/api.dart';
``` ```
All URIs are relative to *http://192.168.31.140* All URIs are relative to *http://localhost:25049*
Method | HTTP request | Description Method | HTTP request | Description
------------- | ------------- | ------------- ------------- | ------------- | -------------
@ -14,7 +14,7 @@ Method | HTTP request | Description
# **authenticationAuthenticateWithForm** # **authenticationAuthenticateWithForm**
> LoginDTO authenticationAuthenticateWithForm(grantType, username, password, clientId, clientSecret) > TokenDTO authenticationAuthenticateWithForm(grantType, username, password, clientId, clientSecret)
Authenticate with form parameters (used by Swagger test client) Authenticate with form parameters (used by Swagger test client)
@ -51,7 +51,7 @@ Name | Type | Description | Notes
### Return type ### Return type
[**LoginDTO**](LoginDTO.md) [**TokenDTO**](TokenDTO.md)
### Authorization ### Authorization

View File

@ -11,6 +11,7 @@ Name | Type | Description | Notes
**id** | **String** | | [optional] **id** | **String** | | [optional]
**userId** | **String** | | [optional] **userId** | **String** | | [optional]
**name** | **String** | | [optional] **name** | **String** | | [optional]
**active** | **bool** | | [optional]
**createdDate** | [**DateTime**](DateTime.md) | | [optional] **createdDate** | [**DateTime**](DateTime.md) | | [optional]
**updatedDate** | [**DateTime**](DateTime.md) | | [optional] **updatedDate** | [**DateTime**](DateTime.md) | | [optional]
**triggers** | [**List<Trigger>**](Trigger.md) | | [optional] [default to const []] **triggers** | [**List<Trigger>**](Trigger.md) | | [optional] [default to const []]

View File

@ -5,11 +5,11 @@
import 'package:mycoreapi/api.dart'; import 'package:mycoreapi/api.dart';
``` ```
All URIs are relative to *http://192.168.31.140* All URIs are relative to *http://localhost:25049*
Method | HTTP request | Description Method | HTTP request | Description
------------- | ------------- | ------------- ------------- | ------------- | -------------
[**automationCreate**](AutomationApi.md#automationcreate) | **POST** /api/automation | [**automationCreate**](AutomationApi.md#automationcreate) | **POST** /api/automation | Create an automation
[**automationDelete**](AutomationApi.md#automationdelete) | **DELETE** /api/automation/{automationId} | Delete an automation [**automationDelete**](AutomationApi.md#automationdelete) | **DELETE** /api/automation/{automationId} | Delete an automation
[**automationDeleteAllForUser**](AutomationApi.md#automationdeleteallforuser) | **DELETE** /api/automation/user/{userId} | Delete all automation for a specified [**automationDeleteAllForUser**](AutomationApi.md#automationdeleteallforuser) | **DELETE** /api/automation/user/{userId} | Delete all automation for a specified
[**automationGetAll**](AutomationApi.md#automationgetall) | **GET** /api/automation/{userId} | Get all automations for the specified user [**automationGetAll**](AutomationApi.md#automationgetall) | **GET** /api/automation/{userId} | Get all automations for the specified user
@ -20,7 +20,7 @@ Method | HTTP request | Description
# **automationCreate** # **automationCreate**
> AutomationDTO automationCreate(automationCreateOrUpdateDetailDTO) > AutomationDTO automationCreate(automationCreateOrUpdateDetailDTO)
Create an automation
### Example ### Example
```dart ```dart
@ -29,7 +29,7 @@ import 'package:mycoreapi/api.dart';
//defaultApiClient.getAuthentication<OAuth>('bearer').accessToken = 'YOUR_ACCESS_TOKEN'; //defaultApiClient.getAuthentication<OAuth>('bearer').accessToken = 'YOUR_ACCESS_TOKEN';
final api_instance = AutomationApi(); final api_instance = AutomationApi();
final automationCreateOrUpdateDetailDTO = AutomationCreateOrUpdateDetailDTO(); // AutomationCreateOrUpdateDetailDTO | final automationCreateOrUpdateDetailDTO = AutomationCreateOrUpdateDetailDTO(); // AutomationCreateOrUpdateDetailDTO | Automation to create
try { try {
final result = api_instance.automationCreate(automationCreateOrUpdateDetailDTO); final result = api_instance.automationCreate(automationCreateOrUpdateDetailDTO);
@ -43,7 +43,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**automationCreateOrUpdateDetailDTO** | [**AutomationCreateOrUpdateDetailDTO**](AutomationCreateOrUpdateDetailDTO.md)| | **automationCreateOrUpdateDetailDTO** | [**AutomationCreateOrUpdateDetailDTO**](AutomationCreateOrUpdateDetailDTO.md)| Automation to create |
### Return type ### Return type
@ -61,7 +61,7 @@ Name | Type | Description | Notes
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **automationDelete** # **automationDelete**
> MultipartFile automationDelete(automationId) > String automationDelete(automationId)
Delete an automation Delete an automation
@ -90,7 +90,7 @@ Name | Type | Description | Notes
### Return type ### Return type
[**MultipartFile**](MultipartFile.md) **String**
### Authorization ### Authorization
@ -99,12 +99,12 @@ Name | Type | Description | Notes
### HTTP request headers ### HTTP request headers
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: application/octet-stream - **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **automationDeleteAllForUser** # **automationDeleteAllForUser**
> MultipartFile automationDeleteAllForUser(userId) > String automationDeleteAllForUser(userId)
Delete all automation for a specified Delete all automation for a specified
@ -133,7 +133,7 @@ Name | Type | Description | Notes
### Return type ### Return type
[**MultipartFile**](MultipartFile.md) **String**
### Authorization ### Authorization
@ -142,7 +142,7 @@ Name | Type | Description | Notes
### HTTP request headers ### HTTP request headers
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: application/octet-stream - **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

View File

@ -10,6 +10,7 @@ Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**id** | **String** | | [optional] **id** | **String** | | [optional]
**name** | **String** | | [optional] **name** | **String** | | [optional]
**active** | **bool** | | [optional]
**userId** | **String** | | [optional] **userId** | **String** | | [optional]
**createdDate** | [**DateTime**](DateTime.md) | | [optional] **createdDate** | [**DateTime**](DateTime.md) | | [optional]
**updatedDate** | [**DateTime**](DateTime.md) | | [optional] **updatedDate** | [**DateTime**](DateTime.md) | | [optional]

View File

@ -10,6 +10,7 @@ Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**id** | **String** | | [optional] **id** | **String** | | [optional]
**name** | **String** | | [optional] **name** | **String** | | [optional]
**active** | **bool** | | [optional]
**userId** | **String** | | [optional] **userId** | **String** | | [optional]
**createdDate** | [**DateTime**](DateTime.md) | | [optional] **createdDate** | [**DateTime**](DateTime.md) | | [optional]
**updatedDate** | [**DateTime**](DateTime.md) | | [optional] **updatedDate** | [**DateTime**](DateTime.md) | | [optional]

View File

@ -10,6 +10,7 @@ Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**id** | **String** | | [optional] **id** | **String** | | [optional]
**name** | **String** | | [optional] **name** | **String** | | [optional]
**active** | **bool** | | [optional]
**userId** | **String** | | [optional] **userId** | **String** | | [optional]
**createdDate** | [**DateTime**](DateTime.md) | | [optional] **createdDate** | [**DateTime**](DateTime.md) | | [optional]
**updatedDate** | [**DateTime**](DateTime.md) | | [optional] **updatedDate** | [**DateTime**](DateTime.md) | | [optional]

View File

@ -0,0 +1,16 @@
# mycoreapi.model.AutomationState
## Load the model package
```dart
import 'package:mycoreapi/api.dart';
```
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**name** | **String** | | [optional]
**value** | **String** | | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -5,7 +5,7 @@
import 'package:mycoreapi/api.dart'; import 'package:mycoreapi/api.dart';
``` ```
All URIs are relative to *http://192.168.31.140* All URIs are relative to *http://localhost:25049*
Method | HTTP request | Description Method | HTTP request | Description
------------- | ------------- | ------------- ------------- | ------------- | -------------

View File

@ -5,7 +5,7 @@
import 'package:mycoreapi/api.dart'; import 'package:mycoreapi/api.dart';
``` ```
All URIs are relative to *http://192.168.31.140* All URIs are relative to *http://localhost:25049*
Method | HTTP request | Description Method | HTTP request | Description
------------- | ------------- | ------------- ------------- | ------------- | -------------

View File

@ -9,7 +9,7 @@ import 'package:mycoreapi/api.dart';
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**deviceId** | **String** | | [optional] **deviceId** | **String** | | [optional]
**state** | [**OneOfState**](OneOfState.md) | | [optional] **state** | [**OneOfAutomationState**](OneOfAutomationState.md) | | [optional]
**startTime** | **String** | | [optional] **startTime** | **String** | | [optional]
**endTime** | **String** | | [optional] **endTime** | **String** | | [optional]
**type** | [**ConditionType**](ConditionType.md) | | [optional] **type** | [**ConditionType**](ConditionType.md) | | [optional]

View File

@ -5,14 +5,14 @@
import 'package:mycoreapi/api.dart'; import 'package:mycoreapi/api.dart';
``` ```
All URIs are relative to *http://192.168.31.140* All URIs are relative to *http://localhost:25049*
Method | HTTP request | Description Method | HTTP request | Description
------------- | ------------- | ------------- ------------- | ------------- | -------------
[**deviceCreate**](DeviceApi.md#devicecreate) | **POST** /api/device | Create a device [**deviceCreate**](DeviceApi.md#devicecreate) | **POST** /api/device | Create a device
[**deviceCreateDevicesFromProvider**](DeviceApi.md#devicecreatedevicesfromprovider) | **POST** /api/device/{userId}/fromProvider/{providerId} | Create devices from provider [**deviceCreateDevicesFromProvider**](DeviceApi.md#devicecreatedevicesfromprovider) | **POST** /api/device/{userId}/fromProvider/{providerId} | Create devices from provider
[**deviceDelete**](DeviceApi.md#devicedelete) | **DELETE** /api/device/{deviceId} | Delete a device [**deviceDelete**](DeviceApi.md#devicedelete) | **DELETE** /api/device/{deviceId} | Delete a device
[**deviceDeleteAllForUser**](DeviceApi.md#devicedeleteallforuser) | **DELETE** /api/device/user/{userId} | Delete all device for a specified [**deviceDeleteAllForUser**](DeviceApi.md#devicedeleteallforuser) | **DELETE** /api/device/user/{userId} | Delete all device for a specified user
[**deviceDeleteDevicesFromProvider**](DeviceApi.md#devicedeletedevicesfromprovider) | **DELETE** /api/device/{userId}/fromProvider/{providerId} | Delete devices from provider [**deviceDeleteDevicesFromProvider**](DeviceApi.md#devicedeletedevicesfromprovider) | **DELETE** /api/device/{userId}/fromProvider/{providerId} | Delete devices from provider
[**deviceGetAll**](DeviceApi.md#devicegetall) | **GET** /api/device/{userId} | Get all devices summary [**deviceGetAll**](DeviceApi.md#devicegetall) | **GET** /api/device/{userId} | Get all devices summary
[**deviceGetDetail**](DeviceApi.md#devicegetdetail) | **GET** /api/device/detail/{deviceId} | Get a specific device info [**deviceGetDetail**](DeviceApi.md#devicegetdetail) | **GET** /api/device/detail/{deviceId} | Get a specific device info
@ -111,7 +111,7 @@ Name | Type | Description | Notes
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **deviceDelete** # **deviceDelete**
> MultipartFile deviceDelete(deviceId) > String deviceDelete(deviceId)
Delete a device Delete a device
@ -140,7 +140,7 @@ Name | Type | Description | Notes
### Return type ### Return type
[**MultipartFile**](MultipartFile.md) **String**
### Authorization ### Authorization
@ -149,14 +149,14 @@ Name | Type | Description | Notes
### HTTP request headers ### HTTP request headers
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: application/octet-stream - **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **deviceDeleteAllForUser** # **deviceDeleteAllForUser**
> MultipartFile deviceDeleteAllForUser(userId) > String deviceDeleteAllForUser(userId)
Delete all device for a specified Delete all device for a specified user
### Example ### Example
```dart ```dart
@ -183,7 +183,7 @@ Name | Type | Description | Notes
### Return type ### Return type
[**MultipartFile**](MultipartFile.md) **String**
### Authorization ### Authorization
@ -192,12 +192,12 @@ Name | Type | Description | Notes
### HTTP request headers ### HTTP request headers
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: application/octet-stream - **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **deviceDeleteDevicesFromProvider** # **deviceDeleteDevicesFromProvider**
> MultipartFile deviceDeleteDevicesFromProvider(userId, providerId) > String deviceDeleteDevicesFromProvider(userId, providerId)
Delete devices from provider Delete devices from provider
@ -228,7 +228,7 @@ Name | Type | Description | Notes
### Return type ### Return type
[**MultipartFile**](MultipartFile.md) **String**
### Authorization ### Authorization
@ -237,7 +237,7 @@ Name | Type | Description | Notes
### HTTP request headers ### HTTP request headers
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: application/octet-stream - **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

View File

@ -5,7 +5,7 @@
import 'package:mycoreapi/api.dart'; import 'package:mycoreapi/api.dart';
``` ```
All URIs are relative to *http://192.168.31.140* All URIs are relative to *http://localhost:25049*
Method | HTTP request | Description Method | HTTP request | Description
------------- | ------------- | ------------- ------------- | ------------- | -------------

View File

@ -5,7 +5,7 @@
import 'package:mycoreapi/api.dart'; import 'package:mycoreapi/api.dart';
``` ```
All URIs are relative to *http://192.168.31.140* All URIs are relative to *http://localhost:25049*
Method | HTTP request | Description Method | HTTP request | Description
------------- | ------------- | ------------- ------------- | ------------- | -------------

View File

@ -5,7 +5,7 @@
import 'package:mycoreapi/api.dart'; import 'package:mycoreapi/api.dart';
``` ```
All URIs are relative to *http://192.168.31.140* All URIs are relative to *http://localhost:25049*
Method | HTTP request | Description Method | HTTP request | Description
------------- | ------------- | ------------- ------------- | ------------- | -------------

View File

@ -5,7 +5,7 @@
import 'package:mycoreapi/api.dart'; import 'package:mycoreapi/api.dart';
``` ```
All URIs are relative to *http://192.168.31.140* All URIs are relative to *http://localhost:25049*
Method | HTTP request | Description Method | HTTP request | Description
------------- | ------------- | ------------- ------------- | ------------- | -------------
@ -108,7 +108,7 @@ Name | Type | Description | Notes
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **groupDelete** # **groupDelete**
> MultipartFile groupDelete(deviceId, groupId) > String groupDelete(deviceId, groupId)
Delete device from a group Delete device from a group
@ -139,7 +139,7 @@ Name | Type | Description | Notes
### Return type ### Return type
[**MultipartFile**](MultipartFile.md) **String**
### Authorization ### Authorization
@ -148,12 +148,12 @@ Name | Type | Description | Notes
### HTTP request headers ### HTTP request headers
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: application/octet-stream - **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **groupDelete2** # **groupDelete2**
> MultipartFile groupDelete2(groupId) > String groupDelete2(groupId)
Delete a group Delete a group
@ -182,7 +182,7 @@ Name | Type | Description | Notes
### Return type ### Return type
[**MultipartFile**](MultipartFile.md) **String**
### Authorization ### Authorization
@ -191,12 +191,12 @@ Name | Type | Description | Notes
### HTTP request headers ### HTTP request headers
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: application/octet-stream - **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **groupDeleteAllForUser** # **groupDeleteAllForUser**
> MultipartFile groupDeleteAllForUser(userId) > String groupDeleteAllForUser(userId)
Delete all group for a specified Delete all group for a specified
@ -225,7 +225,7 @@ Name | Type | Description | Notes
### Return type ### Return type
[**MultipartFile**](MultipartFile.md) **String**
### Authorization ### Authorization
@ -234,7 +234,7 @@ Name | Type | Description | Notes
### HTTP request headers ### HTTP request headers
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: application/octet-stream - **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
@ -282,7 +282,7 @@ Name | Type | Description | Notes
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **groupGetDetail** # **groupGetDetail**
> GroupDetailDTO groupGetDetail(groupId, userId) > GroupDetailDTO groupGetDetail(groupId)
Get detail info of a specified group Get detail info of a specified group
@ -294,10 +294,9 @@ import 'package:mycoreapi/api.dart';
final api_instance = GroupApi(); final api_instance = GroupApi();
final groupId = groupId_example; // String | groupid final groupId = groupId_example; // String | groupid
final userId = userId_example; // String | user id
try { try {
final result = api_instance.groupGetDetail(groupId, userId); final result = api_instance.groupGetDetail(groupId);
print(result); print(result);
} catch (e) { } catch (e) {
print('Exception when calling GroupApi->groupGetDetail: $e\n'); print('Exception when calling GroupApi->groupGetDetail: $e\n');
@ -309,7 +308,6 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**groupId** | **String**| groupid | **groupId** | **String**| groupid |
**userId** | **String**| user id | [optional]
### Return type ### Return type

View File

@ -5,7 +5,7 @@
import 'package:mycoreapi/api.dart'; import 'package:mycoreapi/api.dart';
``` ```
All URIs are relative to *http://192.168.31.140* All URIs are relative to *http://localhost:25049*
Method | HTTP request | Description Method | HTTP request | Description
------------- | ------------- | ------------- ------------- | ------------- | -------------

View File

@ -5,7 +5,7 @@
import 'package:mycoreapi/api.dart'; import 'package:mycoreapi/api.dart';
``` ```
All URIs are relative to *http://192.168.31.140* All URIs are relative to *http://localhost:25049*
Method | HTTP request | Description Method | HTTP request | Description
------------- | ------------- | ------------- ------------- | ------------- | -------------

View File

@ -5,7 +5,7 @@
import 'package:mycoreapi/api.dart'; import 'package:mycoreapi/api.dart';
``` ```
All URIs are relative to *http://192.168.31.140* All URIs are relative to *http://localhost:25049*
Method | HTTP request | Description Method | HTTP request | Description
------------- | ------------- | ------------- ------------- | ------------- | -------------

View File

@ -5,7 +5,7 @@
import 'package:mycoreapi/api.dart'; import 'package:mycoreapi/api.dart';
``` ```
All URIs are relative to *http://192.168.31.140* All URIs are relative to *http://localhost:25049*
Method | HTTP request | Description Method | HTTP request | Description
------------- | ------------- | ------------- ------------- | ------------- | -------------

View File

@ -11,7 +11,7 @@ Name | Type | Description | Notes
**teams** | **List<String>** | | [optional] [default to const []] **teams** | **List<String>** | | [optional] [default to const []]
**commenceTime** | **int** | | [optional] **commenceTime** | **int** | | [optional]
**homeTeam** | **String** | | [optional] **homeTeam** | **String** | | [optional]
**odds** | [**OneOfOddH2H**](OneOfOddH2H.md) | | [optional] **odds** | [**OneOfOddObject**](OneOfOddObject.md) | | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,17 @@
# mycoreapi.model.OddObject
## Load the model package
```dart
import 'package:mycoreapi/api.dart';
```
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**homeOdd** | **double** | | [optional]
**drawOdd** | **double** | | [optional]
**visitOdd** | **double** | | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -5,7 +5,7 @@
import 'package:mycoreapi/api.dart'; import 'package:mycoreapi/api.dart';
``` ```
All URIs are relative to *http://192.168.31.140* All URIs are relative to *http://localhost:25049*
Method | HTTP request | Description Method | HTTP request | Description
------------- | ------------- | ------------- ------------- | ------------- | -------------
@ -59,7 +59,7 @@ Name | Type | Description | Notes
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **providerDelete** # **providerDelete**
> MultipartFile providerDelete(providerId) > String providerDelete(providerId)
Delete a provider Delete a provider
@ -88,7 +88,7 @@ Name | Type | Description | Notes
### Return type ### Return type
[**MultipartFile**](MultipartFile.md) **String**
### Authorization ### Authorization
@ -97,7 +97,7 @@ Name | Type | Description | Notes
### HTTP request headers ### HTTP request headers
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: application/octet-stream - **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
@ -113,7 +113,7 @@ import 'package:mycoreapi/api.dart';
//defaultApiClient.getAuthentication<OAuth>('bearer').accessToken = 'YOUR_ACCESS_TOKEN'; //defaultApiClient.getAuthentication<OAuth>('bearer').accessToken = 'YOUR_ACCESS_TOKEN';
final api_instance = ProviderApi(); final api_instance = ProviderApi();
final userId = userId_example; // String | final userId = userId_example; // String | Id of user
try { try {
final result = api_instance.providerGetAll(userId); final result = api_instance.providerGetAll(userId);
@ -127,7 +127,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**userId** | **String**| | **userId** | **String**| Id of user |
### Return type ### Return type

View File

@ -5,14 +5,14 @@
import 'package:mycoreapi/api.dart'; import 'package:mycoreapi/api.dart';
``` ```
All URIs are relative to *http://192.168.31.140* All URIs are relative to *http://localhost:25049*
Method | HTTP request | Description Method | HTTP request | Description
------------- | ------------- | ------------- ------------- | ------------- | -------------
[**roomCreate**](RoomApi.md#roomcreate) | **POST** /api/room | Create a room [**roomCreate**](RoomApi.md#roomcreate) | **POST** /api/room | Create a room
[**roomDelete**](RoomApi.md#roomdelete) | **DELETE** /api/room/{roomId}/device/{deviceId} | Delete device from a room [**roomDelete**](RoomApi.md#roomdelete) | **DELETE** /api/room/{roomId}/device/{deviceId} | Delete device from a room
[**roomDelete2**](RoomApi.md#roomdelete2) | **DELETE** /api/room/{roomId} | Delete a room [**roomDelete2**](RoomApi.md#roomdelete2) | **DELETE** /api/room/{roomId} | Delete a room
[**roomDeleteAllForUser**](RoomApi.md#roomdeleteallforuser) | **DELETE** /api/room/user/{userId} | Delete all room for a specified [**roomDeleteAllForUser**](RoomApi.md#roomdeleteallforuser) | **DELETE** /api/room/user/{userId} | Delete all room for a specified user
[**roomGetAll**](RoomApi.md#roomgetall) | **GET** /api/room/{userId} | Get all rooms for the specified user [**roomGetAll**](RoomApi.md#roomgetall) | **GET** /api/room/{userId} | Get all rooms for the specified user
[**roomGetDetail**](RoomApi.md#roomgetdetail) | **GET** /api/room/detail/{roomId} | Get detail info of a specified room [**roomGetDetail**](RoomApi.md#roomgetdetail) | **GET** /api/room/detail/{roomId} | Get detail info of a specified room
[**roomUpdate**](RoomApi.md#roomupdate) | **PUT** /api/room | Update a room [**roomUpdate**](RoomApi.md#roomupdate) | **PUT** /api/room | Update a room
@ -62,7 +62,7 @@ Name | Type | Description | Notes
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **roomDelete** # **roomDelete**
> MultipartFile roomDelete(deviceId, roomId) > String roomDelete(deviceId, roomId)
Delete device from a room Delete device from a room
@ -93,7 +93,7 @@ Name | Type | Description | Notes
### Return type ### Return type
[**MultipartFile**](MultipartFile.md) **String**
### Authorization ### Authorization
@ -102,12 +102,12 @@ Name | Type | Description | Notes
### HTTP request headers ### HTTP request headers
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: application/octet-stream - **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **roomDelete2** # **roomDelete2**
> MultipartFile roomDelete2(roomId) > String roomDelete2(roomId)
Delete a room Delete a room
@ -136,7 +136,7 @@ Name | Type | Description | Notes
### Return type ### Return type
[**MultipartFile**](MultipartFile.md) **String**
### Authorization ### Authorization
@ -145,14 +145,14 @@ Name | Type | Description | Notes
### HTTP request headers ### HTTP request headers
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: application/octet-stream - **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **roomDeleteAllForUser** # **roomDeleteAllForUser**
> MultipartFile roomDeleteAllForUser(userId) > String roomDeleteAllForUser(userId)
Delete all room for a specified Delete all room for a specified user
### Example ### Example
```dart ```dart
@ -179,7 +179,7 @@ Name | Type | Description | Notes
### Return type ### Return type
[**MultipartFile**](MultipartFile.md) **String**
### Authorization ### Authorization
@ -188,7 +188,7 @@ Name | Type | Description | Notes
### HTTP request headers ### HTTP request headers
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: application/octet-stream - **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

View File

@ -11,7 +11,7 @@ Name | Type | Description | Notes
**id** | **String** | | [optional] **id** | **String** | | [optional]
**name** | **String** | | [optional] **name** | **String** | | [optional]
**type** | **String** | | [optional] **type** | **String** | | [optional]
**widgets** | [**List<Widget>**](Widget.md) | | [optional] [default to const []] **widgets** | [**List<ScreenWidget>**](ScreenWidget.md) | | [optional] [default to const []]
**height** | **int** | | [optional] **height** | **int** | | [optional]
**width** | **int** | | [optional] **width** | **int** | | [optional]

View File

@ -5,21 +5,21 @@
import 'package:mycoreapi/api.dart'; import 'package:mycoreapi/api.dart';
``` ```
All URIs are relative to *http://192.168.31.140* All URIs are relative to *http://localhost:25049*
Method | HTTP request | Description Method | HTTP request | Description
------------- | ------------- | ------------- ------------- | ------------- | -------------
[**screenDeviceCreateDevice**](ScreenDeviceApi.md#screendevicecreatedevice) | **POST** /api/device/screen | [**screenDeviceCreateDevice**](ScreenDeviceApi.md#screendevicecreatedevice) | **POST** /api/device/screen | Create screen device
[**screenDeviceDeleteDevice**](ScreenDeviceApi.md#screendevicedeletedevice) | **DELETE** /api/device/screen/{deviceId} | [**screenDeviceDeleteDevice**](ScreenDeviceApi.md#screendevicedeletedevice) | **DELETE** /api/device/screen/{deviceId} | Delete device
[**screenDeviceGetAllScreenDevices**](ScreenDeviceApi.md#screendevicegetallscreendevices) | **GET** /api/device/screen | [**screenDeviceGetAllScreenDevices**](ScreenDeviceApi.md#screendevicegetallscreendevices) | **GET** /api/device/screen | Get all screen devices
[**screenDeviceGetDeviceInfo**](ScreenDeviceApi.md#screendevicegetdeviceinfo) | **GET** /api/device/screen/{screenDeviceId} | [**screenDeviceGetDeviceInfo**](ScreenDeviceApi.md#screendevicegetdeviceinfo) | **GET** /api/device/screen/{screenDeviceId} | Get screen device info
[**screenDeviceUpdateDevice**](ScreenDeviceApi.md#screendeviceupdatedevice) | **PUT** /api/device/screen/{screenDeviceId} | [**screenDeviceUpdateDevice**](ScreenDeviceApi.md#screendeviceupdatedevice) | **PUT** /api/device/screen | Update screen device
# **screenDeviceCreateDevice** # **screenDeviceCreateDevice**
> MultipartFile screenDeviceCreateDevice(screenDevice) > ScreenDevice screenDeviceCreateDevice(screenDevice)
Create screen device
### Example ### Example
```dart ```dart
@ -28,7 +28,7 @@ import 'package:mycoreapi/api.dart';
//defaultApiClient.getAuthentication<OAuth>('bearer').accessToken = 'YOUR_ACCESS_TOKEN'; //defaultApiClient.getAuthentication<OAuth>('bearer').accessToken = 'YOUR_ACCESS_TOKEN';
final api_instance = ScreenDeviceApi(); final api_instance = ScreenDeviceApi();
final screenDevice = ScreenDevice(); // ScreenDevice | final screenDevice = ScreenDevice(); // ScreenDevice | Screen device to create
try { try {
final result = api_instance.screenDeviceCreateDevice(screenDevice); final result = api_instance.screenDeviceCreateDevice(screenDevice);
@ -42,11 +42,11 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**screenDevice** | [**ScreenDevice**](ScreenDevice.md)| | **screenDevice** | [**ScreenDevice**](ScreenDevice.md)| Screen device to create |
### Return type ### Return type
[**MultipartFile**](MultipartFile.md) [**ScreenDevice**](ScreenDevice.md)
### Authorization ### Authorization
@ -55,14 +55,14 @@ Name | Type | Description | Notes
### HTTP request headers ### HTTP request headers
- **Content-Type**: application/json - **Content-Type**: application/json
- **Accept**: application/octet-stream - **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **screenDeviceDeleteDevice** # **screenDeviceDeleteDevice**
> MultipartFile screenDeviceDeleteDevice(deviceId) > String screenDeviceDeleteDevice(deviceId)
Delete device
### Example ### Example
```dart ```dart
@ -71,7 +71,7 @@ import 'package:mycoreapi/api.dart';
//defaultApiClient.getAuthentication<OAuth>('bearer').accessToken = 'YOUR_ACCESS_TOKEN'; //defaultApiClient.getAuthentication<OAuth>('bearer').accessToken = 'YOUR_ACCESS_TOKEN';
final api_instance = ScreenDeviceApi(); final api_instance = ScreenDeviceApi();
final deviceId = deviceId_example; // String | final deviceId = deviceId_example; // String | Screen device id to update
try { try {
final result = api_instance.screenDeviceDeleteDevice(deviceId); final result = api_instance.screenDeviceDeleteDevice(deviceId);
@ -85,11 +85,11 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**deviceId** | **String**| | **deviceId** | **String**| Screen device id to update |
### Return type ### Return type
[**MultipartFile**](MultipartFile.md) **String**
### Authorization ### Authorization
@ -98,14 +98,14 @@ Name | Type | Description | Notes
### HTTP request headers ### HTTP request headers
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: application/octet-stream - **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **screenDeviceGetAllScreenDevices** # **screenDeviceGetAllScreenDevices**
> List<ScreenDevice> screenDeviceGetAllScreenDevices() > List<ScreenDevice> screenDeviceGetAllScreenDevices()
Get all screen devices
### Example ### Example
```dart ```dart
@ -144,7 +144,7 @@ This endpoint does not need any parameter.
# **screenDeviceGetDeviceInfo** # **screenDeviceGetDeviceInfo**
> ScreenDevice screenDeviceGetDeviceInfo(screenDeviceId) > ScreenDevice screenDeviceGetDeviceInfo(screenDeviceId)
Get screen device info
### Example ### Example
```dart ```dart
@ -185,9 +185,9 @@ Name | Type | Description | Notes
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **screenDeviceUpdateDevice** # **screenDeviceUpdateDevice**
> MultipartFile screenDeviceUpdateDevice(screenDeviceId, screenDevice) > ScreenDevice screenDeviceUpdateDevice(screenDevice)
Update screen device
### Example ### Example
```dart ```dart
@ -196,11 +196,10 @@ import 'package:mycoreapi/api.dart';
//defaultApiClient.getAuthentication<OAuth>('bearer').accessToken = 'YOUR_ACCESS_TOKEN'; //defaultApiClient.getAuthentication<OAuth>('bearer').accessToken = 'YOUR_ACCESS_TOKEN';
final api_instance = ScreenDeviceApi(); final api_instance = ScreenDeviceApi();
final screenDeviceId = 56; // int | final screenDevice = ScreenDevice(); // ScreenDevice | Screen device to update
final screenDevice = ScreenDevice(); // ScreenDevice |
try { try {
final result = api_instance.screenDeviceUpdateDevice(screenDeviceId, screenDevice); final result = api_instance.screenDeviceUpdateDevice(screenDevice);
print(result); print(result);
} catch (e) { } catch (e) {
print('Exception when calling ScreenDeviceApi->screenDeviceUpdateDevice: $e\n'); print('Exception when calling ScreenDeviceApi->screenDeviceUpdateDevice: $e\n');
@ -211,12 +210,11 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**screenDeviceId** | **int**| | **screenDevice** | [**ScreenDevice**](ScreenDevice.md)| Screen device to update |
**screenDevice** | [**ScreenDevice**](ScreenDevice.md)| |
### Return type ### Return type
[**MultipartFile**](MultipartFile.md) [**ScreenDevice**](ScreenDevice.md)
### Authorization ### Authorization
@ -225,7 +223,7 @@ Name | Type | Description | Notes
### HTTP request headers ### HTTP request headers
- **Content-Type**: application/json - **Content-Type**: application/json
- **Accept**: application/octet-stream - **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

View File

@ -0,0 +1,27 @@
# mycoreapi.model.ScreenWidget
## Load the model package
```dart
import 'package:mycoreapi/api.dart';
```
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **String** | | [optional]
**name** | **String** | | [optional]
**displayName** | **String** | | [optional]
**type** | **String** | | [optional]
**activated** | **bool** | | [optional]
**form** | **String** | | [optional]
**font** | **String** | | [optional]
**color** | **String** | | [optional]
**size** | **String** | | [optional]
**width** | **int** | | [optional]
**height** | **int** | | [optional]
**positionX** | **int** | | [optional]
**positionY** | **int** | | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -5,18 +5,18 @@
import 'package:mycoreapi/api.dart'; import 'package:mycoreapi/api.dart';
``` ```
All URIs are relative to *http://192.168.31.140* All URIs are relative to *http://localhost:25049*
Method | HTTP request | Description Method | HTTP request | Description
------------- | ------------- | ------------- ------------- | ------------- | -------------
[**tokenConnectUser**](TokenApi.md#tokenconnectuser) | **POST** /api/token | [**tokenConnectUser**](TokenApi.md#tokenconnectuser) | **POST** /api/token | Connect user
[**tokenCreate**](TokenApi.md#tokencreate) | **POST** /token | [**tokenCreate**](TokenApi.md#tokencreate) | **POST** /token |
# **tokenConnectUser** # **tokenConnectUser**
> UserInfo tokenConnectUser(loginDTO) > UserInfo tokenConnectUser(loginDTO)
Connect user
### Example ### Example
```dart ```dart
@ -25,7 +25,7 @@ import 'package:mycoreapi/api.dart';
//defaultApiClient.getAuthentication<OAuth>('bearer').accessToken = 'YOUR_ACCESS_TOKEN'; //defaultApiClient.getAuthentication<OAuth>('bearer').accessToken = 'YOUR_ACCESS_TOKEN';
final api_instance = TokenApi(); final api_instance = TokenApi();
final loginDTO = LoginDTO(); // LoginDTO | final loginDTO = LoginDTO(); // LoginDTO | login info
try { try {
final result = api_instance.tokenConnectUser(loginDTO); final result = api_instance.tokenConnectUser(loginDTO);
@ -39,7 +39,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**loginDTO** | [**LoginDTO**](LoginDTO.md)| | **loginDTO** | [**LoginDTO**](LoginDTO.md)| login info |
### Return type ### Return type

View File

@ -0,0 +1,20 @@
# mycoreapi.model.TokenDTO
## Load the model package
```dart
import 'package:mycoreapi/api.dart';
```
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**accessToken** | **String** | | [optional]
**refreshToken** | **String** | | [optional]
**scope** | **String** | | [optional]
**tokenType** | **String** | | [optional]
**expiresIn** | **int** | | [optional]
**expiration** | [**DateTime**](DateTime.md) | | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -5,7 +5,7 @@
import 'package:mycoreapi/api.dart'; import 'package:mycoreapi/api.dart';
``` ```
All URIs are relative to *http://192.168.31.140* All URIs are relative to *http://localhost:25049*
Method | HTTP request | Description Method | HTTP request | Description
------------- | ------------- | ------------- ------------- | ------------- | -------------

View File

@ -5,21 +5,21 @@
import 'package:mycoreapi/api.dart'; import 'package:mycoreapi/api.dart';
``` ```
All URIs are relative to *http://192.168.31.140* All URIs are relative to *http://localhost:25049*
Method | HTTP request | Description Method | HTTP request | Description
------------- | ------------- | ------------- ------------- | ------------- | -------------
[**userCreateUser**](UserApi.md#usercreateuser) | **POST** /api/user | [**userCreateUser**](UserApi.md#usercreateuser) | **POST** /api/user | Create an user
[**userDeleteUser**](UserApi.md#userdeleteuser) | **DELETE** /api/user/{id} | [**userDeleteUser**](UserApi.md#userdeleteuser) | **DELETE** /api/user/{id} | Delete an user
[**userGet**](UserApi.md#userget) | **GET** /api/user | Get a list of user [**userGet**](UserApi.md#userget) | **GET** /api/user/{id} | Get a specific user
[**userGet2**](UserApi.md#userget2) | **GET** /api/user/{id} | Get a specific user [**userGetAll**](UserApi.md#usergetall) | **GET** /api/user | Get a list of user
[**userUpdateUser**](UserApi.md#userupdateuser) | **PUT** /api/user | [**userUpdateUser**](UserApi.md#userupdateuser) | **PUT** /api/user | Update an user
# **userCreateUser** # **userCreateUser**
> UserInfoDetailDTO userCreateUser(userInfo) > UserInfoDetailDTO userCreateUser(userInfo)
Create an user
### Example ### Example
```dart ```dart
@ -28,7 +28,7 @@ import 'package:mycoreapi/api.dart';
//defaultApiClient.getAuthentication<OAuth>('bearer').accessToken = 'YOUR_ACCESS_TOKEN'; //defaultApiClient.getAuthentication<OAuth>('bearer').accessToken = 'YOUR_ACCESS_TOKEN';
final api_instance = UserApi(); final api_instance = UserApi();
final userInfo = UserInfo(); // UserInfo | final userInfo = UserInfo(); // UserInfo | New user info
try { try {
final result = api_instance.userCreateUser(userInfo); final result = api_instance.userCreateUser(userInfo);
@ -42,7 +42,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**userInfo** | [**UserInfo**](UserInfo.md)| | **userInfo** | [**UserInfo**](UserInfo.md)| New user info |
### Return type ### Return type
@ -60,9 +60,9 @@ Name | Type | Description | Notes
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **userDeleteUser** # **userDeleteUser**
> MultipartFile userDeleteUser(id) > String userDeleteUser(id)
Delete an user
### Example ### Example
```dart ```dart
@ -71,7 +71,7 @@ import 'package:mycoreapi/api.dart';
//defaultApiClient.getAuthentication<OAuth>('bearer').accessToken = 'YOUR_ACCESS_TOKEN'; //defaultApiClient.getAuthentication<OAuth>('bearer').accessToken = 'YOUR_ACCESS_TOKEN';
final api_instance = UserApi(); final api_instance = UserApi();
final id = id_example; // String | final id = id_example; // String | Id of user to delete
try { try {
final result = api_instance.userDeleteUser(id); final result = api_instance.userDeleteUser(id);
@ -85,11 +85,11 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**id** | **String**| | **id** | **String**| Id of user to delete |
### Return type ### Return type
[**MultipartFile**](MultipartFile.md) **String**
### Authorization ### Authorization
@ -98,51 +98,12 @@ Name | Type | Description | Notes
### HTTP request headers ### HTTP request headers
- **Content-Type**: Not defined - **Content-Type**: Not defined
- **Accept**: application/octet-stream - **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **userGet** # **userGet**
> MultipartFile userGet() > UserInfoDetailDTO userGet(id)
Get a list of user
### Example
```dart
import 'package:mycoreapi/api.dart';
// TODO Configure OAuth2 access token for authorization: bearer
//defaultApiClient.getAuthentication<OAuth>('bearer').accessToken = 'YOUR_ACCESS_TOKEN';
final api_instance = UserApi();
try {
final result = api_instance.userGet();
print(result);
} catch (e) {
print('Exception when calling UserApi->userGet: $e\n');
}
```
### Parameters
This endpoint does not need any parameter.
### Return type
[**MultipartFile**](MultipartFile.md)
### Authorization
[bearer](../README.md#bearer)
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/octet-stream
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **userGet2**
> UserInfoDetailDTO userGet2(id)
Get a specific user Get a specific user
@ -156,10 +117,10 @@ final api_instance = UserApi();
final id = id_example; // String | id user final id = id_example; // String | id user
try { try {
final result = api_instance.userGet2(id); final result = api_instance.userGet(id);
print(result); print(result);
} catch (e) { } catch (e) {
print('Exception when calling UserApi->userGet2: $e\n'); print('Exception when calling UserApi->userGet: $e\n');
} }
``` ```
@ -184,10 +145,10 @@ Name | Type | Description | Notes
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **userUpdateUser** # **userGetAll**
> UserInfoDetailDTO userUpdateUser(userInfo) > List<UserInfo> userGetAll()
Get a list of user
### Example ### Example
```dart ```dart
@ -196,7 +157,46 @@ import 'package:mycoreapi/api.dart';
//defaultApiClient.getAuthentication<OAuth>('bearer').accessToken = 'YOUR_ACCESS_TOKEN'; //defaultApiClient.getAuthentication<OAuth>('bearer').accessToken = 'YOUR_ACCESS_TOKEN';
final api_instance = UserApi(); final api_instance = UserApi();
final userInfo = UserInfo(); // UserInfo |
try {
final result = api_instance.userGetAll();
print(result);
} catch (e) {
print('Exception when calling UserApi->userGetAll: $e\n');
}
```
### Parameters
This endpoint does not need any parameter.
### Return type
[**List<UserInfo>**](UserInfo.md)
### Authorization
[bearer](../README.md#bearer)
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **userUpdateUser**
> UserInfoDetailDTO userUpdateUser(userInfo)
Update an user
### Example
```dart
import 'package:mycoreapi/api.dart';
// TODO Configure OAuth2 access token for authorization: bearer
//defaultApiClient.getAuthentication<OAuth>('bearer').accessToken = 'YOUR_ACCESS_TOKEN';
final api_instance = UserApi();
final userInfo = UserInfo(); // UserInfo | User to update
try { try {
final result = api_instance.userUpdateUser(userInfo); final result = api_instance.userUpdateUser(userInfo);
@ -210,7 +210,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**userInfo** | [**UserInfo**](UserInfo.md)| | **userInfo** | [**UserInfo**](UserInfo.md)| User to update |
### Return type ### Return type

View File

@ -5,7 +5,7 @@
import 'package:mycoreapi/api.dart'; import 'package:mycoreapi/api.dart';
``` ```
All URIs are relative to *http://192.168.31.140* All URIs are relative to *http://localhost:25049*
Method | HTTP request | Description Method | HTTP request | Description
------------- | ------------- | ------------- ------------- | ------------- | -------------

View File

@ -56,6 +56,7 @@ part 'model/automation_create_or_update_detail_dto_all_of.dart';
part 'model/automation_dto.dart'; part 'model/automation_dto.dart';
part 'model/automation_detail_dto.dart'; part 'model/automation_detail_dto.dart';
part 'model/automation_detail_dto_all_of.dart'; part 'model/automation_detail_dto_all_of.dart';
part 'model/automation_state.dart';
part 'model/azure_ad_auth_model.dart'; part 'model/azure_ad_auth_model.dart';
part 'model/book.dart'; part 'model/book.dart';
part 'model/condition.dart'; part 'model/condition.dart';
@ -80,8 +81,8 @@ part 'model/location_dto.dart';
part 'model/login_dto.dart'; part 'model/login_dto.dart';
part 'model/means_of_communication.dart'; part 'model/means_of_communication.dart';
part 'model/mqtt_message_dto.dart'; part 'model/mqtt_message_dto.dart';
part 'model/odd_h2_h.dart';
part 'model/odd_nice.dart'; part 'model/odd_nice.dart';
part 'model/odd_object.dart';
part 'model/panel_menu_item.dart'; part 'model/panel_menu_item.dart';
part 'model/panel_section.dart'; part 'model/panel_section.dart';
part 'model/provider.dart'; part 'model/provider.dart';
@ -91,9 +92,10 @@ part 'model/room_detail_dto.dart';
part 'model/room_summary_dto.dart'; part 'model/room_summary_dto.dart';
part 'model/screen_configuration.dart'; part 'model/screen_configuration.dart';
part 'model/screen_device.dart'; part 'model/screen_device.dart';
part 'model/screen_widget.dart';
part 'model/smart_garden_message.dart'; part 'model/smart_garden_message.dart';
part 'model/smart_printer_message.dart'; part 'model/smart_printer_message.dart';
part 'model/state.dart'; part 'model/token_dto.dart';
part 'model/trigger.dart'; part 'model/trigger.dart';
part 'model/trigger_type.dart'; part 'model/trigger_type.dart';
part 'model/twitter_auth_model.dart'; part 'model/twitter_auth_model.dart';
@ -101,7 +103,6 @@ part 'model/user.dart';
part 'model/user_info.dart'; part 'model/user_info.dart';
part 'model/user_info_detail_dto.dart'; part 'model/user_info_detail_dto.dart';
part 'model/view_by.dart'; part 'model/view_by.dart';
part 'model/widget.dart';
const _delimiters = {'csv': ',', 'ssv': ' ', 'tsv': '\t', 'pipes': '|'}; const _delimiters = {'csv': ',', 'ssv': ' ', 'tsv': '\t', 'pipes': '|'};

View File

@ -117,7 +117,7 @@ class AuthenticationApi {
/// * [String] clientId: /// * [String] clientId:
/// ///
/// * [String] clientSecret: /// * [String] clientSecret:
Future<LoginDTO> authenticationAuthenticateWithForm({ String grantType, String username, String password, String clientId, String clientSecret }) async { Future<TokenDTO> authenticationAuthenticateWithForm({ String grantType, String username, String password, String clientId, String clientSecret }) async {
final response = await authenticationAuthenticateWithFormWithHttpInfo( grantType: grantType, username: username, password: password, clientId: clientId, clientSecret: clientSecret ); final response = await authenticationAuthenticateWithFormWithHttpInfo( grantType: grantType, username: username, password: password, clientId: clientId, clientSecret: clientSecret );
if (response.statusCode >= HttpStatus.badRequest) { if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, _decodeBodyBytes(response)); throw ApiException(response.statusCode, _decodeBodyBytes(response));
@ -126,9 +126,9 @@ class AuthenticationApi {
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string. // FormatException when trying to decode an empty string.
if (response.body != null && response.statusCode != HttpStatus.noContent) { if (response.body != null && response.statusCode != HttpStatus.noContent) {
return apiClient.deserialize(_decodeBodyBytes(response), 'LoginDTO') as LoginDTO; return apiClient.deserialize(_decodeBodyBytes(response), 'TokenDTO') as TokenDTO;
} }
return Future<LoginDTO>.value(null); return Future<TokenDTO>.value(null);
} }
/// Authenticate with Json parameters (used by most clients) /// Authenticate with Json parameters (used by most clients)

View File

@ -15,10 +15,14 @@ class AutomationApi {
final ApiClient apiClient; final ApiClient apiClient;
/// Performs an HTTP 'POST /api/automation' operation and returns the [Response]. /// Create an automation
///
/// Note: This method returns the HTTP [Response].
///
/// Parameters: /// Parameters:
/// ///
/// * [AutomationCreateOrUpdateDetailDTO] automationCreateOrUpdateDetailDTO (required): /// * [AutomationCreateOrUpdateDetailDTO] automationCreateOrUpdateDetailDTO (required):
/// Automation to create
Future<Response> automationCreateWithHttpInfo(AutomationCreateOrUpdateDetailDTO automationCreateOrUpdateDetailDTO) async { Future<Response> automationCreateWithHttpInfo(AutomationCreateOrUpdateDetailDTO automationCreateOrUpdateDetailDTO) async {
// Verify required params are set. // Verify required params are set.
if (automationCreateOrUpdateDetailDTO == null) { if (automationCreateOrUpdateDetailDTO == null) {
@ -61,9 +65,12 @@ class AutomationApi {
); );
} }
/// Create an automation
///
/// Parameters: /// Parameters:
/// ///
/// * [AutomationCreateOrUpdateDetailDTO] automationCreateOrUpdateDetailDTO (required): /// * [AutomationCreateOrUpdateDetailDTO] automationCreateOrUpdateDetailDTO (required):
/// Automation to create
Future<AutomationDTO> automationCreate(AutomationCreateOrUpdateDetailDTO automationCreateOrUpdateDetailDTO) async { Future<AutomationDTO> automationCreate(AutomationCreateOrUpdateDetailDTO automationCreateOrUpdateDetailDTO) async {
final response = await automationCreateWithHttpInfo(automationCreateOrUpdateDetailDTO); final response = await automationCreateWithHttpInfo(automationCreateOrUpdateDetailDTO);
if (response.statusCode >= HttpStatus.badRequest) { if (response.statusCode >= HttpStatus.badRequest) {
@ -135,7 +142,7 @@ class AutomationApi {
/// ///
/// * [String] automationId (required): /// * [String] automationId (required):
/// Id of automation to delete /// Id of automation to delete
Future<MultipartFile> automationDelete(String automationId) async { Future<String> automationDelete(String automationId) async {
final response = await automationDeleteWithHttpInfo(automationId); final response = await automationDeleteWithHttpInfo(automationId);
if (response.statusCode >= HttpStatus.badRequest) { if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, _decodeBodyBytes(response)); throw ApiException(response.statusCode, _decodeBodyBytes(response));
@ -144,9 +151,9 @@ class AutomationApi {
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string. // FormatException when trying to decode an empty string.
if (response.body != null && response.statusCode != HttpStatus.noContent) { if (response.body != null && response.statusCode != HttpStatus.noContent) {
return apiClient.deserialize(_decodeBodyBytes(response), 'MultipartFile') as MultipartFile; return apiClient.deserialize(_decodeBodyBytes(response), 'String') as String;
} }
return Future<MultipartFile>.value(null); return Future<String>.value(null);
} }
/// Delete all automation for a specified /// Delete all automation for a specified
@ -206,7 +213,7 @@ class AutomationApi {
/// ///
/// * [String] userId (required): /// * [String] userId (required):
/// Id of user /// Id of user
Future<MultipartFile> automationDeleteAllForUser(String userId) async { Future<String> automationDeleteAllForUser(String userId) async {
final response = await automationDeleteAllForUserWithHttpInfo(userId); final response = await automationDeleteAllForUserWithHttpInfo(userId);
if (response.statusCode >= HttpStatus.badRequest) { if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, _decodeBodyBytes(response)); throw ApiException(response.statusCode, _decodeBodyBytes(response));
@ -215,9 +222,9 @@ class AutomationApi {
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string. // FormatException when trying to decode an empty string.
if (response.body != null && response.statusCode != HttpStatus.noContent) { if (response.body != null && response.statusCode != HttpStatus.noContent) {
return apiClient.deserialize(_decodeBodyBytes(response), 'MultipartFile') as MultipartFile; return apiClient.deserialize(_decodeBodyBytes(response), 'String') as String;
} }
return Future<MultipartFile>.value(null); return Future<String>.value(null);
} }
/// Get all automations for the specified user /// Get all automations for the specified user

View File

@ -225,7 +225,7 @@ class DeviceApi {
/// ///
/// * [String] deviceId (required): /// * [String] deviceId (required):
/// Id of device to delete /// Id of device to delete
Future<MultipartFile> deviceDelete(String deviceId) async { Future<String> deviceDelete(String deviceId) async {
final response = await deviceDeleteWithHttpInfo(deviceId); final response = await deviceDeleteWithHttpInfo(deviceId);
if (response.statusCode >= HttpStatus.badRequest) { if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, _decodeBodyBytes(response)); throw ApiException(response.statusCode, _decodeBodyBytes(response));
@ -234,12 +234,12 @@ class DeviceApi {
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string. // FormatException when trying to decode an empty string.
if (response.body != null && response.statusCode != HttpStatus.noContent) { if (response.body != null && response.statusCode != HttpStatus.noContent) {
return apiClient.deserialize(_decodeBodyBytes(response), 'MultipartFile') as MultipartFile; return apiClient.deserialize(_decodeBodyBytes(response), 'String') as String;
} }
return Future<MultipartFile>.value(null); return Future<String>.value(null);
} }
/// Delete all device for a specified /// Delete all device for a specified user
/// ///
/// Note: This method returns the HTTP [Response]. /// Note: This method returns the HTTP [Response].
/// ///
@ -290,13 +290,13 @@ class DeviceApi {
); );
} }
/// Delete all device for a specified /// Delete all device for a specified user
/// ///
/// Parameters: /// Parameters:
/// ///
/// * [String] userId (required): /// * [String] userId (required):
/// Id of user /// Id of user
Future<MultipartFile> deviceDeleteAllForUser(String userId) async { Future<String> deviceDeleteAllForUser(String userId) async {
final response = await deviceDeleteAllForUserWithHttpInfo(userId); final response = await deviceDeleteAllForUserWithHttpInfo(userId);
if (response.statusCode >= HttpStatus.badRequest) { if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, _decodeBodyBytes(response)); throw ApiException(response.statusCode, _decodeBodyBytes(response));
@ -305,9 +305,9 @@ class DeviceApi {
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string. // FormatException when trying to decode an empty string.
if (response.body != null && response.statusCode != HttpStatus.noContent) { if (response.body != null && response.statusCode != HttpStatus.noContent) {
return apiClient.deserialize(_decodeBodyBytes(response), 'MultipartFile') as MultipartFile; return apiClient.deserialize(_decodeBodyBytes(response), 'String') as String;
} }
return Future<MultipartFile>.value(null); return Future<String>.value(null);
} }
/// Delete devices from provider /// Delete devices from provider
@ -377,7 +377,7 @@ class DeviceApi {
/// ///
/// * [String] providerId (required): /// * [String] providerId (required):
/// Id of Provider /// Id of Provider
Future<MultipartFile> deviceDeleteDevicesFromProvider(String userId, String providerId) async { Future<String> deviceDeleteDevicesFromProvider(String userId, String providerId) async {
final response = await deviceDeleteDevicesFromProviderWithHttpInfo(userId, providerId); final response = await deviceDeleteDevicesFromProviderWithHttpInfo(userId, providerId);
if (response.statusCode >= HttpStatus.badRequest) { if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, _decodeBodyBytes(response)); throw ApiException(response.statusCode, _decodeBodyBytes(response));
@ -386,9 +386,9 @@ class DeviceApi {
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string. // FormatException when trying to decode an empty string.
if (response.body != null && response.statusCode != HttpStatus.noContent) { if (response.body != null && response.statusCode != HttpStatus.noContent) {
return apiClient.deserialize(_decodeBodyBytes(response), 'MultipartFile') as MultipartFile; return apiClient.deserialize(_decodeBodyBytes(response), 'String') as String;
} }
return Future<MultipartFile>.value(null); return Future<String>.value(null);
} }
/// Get all devices summary /// Get all devices summary

View File

@ -225,7 +225,7 @@ class GroupApi {
/// ///
/// * [String] groupId (required): /// * [String] groupId (required):
/// Id of group /// Id of group
Future<MultipartFile> groupDelete(String deviceId, String groupId) async { Future<String> groupDelete(String deviceId, String groupId) async {
final response = await groupDeleteWithHttpInfo(deviceId, groupId); final response = await groupDeleteWithHttpInfo(deviceId, groupId);
if (response.statusCode >= HttpStatus.badRequest) { if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, _decodeBodyBytes(response)); throw ApiException(response.statusCode, _decodeBodyBytes(response));
@ -234,9 +234,9 @@ class GroupApi {
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string. // FormatException when trying to decode an empty string.
if (response.body != null && response.statusCode != HttpStatus.noContent) { if (response.body != null && response.statusCode != HttpStatus.noContent) {
return apiClient.deserialize(_decodeBodyBytes(response), 'MultipartFile') as MultipartFile; return apiClient.deserialize(_decodeBodyBytes(response), 'String') as String;
} }
return Future<MultipartFile>.value(null); return Future<String>.value(null);
} }
/// Delete a group /// Delete a group
@ -296,7 +296,7 @@ class GroupApi {
/// ///
/// * [String] groupId (required): /// * [String] groupId (required):
/// Id of group /// Id of group
Future<MultipartFile> groupDelete2(String groupId) async { Future<String> groupDelete2(String groupId) async {
final response = await groupDelete2WithHttpInfo(groupId); final response = await groupDelete2WithHttpInfo(groupId);
if (response.statusCode >= HttpStatus.badRequest) { if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, _decodeBodyBytes(response)); throw ApiException(response.statusCode, _decodeBodyBytes(response));
@ -305,9 +305,9 @@ class GroupApi {
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string. // FormatException when trying to decode an empty string.
if (response.body != null && response.statusCode != HttpStatus.noContent) { if (response.body != null && response.statusCode != HttpStatus.noContent) {
return apiClient.deserialize(_decodeBodyBytes(response), 'MultipartFile') as MultipartFile; return apiClient.deserialize(_decodeBodyBytes(response), 'String') as String;
} }
return Future<MultipartFile>.value(null); return Future<String>.value(null);
} }
/// Delete all group for a specified /// Delete all group for a specified
@ -367,7 +367,7 @@ class GroupApi {
/// ///
/// * [String] userId (required): /// * [String] userId (required):
/// Id of user /// Id of user
Future<MultipartFile> groupDeleteAllForUser(String userId) async { Future<String> groupDeleteAllForUser(String userId) async {
final response = await groupDeleteAllForUserWithHttpInfo(userId); final response = await groupDeleteAllForUserWithHttpInfo(userId);
if (response.statusCode >= HttpStatus.badRequest) { if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, _decodeBodyBytes(response)); throw ApiException(response.statusCode, _decodeBodyBytes(response));
@ -376,9 +376,9 @@ class GroupApi {
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string. // FormatException when trying to decode an empty string.
if (response.body != null && response.statusCode != HttpStatus.noContent) { if (response.body != null && response.statusCode != HttpStatus.noContent) {
return apiClient.deserialize(_decodeBodyBytes(response), 'MultipartFile') as MultipartFile; return apiClient.deserialize(_decodeBodyBytes(response), 'String') as String;
} }
return Future<MultipartFile>.value(null); return Future<String>.value(null);
} }
/// Get all groups for the specified user /// Get all groups for the specified user
@ -462,10 +462,7 @@ class GroupApi {
/// ///
/// * [String] groupId (required): /// * [String] groupId (required):
/// groupid /// groupid
/// Future<Response> groupGetDetailWithHttpInfo(String groupId) async {
/// * [String] userId:
/// user id
Future<Response> groupGetDetailWithHttpInfo(String groupId, { String userId }) async {
// Verify required params are set. // Verify required params are set.
if (groupId == null) { if (groupId == null) {
throw ApiException(HttpStatus.badRequest, 'Missing required param: groupId'); throw ApiException(HttpStatus.badRequest, 'Missing required param: groupId');
@ -480,10 +477,6 @@ class GroupApi {
final headerParams = <String, String>{}; final headerParams = <String, String>{};
final formParams = <String, String>{}; final formParams = <String, String>{};
if (userId != null) {
queryParams.addAll(_convertParametersForCollectionFormat('', 'userId', userId));
}
final contentTypes = <String>[]; final contentTypes = <String>[];
final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null;
final authNames = <String>['bearer']; final authNames = <String>['bearer'];
@ -518,11 +511,8 @@ class GroupApi {
/// ///
/// * [String] groupId (required): /// * [String] groupId (required):
/// groupid /// groupid
/// Future<GroupDetailDTO> groupGetDetail(String groupId) async {
/// * [String] userId: final response = await groupGetDetailWithHttpInfo(groupId);
/// user id
Future<GroupDetailDTO> groupGetDetail(String groupId, { String userId }) async {
final response = await groupGetDetailWithHttpInfo(groupId, userId: userId );
if (response.statusCode >= HttpStatus.badRequest) { if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, _decodeBodyBytes(response)); throw ApiException(response.statusCode, _decodeBodyBytes(response));
} }

View File

@ -142,7 +142,7 @@ class ProviderApi {
/// ///
/// * [String] providerId (required): /// * [String] providerId (required):
/// Id of provider to delete /// Id of provider to delete
Future<MultipartFile> providerDelete(String providerId) async { Future<String> providerDelete(String providerId) async {
final response = await providerDeleteWithHttpInfo(providerId); final response = await providerDeleteWithHttpInfo(providerId);
if (response.statusCode >= HttpStatus.badRequest) { if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, _decodeBodyBytes(response)); throw ApiException(response.statusCode, _decodeBodyBytes(response));
@ -151,9 +151,9 @@ class ProviderApi {
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string. // FormatException when trying to decode an empty string.
if (response.body != null && response.statusCode != HttpStatus.noContent) { if (response.body != null && response.statusCode != HttpStatus.noContent) {
return apiClient.deserialize(_decodeBodyBytes(response), 'MultipartFile') as MultipartFile; return apiClient.deserialize(_decodeBodyBytes(response), 'String') as String;
} }
return Future<MultipartFile>.value(null); return Future<String>.value(null);
} }
/// Get all user providers /// Get all user providers
@ -163,6 +163,7 @@ class ProviderApi {
/// Parameters: /// Parameters:
/// ///
/// * [String] userId (required): /// * [String] userId (required):
/// Id of user
Future<Response> providerGetAllWithHttpInfo(String userId) async { Future<Response> providerGetAllWithHttpInfo(String userId) async {
// Verify required params are set. // Verify required params are set.
if (userId == null) { if (userId == null) {
@ -211,6 +212,7 @@ class ProviderApi {
/// Parameters: /// Parameters:
/// ///
/// * [String] userId (required): /// * [String] userId (required):
/// Id of user
Future<List<ProviderDTO>> providerGetAll(String userId) async { Future<List<ProviderDTO>> providerGetAll(String userId) async {
final response = await providerGetAllWithHttpInfo(userId); final response = await providerGetAllWithHttpInfo(userId);
if (response.statusCode >= HttpStatus.badRequest) { if (response.statusCode >= HttpStatus.badRequest) {

View File

@ -152,7 +152,7 @@ class RoomApi {
/// ///
/// * [String] roomId (required): /// * [String] roomId (required):
/// Id of room /// Id of room
Future<MultipartFile> roomDelete(String deviceId, String roomId) async { Future<String> roomDelete(String deviceId, String roomId) async {
final response = await roomDeleteWithHttpInfo(deviceId, roomId); final response = await roomDeleteWithHttpInfo(deviceId, roomId);
if (response.statusCode >= HttpStatus.badRequest) { if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, _decodeBodyBytes(response)); throw ApiException(response.statusCode, _decodeBodyBytes(response));
@ -161,9 +161,9 @@ class RoomApi {
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string. // FormatException when trying to decode an empty string.
if (response.body != null && response.statusCode != HttpStatus.noContent) { if (response.body != null && response.statusCode != HttpStatus.noContent) {
return apiClient.deserialize(_decodeBodyBytes(response), 'MultipartFile') as MultipartFile; return apiClient.deserialize(_decodeBodyBytes(response), 'String') as String;
} }
return Future<MultipartFile>.value(null); return Future<String>.value(null);
} }
/// Delete a room /// Delete a room
@ -223,7 +223,7 @@ class RoomApi {
/// ///
/// * [String] roomId (required): /// * [String] roomId (required):
/// Id of room /// Id of room
Future<MultipartFile> roomDelete2(String roomId) async { Future<String> roomDelete2(String roomId) async {
final response = await roomDelete2WithHttpInfo(roomId); final response = await roomDelete2WithHttpInfo(roomId);
if (response.statusCode >= HttpStatus.badRequest) { if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, _decodeBodyBytes(response)); throw ApiException(response.statusCode, _decodeBodyBytes(response));
@ -232,12 +232,12 @@ class RoomApi {
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string. // FormatException when trying to decode an empty string.
if (response.body != null && response.statusCode != HttpStatus.noContent) { if (response.body != null && response.statusCode != HttpStatus.noContent) {
return apiClient.deserialize(_decodeBodyBytes(response), 'MultipartFile') as MultipartFile; return apiClient.deserialize(_decodeBodyBytes(response), 'String') as String;
} }
return Future<MultipartFile>.value(null); return Future<String>.value(null);
} }
/// Delete all room for a specified /// Delete all room for a specified user
/// ///
/// Note: This method returns the HTTP [Response]. /// Note: This method returns the HTTP [Response].
/// ///
@ -288,13 +288,13 @@ class RoomApi {
); );
} }
/// Delete all room for a specified /// Delete all room for a specified user
/// ///
/// Parameters: /// Parameters:
/// ///
/// * [String] userId (required): /// * [String] userId (required):
/// Id of user /// Id of user
Future<MultipartFile> roomDeleteAllForUser(String userId) async { Future<String> roomDeleteAllForUser(String userId) async {
final response = await roomDeleteAllForUserWithHttpInfo(userId); final response = await roomDeleteAllForUserWithHttpInfo(userId);
if (response.statusCode >= HttpStatus.badRequest) { if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, _decodeBodyBytes(response)); throw ApiException(response.statusCode, _decodeBodyBytes(response));
@ -303,9 +303,9 @@ class RoomApi {
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string. // FormatException when trying to decode an empty string.
if (response.body != null && response.statusCode != HttpStatus.noContent) { if (response.body != null && response.statusCode != HttpStatus.noContent) {
return apiClient.deserialize(_decodeBodyBytes(response), 'MultipartFile') as MultipartFile; return apiClient.deserialize(_decodeBodyBytes(response), 'String') as String;
} }
return Future<MultipartFile>.value(null); return Future<String>.value(null);
} }
/// Get all rooms for the specified user /// Get all rooms for the specified user

View File

@ -15,10 +15,14 @@ class ScreenDeviceApi {
final ApiClient apiClient; final ApiClient apiClient;
/// Performs an HTTP 'POST /api/device/screen' operation and returns the [Response]. /// Create screen device
///
/// Note: This method returns the HTTP [Response].
///
/// Parameters: /// Parameters:
/// ///
/// * [ScreenDevice] screenDevice (required): /// * [ScreenDevice] screenDevice (required):
/// Screen device to create
Future<Response> screenDeviceCreateDeviceWithHttpInfo(ScreenDevice screenDevice) async { Future<Response> screenDeviceCreateDeviceWithHttpInfo(ScreenDevice screenDevice) async {
// Verify required params are set. // Verify required params are set.
if (screenDevice == null) { if (screenDevice == null) {
@ -61,10 +65,13 @@ class ScreenDeviceApi {
); );
} }
/// Create screen device
///
/// Parameters: /// Parameters:
/// ///
/// * [ScreenDevice] screenDevice (required): /// * [ScreenDevice] screenDevice (required):
Future<MultipartFile> screenDeviceCreateDevice(ScreenDevice screenDevice) async { /// Screen device to create
Future<ScreenDevice> screenDeviceCreateDevice(ScreenDevice screenDevice) async {
final response = await screenDeviceCreateDeviceWithHttpInfo(screenDevice); final response = await screenDeviceCreateDeviceWithHttpInfo(screenDevice);
if (response.statusCode >= HttpStatus.badRequest) { if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, _decodeBodyBytes(response)); throw ApiException(response.statusCode, _decodeBodyBytes(response));
@ -73,15 +80,19 @@ class ScreenDeviceApi {
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string. // FormatException when trying to decode an empty string.
if (response.body != null && response.statusCode != HttpStatus.noContent) { if (response.body != null && response.statusCode != HttpStatus.noContent) {
return apiClient.deserialize(_decodeBodyBytes(response), 'MultipartFile') as MultipartFile; return apiClient.deserialize(_decodeBodyBytes(response), 'ScreenDevice') as ScreenDevice;
} }
return Future<MultipartFile>.value(null); return Future<ScreenDevice>.value(null);
} }
/// Performs an HTTP 'DELETE /api/device/screen/{deviceId}' operation and returns the [Response]. /// Delete device
///
/// Note: This method returns the HTTP [Response].
///
/// Parameters: /// Parameters:
/// ///
/// * [String] deviceId (required): /// * [String] deviceId (required):
/// Screen device id to update
Future<Response> screenDeviceDeleteDeviceWithHttpInfo(String deviceId) async { Future<Response> screenDeviceDeleteDeviceWithHttpInfo(String deviceId) async {
// Verify required params are set. // Verify required params are set.
if (deviceId == null) { if (deviceId == null) {
@ -125,10 +136,13 @@ class ScreenDeviceApi {
); );
} }
/// Delete device
///
/// Parameters: /// Parameters:
/// ///
/// * [String] deviceId (required): /// * [String] deviceId (required):
Future<MultipartFile> screenDeviceDeleteDevice(String deviceId) async { /// Screen device id to update
Future<String> screenDeviceDeleteDevice(String deviceId) async {
final response = await screenDeviceDeleteDeviceWithHttpInfo(deviceId); final response = await screenDeviceDeleteDeviceWithHttpInfo(deviceId);
if (response.statusCode >= HttpStatus.badRequest) { if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, _decodeBodyBytes(response)); throw ApiException(response.statusCode, _decodeBodyBytes(response));
@ -137,12 +151,14 @@ class ScreenDeviceApi {
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string. // FormatException when trying to decode an empty string.
if (response.body != null && response.statusCode != HttpStatus.noContent) { if (response.body != null && response.statusCode != HttpStatus.noContent) {
return apiClient.deserialize(_decodeBodyBytes(response), 'MultipartFile') as MultipartFile; return apiClient.deserialize(_decodeBodyBytes(response), 'String') as String;
} }
return Future<MultipartFile>.value(null); return Future<String>.value(null);
} }
/// Performs an HTTP 'GET /api/device/screen' operation and returns the [Response]. /// Get all screen devices
///
/// Note: This method returns the HTTP [Response].
Future<Response> screenDeviceGetAllScreenDevicesWithHttpInfo() async { Future<Response> screenDeviceGetAllScreenDevicesWithHttpInfo() async {
final path = r'/api/device/screen'; final path = r'/api/device/screen';
@ -180,6 +196,7 @@ class ScreenDeviceApi {
); );
} }
/// Get all screen devices
Future<List<ScreenDevice>> screenDeviceGetAllScreenDevices() async { Future<List<ScreenDevice>> screenDeviceGetAllScreenDevices() async {
final response = await screenDeviceGetAllScreenDevicesWithHttpInfo(); final response = await screenDeviceGetAllScreenDevicesWithHttpInfo();
if (response.statusCode >= HttpStatus.badRequest) { if (response.statusCode >= HttpStatus.badRequest) {
@ -196,7 +213,10 @@ class ScreenDeviceApi {
return Future<List<ScreenDevice>>.value(null); return Future<List<ScreenDevice>>.value(null);
} }
/// Performs an HTTP 'GET /api/device/screen/{screenDeviceId}' operation and returns the [Response]. /// Get screen device info
///
/// Note: This method returns the HTTP [Response].
///
/// Parameters: /// Parameters:
/// ///
/// * [String] screenDeviceId (required): /// * [String] screenDeviceId (required):
@ -244,6 +264,8 @@ class ScreenDeviceApi {
); );
} }
/// Get screen device info
///
/// Parameters: /// Parameters:
/// ///
/// * [String] screenDeviceId (required): /// * [String] screenDeviceId (required):
@ -262,23 +284,21 @@ class ScreenDeviceApi {
return Future<ScreenDevice>.value(null); return Future<ScreenDevice>.value(null);
} }
/// Performs an HTTP 'PUT /api/device/screen/{screenDeviceId}' operation and returns the [Response]. /// Update screen device
///
/// Note: This method returns the HTTP [Response].
///
/// Parameters: /// Parameters:
/// ///
/// * [int] screenDeviceId (required):
///
/// * [ScreenDevice] screenDevice (required): /// * [ScreenDevice] screenDevice (required):
Future<Response> screenDeviceUpdateDeviceWithHttpInfo(int screenDeviceId, ScreenDevice screenDevice) async { /// Screen device to update
Future<Response> screenDeviceUpdateDeviceWithHttpInfo(ScreenDevice screenDevice) async {
// Verify required params are set. // Verify required params are set.
if (screenDeviceId == null) {
throw ApiException(HttpStatus.badRequest, 'Missing required param: screenDeviceId');
}
if (screenDevice == null) { if (screenDevice == null) {
throw ApiException(HttpStatus.badRequest, 'Missing required param: screenDevice'); throw ApiException(HttpStatus.badRequest, 'Missing required param: screenDevice');
} }
final path = r'/api/device/screen/{screenDeviceId}' final path = r'/api/device/screen';
.replaceAll('{' + 'screenDeviceId' + '}', screenDeviceId.toString());
Object postBody = screenDevice; Object postBody = screenDevice;
@ -314,13 +334,14 @@ class ScreenDeviceApi {
); );
} }
/// Update screen device
///
/// Parameters: /// Parameters:
/// ///
/// * [int] screenDeviceId (required):
///
/// * [ScreenDevice] screenDevice (required): /// * [ScreenDevice] screenDevice (required):
Future<MultipartFile> screenDeviceUpdateDevice(int screenDeviceId, ScreenDevice screenDevice) async { /// Screen device to update
final response = await screenDeviceUpdateDeviceWithHttpInfo(screenDeviceId, screenDevice); Future<ScreenDevice> screenDeviceUpdateDevice(ScreenDevice screenDevice) async {
final response = await screenDeviceUpdateDeviceWithHttpInfo(screenDevice);
if (response.statusCode >= HttpStatus.badRequest) { if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, _decodeBodyBytes(response)); throw ApiException(response.statusCode, _decodeBodyBytes(response));
} }
@ -328,8 +349,8 @@ class ScreenDeviceApi {
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string. // FormatException when trying to decode an empty string.
if (response.body != null && response.statusCode != HttpStatus.noContent) { if (response.body != null && response.statusCode != HttpStatus.noContent) {
return apiClient.deserialize(_decodeBodyBytes(response), 'MultipartFile') as MultipartFile; return apiClient.deserialize(_decodeBodyBytes(response), 'ScreenDevice') as ScreenDevice;
} }
return Future<MultipartFile>.value(null); return Future<ScreenDevice>.value(null);
} }
} }

View File

@ -15,10 +15,14 @@ class TokenApi {
final ApiClient apiClient; final ApiClient apiClient;
/// Performs an HTTP 'POST /api/token' operation and returns the [Response]. /// Connect user
///
/// Note: This method returns the HTTP [Response].
///
/// Parameters: /// Parameters:
/// ///
/// * [LoginDTO] loginDTO (required): /// * [LoginDTO] loginDTO (required):
/// login info
Future<Response> tokenConnectUserWithHttpInfo(LoginDTO loginDTO) async { Future<Response> tokenConnectUserWithHttpInfo(LoginDTO loginDTO) async {
// Verify required params are set. // Verify required params are set.
if (loginDTO == null) { if (loginDTO == null) {
@ -61,9 +65,12 @@ class TokenApi {
); );
} }
/// Connect user
///
/// Parameters: /// Parameters:
/// ///
/// * [LoginDTO] loginDTO (required): /// * [LoginDTO] loginDTO (required):
/// login info
Future<UserInfo> tokenConnectUser(LoginDTO loginDTO) async { Future<UserInfo> tokenConnectUser(LoginDTO loginDTO) async {
final response = await tokenConnectUserWithHttpInfo(loginDTO); final response = await tokenConnectUserWithHttpInfo(loginDTO);
if (response.statusCode >= HttpStatus.badRequest) { if (response.statusCode >= HttpStatus.badRequest) {

View File

@ -15,10 +15,14 @@ class UserApi {
final ApiClient apiClient; final ApiClient apiClient;
/// Performs an HTTP 'POST /api/user' operation and returns the [Response]. /// Create an user
///
/// Note: This method returns the HTTP [Response].
///
/// Parameters: /// Parameters:
/// ///
/// * [UserInfo] userInfo (required): /// * [UserInfo] userInfo (required):
/// New user info
Future<Response> userCreateUserWithHttpInfo(UserInfo userInfo) async { Future<Response> userCreateUserWithHttpInfo(UserInfo userInfo) async {
// Verify required params are set. // Verify required params are set.
if (userInfo == null) { if (userInfo == null) {
@ -61,9 +65,12 @@ class UserApi {
); );
} }
/// Create an user
///
/// Parameters: /// Parameters:
/// ///
/// * [UserInfo] userInfo (required): /// * [UserInfo] userInfo (required):
/// New user info
Future<UserInfoDetailDTO> userCreateUser(UserInfo userInfo) async { Future<UserInfoDetailDTO> userCreateUser(UserInfo userInfo) async {
final response = await userCreateUserWithHttpInfo(userInfo); final response = await userCreateUserWithHttpInfo(userInfo);
if (response.statusCode >= HttpStatus.badRequest) { if (response.statusCode >= HttpStatus.badRequest) {
@ -78,10 +85,14 @@ class UserApi {
return Future<UserInfoDetailDTO>.value(null); return Future<UserInfoDetailDTO>.value(null);
} }
/// Performs an HTTP 'DELETE /api/user/{id}' operation and returns the [Response]. /// Delete an user
///
/// Note: This method returns the HTTP [Response].
///
/// Parameters: /// Parameters:
/// ///
/// * [String] id (required): /// * [String] id (required):
/// Id of user to delete
Future<Response> userDeleteUserWithHttpInfo(String id) async { Future<Response> userDeleteUserWithHttpInfo(String id) async {
// Verify required params are set. // Verify required params are set.
if (id == null) { if (id == null) {
@ -125,10 +136,13 @@ class UserApi {
); );
} }
/// Delete an user
///
/// Parameters: /// Parameters:
/// ///
/// * [String] id (required): /// * [String] id (required):
Future<MultipartFile> userDeleteUser(String id) async { /// Id of user to delete
Future<String> userDeleteUser(String id) async {
final response = await userDeleteUserWithHttpInfo(id); final response = await userDeleteUserWithHttpInfo(id);
if (response.statusCode >= HttpStatus.badRequest) { if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, _decodeBodyBytes(response)); throw ApiException(response.statusCode, _decodeBodyBytes(response));
@ -137,64 +151,9 @@ class UserApi {
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input" // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string. // FormatException when trying to decode an empty string.
if (response.body != null && response.statusCode != HttpStatus.noContent) { if (response.body != null && response.statusCode != HttpStatus.noContent) {
return apiClient.deserialize(_decodeBodyBytes(response), 'MultipartFile') as MultipartFile; return apiClient.deserialize(_decodeBodyBytes(response), 'String') as String;
} }
return Future<MultipartFile>.value(null); return Future<String>.value(null);
}
/// Get a list of user
///
/// Note: This method returns the HTTP [Response].
Future<Response> userGetWithHttpInfo() async {
final path = r'/api/user';
Object postBody;
final queryParams = <QueryParam>[];
final headerParams = <String, String>{};
final formParams = <String, String>{};
final contentTypes = <String>[];
final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null;
final authNames = <String>['bearer'];
if (
nullableContentType != null &&
nullableContentType.toLowerCase().startsWith('multipart/form-data')
) {
bool hasFields = false;
final mp = MultipartRequest(null, null);
if (hasFields) {
postBody = mp;
}
} else {
}
return await apiClient.invokeAPI(
path,
'GET',
queryParams,
postBody,
headerParams,
formParams,
nullableContentType,
authNames,
);
}
/// Get a list of user
Future<MultipartFile> userGet() async {
final response = await userGetWithHttpInfo();
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, _decodeBodyBytes(response));
}
// When a remote server returns no body with a status of 204, we shall not decode it.
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string.
if (response.body != null && response.statusCode != HttpStatus.noContent) {
return apiClient.deserialize(_decodeBodyBytes(response), 'MultipartFile') as MultipartFile;
}
return Future<MultipartFile>.value(null);
} }
/// Get a specific user /// Get a specific user
@ -205,7 +164,7 @@ class UserApi {
/// ///
/// * [String] id (required): /// * [String] id (required):
/// id user /// id user
Future<Response> userGet2WithHttpInfo(String id) async { Future<Response> userGetWithHttpInfo(String id) async {
// Verify required params are set. // Verify required params are set.
if (id == null) { if (id == null) {
throw ApiException(HttpStatus.badRequest, 'Missing required param: id'); throw ApiException(HttpStatus.badRequest, 'Missing required param: id');
@ -254,8 +213,8 @@ class UserApi {
/// ///
/// * [String] id (required): /// * [String] id (required):
/// id user /// id user
Future<UserInfoDetailDTO> userGet2(String id) async { Future<UserInfoDetailDTO> userGet(String id) async {
final response = await userGet2WithHttpInfo(id); final response = await userGetWithHttpInfo(id);
if (response.statusCode >= HttpStatus.badRequest) { if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, _decodeBodyBytes(response)); throw ApiException(response.statusCode, _decodeBodyBytes(response));
} }
@ -268,10 +227,71 @@ class UserApi {
return Future<UserInfoDetailDTO>.value(null); return Future<UserInfoDetailDTO>.value(null);
} }
/// Performs an HTTP 'PUT /api/user' operation and returns the [Response]. /// Get a list of user
///
/// Note: This method returns the HTTP [Response].
Future<Response> userGetAllWithHttpInfo() async {
final path = r'/api/user';
Object postBody;
final queryParams = <QueryParam>[];
final headerParams = <String, String>{};
final formParams = <String, String>{};
final contentTypes = <String>[];
final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null;
final authNames = <String>['bearer'];
if (
nullableContentType != null &&
nullableContentType.toLowerCase().startsWith('multipart/form-data')
) {
bool hasFields = false;
final mp = MultipartRequest(null, null);
if (hasFields) {
postBody = mp;
}
} else {
}
return await apiClient.invokeAPI(
path,
'GET',
queryParams,
postBody,
headerParams,
formParams,
nullableContentType,
authNames,
);
}
/// Get a list of user
Future<List<UserInfo>> userGetAll() async {
final response = await userGetAllWithHttpInfo();
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, _decodeBodyBytes(response));
}
// When a remote server returns no body with a status of 204, we shall not decode it.
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string.
if (response.body != null && response.statusCode != HttpStatus.noContent) {
return (apiClient.deserialize(_decodeBodyBytes(response), 'List<UserInfo>') as List)
.cast<UserInfo>()
.toList(growable: false);
}
return Future<List<UserInfo>>.value(null);
}
/// Update an user
///
/// Note: This method returns the HTTP [Response].
///
/// Parameters: /// Parameters:
/// ///
/// * [UserInfo] userInfo (required): /// * [UserInfo] userInfo (required):
/// User to update
Future<Response> userUpdateUserWithHttpInfo(UserInfo userInfo) async { Future<Response> userUpdateUserWithHttpInfo(UserInfo userInfo) async {
// Verify required params are set. // Verify required params are set.
if (userInfo == null) { if (userInfo == null) {
@ -314,9 +334,12 @@ class UserApi {
); );
} }
/// Update an user
///
/// Parameters: /// Parameters:
/// ///
/// * [UserInfo] userInfo (required): /// * [UserInfo] userInfo (required):
/// User to update
Future<UserInfoDetailDTO> userUpdateUser(UserInfo userInfo) async { Future<UserInfoDetailDTO> userUpdateUser(UserInfo userInfo) async {
final response = await userUpdateUserWithHttpInfo(userInfo); final response = await userUpdateUserWithHttpInfo(userInfo);
if (response.statusCode >= HttpStatus.badRequest) { if (response.statusCode >= HttpStatus.badRequest) {

View File

@ -10,7 +10,7 @@
part of openapi.api; part of openapi.api;
class ApiClient { class ApiClient {
ApiClient({this.basePath = 'http://192.168.31.140'}) { ApiClient({this.basePath = 'http://localhost:25049'}) {
// Setup authentications (key: authentication name, value: authentication). // Setup authentications (key: authentication name, value: authentication).
_authentications[r'bearer'] = OAuth(); _authentications[r'bearer'] = OAuth();
} }
@ -173,6 +173,8 @@ class ApiClient {
return AutomationDetailDTO.fromJson(value); return AutomationDetailDTO.fromJson(value);
case 'AutomationDetailDTOAllOf': case 'AutomationDetailDTOAllOf':
return AutomationDetailDTOAllOf.fromJson(value); return AutomationDetailDTOAllOf.fromJson(value);
case 'AutomationState':
return AutomationState.fromJson(value);
case 'AzureADAuthModel': case 'AzureADAuthModel':
return AzureADAuthModel.fromJson(value); return AzureADAuthModel.fromJson(value);
case 'Book': case 'Book':
@ -226,10 +228,10 @@ class ApiClient {
case 'MqttMessageDTO': case 'MqttMessageDTO':
return MqttMessageDTO.fromJson(value); return MqttMessageDTO.fromJson(value);
case 'OddH2H':
return OddH2H.fromJson(value);
case 'OddNice': case 'OddNice':
return OddNice.fromJson(value); return OddNice.fromJson(value);
case 'OddObject':
return OddObject.fromJson(value);
case 'PanelMenuItem': case 'PanelMenuItem':
return PanelMenuItem.fromJson(value); return PanelMenuItem.fromJson(value);
case 'PanelSection': case 'PanelSection':
@ -248,12 +250,14 @@ class ApiClient {
return ScreenConfiguration.fromJson(value); return ScreenConfiguration.fromJson(value);
case 'ScreenDevice': case 'ScreenDevice':
return ScreenDevice.fromJson(value); return ScreenDevice.fromJson(value);
case 'ScreenWidget':
return ScreenWidget.fromJson(value);
case 'SmartGardenMessage': case 'SmartGardenMessage':
return SmartGardenMessage.fromJson(value); return SmartGardenMessage.fromJson(value);
case 'SmartPrinterMessage': case 'SmartPrinterMessage':
return SmartPrinterMessage.fromJson(value); return SmartPrinterMessage.fromJson(value);
case 'State': case 'TokenDTO':
return State.fromJson(value); return TokenDTO.fromJson(value);
case 'Trigger': case 'Trigger':
return Trigger.fromJson(value); return Trigger.fromJson(value);
case 'TriggerType': case 'TriggerType':
@ -270,8 +274,6 @@ class ApiClient {
case 'ViewBy': case 'ViewBy':
return ViewByTypeTransformer().decode(value); return ViewByTypeTransformer().decode(value);
case 'Widget':
return Widget.fromJson(value);
default: default:
Match match; Match match;
if (value is List && (match = _regList.firstMatch(targetType)) != null) { if (value is List && (match = _regList.firstMatch(targetType)) != null) {

View File

@ -24,7 +24,7 @@ class Action {
String deviceId; String deviceId;
List<State> states; List<AutomationState> states;
String rawRequest; String rawRequest;
@ -83,7 +83,7 @@ class Action {
: Action( : Action(
groupId: json[r'groupId'], groupId: json[r'groupId'],
deviceId: json[r'deviceId'], deviceId: json[r'deviceId'],
states: State.listFromJson(json[r'states']), states: AutomationState.listFromJson(json[r'states']),
rawRequest: json[r'rawRequest'], rawRequest: json[r'rawRequest'],
providerId: json[r'providerId'], providerId: json[r'providerId'],
type: ActionType.fromJson(json[r'type']), type: ActionType.fromJson(json[r'type']),

View File

@ -15,6 +15,7 @@ class Automation {
this.id, this.id,
this.userId, this.userId,
this.name, this.name,
this.active,
this.createdDate, this.createdDate,
this.updatedDate, this.updatedDate,
this.triggers, this.triggers,
@ -29,6 +30,8 @@ class Automation {
String name; String name;
bool active;
DateTime createdDate; DateTime createdDate;
DateTime updatedDate; DateTime updatedDate;
@ -46,6 +49,7 @@ class Automation {
other.id == id && other.id == id &&
other.userId == userId && other.userId == userId &&
other.name == name && other.name == name &&
other.active == active &&
other.createdDate == createdDate && other.createdDate == createdDate &&
other.updatedDate == updatedDate && other.updatedDate == updatedDate &&
other.triggers == triggers && other.triggers == triggers &&
@ -58,6 +62,7 @@ class Automation {
(id == null ? 0 : id.hashCode) + (id == null ? 0 : id.hashCode) +
(userId == null ? 0 : userId.hashCode) + (userId == null ? 0 : userId.hashCode) +
(name == null ? 0 : name.hashCode) + (name == null ? 0 : name.hashCode) +
(active == null ? 0 : active.hashCode) +
(createdDate == null ? 0 : createdDate.hashCode) + (createdDate == null ? 0 : createdDate.hashCode) +
(updatedDate == null ? 0 : updatedDate.hashCode) + (updatedDate == null ? 0 : updatedDate.hashCode) +
(triggers == null ? 0 : triggers.hashCode) + (triggers == null ? 0 : triggers.hashCode) +
@ -66,7 +71,7 @@ class Automation {
(devicesIds == null ? 0 : devicesIds.hashCode); (devicesIds == null ? 0 : devicesIds.hashCode);
@override @override
String toString() => 'Automation[id=$id, userId=$userId, name=$name, createdDate=$createdDate, updatedDate=$updatedDate, triggers=$triggers, conditions=$conditions, actions=$actions, devicesIds=$devicesIds]'; String toString() => 'Automation[id=$id, userId=$userId, name=$name, active=$active, createdDate=$createdDate, updatedDate=$updatedDate, triggers=$triggers, conditions=$conditions, actions=$actions, devicesIds=$devicesIds]';
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final json = <String, dynamic>{}; final json = <String, dynamic>{};
@ -79,6 +84,9 @@ class Automation {
if (name != null) { if (name != null) {
json[r'name'] = name; json[r'name'] = name;
} }
if (active != null) {
json[r'active'] = active;
}
if (createdDate != null) { if (createdDate != null) {
json[r'createdDate'] = createdDate.toUtc().toIso8601String(); json[r'createdDate'] = createdDate.toUtc().toIso8601String();
} }
@ -108,6 +116,7 @@ class Automation {
id: json[r'id'], id: json[r'id'],
userId: json[r'userId'], userId: json[r'userId'],
name: json[r'name'], name: json[r'name'],
active: json[r'active'],
createdDate: json[r'createdDate'] == null createdDate: json[r'createdDate'] == null
? null ? null
: DateTime.parse(json[r'createdDate']), : DateTime.parse(json[r'createdDate']),

View File

@ -14,6 +14,7 @@ class AutomationCreateOrUpdateDetailDTO {
AutomationCreateOrUpdateDetailDTO({ AutomationCreateOrUpdateDetailDTO({
this.id, this.id,
this.name, this.name,
this.active,
this.userId, this.userId,
this.createdDate, this.createdDate,
this.updatedDate, this.updatedDate,
@ -27,6 +28,8 @@ class AutomationCreateOrUpdateDetailDTO {
String name; String name;
bool active;
String userId; String userId;
DateTime createdDate; DateTime createdDate;
@ -45,6 +48,7 @@ class AutomationCreateOrUpdateDetailDTO {
bool operator ==(Object other) => identical(this, other) || other is AutomationCreateOrUpdateDetailDTO && bool operator ==(Object other) => identical(this, other) || other is AutomationCreateOrUpdateDetailDTO &&
other.id == id && other.id == id &&
other.name == name && other.name == name &&
other.active == active &&
other.userId == userId && other.userId == userId &&
other.createdDate == createdDate && other.createdDate == createdDate &&
other.updatedDate == updatedDate && other.updatedDate == updatedDate &&
@ -57,6 +61,7 @@ class AutomationCreateOrUpdateDetailDTO {
int get hashCode => int get hashCode =>
(id == null ? 0 : id.hashCode) + (id == null ? 0 : id.hashCode) +
(name == null ? 0 : name.hashCode) + (name == null ? 0 : name.hashCode) +
(active == null ? 0 : active.hashCode) +
(userId == null ? 0 : userId.hashCode) + (userId == null ? 0 : userId.hashCode) +
(createdDate == null ? 0 : createdDate.hashCode) + (createdDate == null ? 0 : createdDate.hashCode) +
(updatedDate == null ? 0 : updatedDate.hashCode) + (updatedDate == null ? 0 : updatedDate.hashCode) +
@ -66,7 +71,7 @@ class AutomationCreateOrUpdateDetailDTO {
(deviceIds == null ? 0 : deviceIds.hashCode); (deviceIds == null ? 0 : deviceIds.hashCode);
@override @override
String toString() => 'AutomationCreateOrUpdateDetailDTO[id=$id, name=$name, userId=$userId, createdDate=$createdDate, updatedDate=$updatedDate, triggers=$triggers, conditions=$conditions, actions=$actions, deviceIds=$deviceIds]'; String toString() => 'AutomationCreateOrUpdateDetailDTO[id=$id, name=$name, active=$active, userId=$userId, createdDate=$createdDate, updatedDate=$updatedDate, triggers=$triggers, conditions=$conditions, actions=$actions, deviceIds=$deviceIds]';
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final json = <String, dynamic>{}; final json = <String, dynamic>{};
@ -76,6 +81,9 @@ class AutomationCreateOrUpdateDetailDTO {
if (name != null) { if (name != null) {
json[r'name'] = name; json[r'name'] = name;
} }
if (active != null) {
json[r'active'] = active;
}
if (userId != null) { if (userId != null) {
json[r'userId'] = userId; json[r'userId'] = userId;
} }
@ -107,6 +115,7 @@ class AutomationCreateOrUpdateDetailDTO {
: AutomationCreateOrUpdateDetailDTO( : AutomationCreateOrUpdateDetailDTO(
id: json[r'id'], id: json[r'id'],
name: json[r'name'], name: json[r'name'],
active: json[r'active'],
userId: json[r'userId'], userId: json[r'userId'],
createdDate: json[r'createdDate'] == null createdDate: json[r'createdDate'] == null
? null ? null

View File

@ -14,6 +14,7 @@ class AutomationDetailDTO {
AutomationDetailDTO({ AutomationDetailDTO({
this.id, this.id,
this.name, this.name,
this.active,
this.userId, this.userId,
this.createdDate, this.createdDate,
this.updatedDate, this.updatedDate,
@ -27,6 +28,8 @@ class AutomationDetailDTO {
String name; String name;
bool active;
String userId; String userId;
DateTime createdDate; DateTime createdDate;
@ -45,6 +48,7 @@ class AutomationDetailDTO {
bool operator ==(Object other) => identical(this, other) || other is AutomationDetailDTO && bool operator ==(Object other) => identical(this, other) || other is AutomationDetailDTO &&
other.id == id && other.id == id &&
other.name == name && other.name == name &&
other.active == active &&
other.userId == userId && other.userId == userId &&
other.createdDate == createdDate && other.createdDate == createdDate &&
other.updatedDate == updatedDate && other.updatedDate == updatedDate &&
@ -57,6 +61,7 @@ class AutomationDetailDTO {
int get hashCode => int get hashCode =>
(id == null ? 0 : id.hashCode) + (id == null ? 0 : id.hashCode) +
(name == null ? 0 : name.hashCode) + (name == null ? 0 : name.hashCode) +
(active == null ? 0 : active.hashCode) +
(userId == null ? 0 : userId.hashCode) + (userId == null ? 0 : userId.hashCode) +
(createdDate == null ? 0 : createdDate.hashCode) + (createdDate == null ? 0 : createdDate.hashCode) +
(updatedDate == null ? 0 : updatedDate.hashCode) + (updatedDate == null ? 0 : updatedDate.hashCode) +
@ -66,7 +71,7 @@ class AutomationDetailDTO {
(devicesIds == null ? 0 : devicesIds.hashCode); (devicesIds == null ? 0 : devicesIds.hashCode);
@override @override
String toString() => 'AutomationDetailDTO[id=$id, name=$name, userId=$userId, createdDate=$createdDate, updatedDate=$updatedDate, triggers=$triggers, conditions=$conditions, actions=$actions, devicesIds=$devicesIds]'; String toString() => 'AutomationDetailDTO[id=$id, name=$name, active=$active, userId=$userId, createdDate=$createdDate, updatedDate=$updatedDate, triggers=$triggers, conditions=$conditions, actions=$actions, devicesIds=$devicesIds]';
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final json = <String, dynamic>{}; final json = <String, dynamic>{};
@ -76,6 +81,9 @@ class AutomationDetailDTO {
if (name != null) { if (name != null) {
json[r'name'] = name; json[r'name'] = name;
} }
if (active != null) {
json[r'active'] = active;
}
if (userId != null) { if (userId != null) {
json[r'userId'] = userId; json[r'userId'] = userId;
} }
@ -107,6 +115,7 @@ class AutomationDetailDTO {
: AutomationDetailDTO( : AutomationDetailDTO(
id: json[r'id'], id: json[r'id'],
name: json[r'name'], name: json[r'name'],
active: json[r'active'],
userId: json[r'userId'], userId: json[r'userId'],
createdDate: json[r'createdDate'] == null createdDate: json[r'createdDate'] == null
? null ? null

View File

@ -14,6 +14,7 @@ class AutomationDTO {
AutomationDTO({ AutomationDTO({
this.id, this.id,
this.name, this.name,
this.active,
this.userId, this.userId,
this.createdDate, this.createdDate,
this.updatedDate, this.updatedDate,
@ -23,6 +24,8 @@ class AutomationDTO {
String name; String name;
bool active;
String userId; String userId;
DateTime createdDate; DateTime createdDate;
@ -33,6 +36,7 @@ class AutomationDTO {
bool operator ==(Object other) => identical(this, other) || other is AutomationDTO && bool operator ==(Object other) => identical(this, other) || other is AutomationDTO &&
other.id == id && other.id == id &&
other.name == name && other.name == name &&
other.active == active &&
other.userId == userId && other.userId == userId &&
other.createdDate == createdDate && other.createdDate == createdDate &&
other.updatedDate == updatedDate; other.updatedDate == updatedDate;
@ -41,12 +45,13 @@ class AutomationDTO {
int get hashCode => int get hashCode =>
(id == null ? 0 : id.hashCode) + (id == null ? 0 : id.hashCode) +
(name == null ? 0 : name.hashCode) + (name == null ? 0 : name.hashCode) +
(active == null ? 0 : active.hashCode) +
(userId == null ? 0 : userId.hashCode) + (userId == null ? 0 : userId.hashCode) +
(createdDate == null ? 0 : createdDate.hashCode) + (createdDate == null ? 0 : createdDate.hashCode) +
(updatedDate == null ? 0 : updatedDate.hashCode); (updatedDate == null ? 0 : updatedDate.hashCode);
@override @override
String toString() => 'AutomationDTO[id=$id, name=$name, userId=$userId, createdDate=$createdDate, updatedDate=$updatedDate]'; String toString() => 'AutomationDTO[id=$id, name=$name, active=$active, userId=$userId, createdDate=$createdDate, updatedDate=$updatedDate]';
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final json = <String, dynamic>{}; final json = <String, dynamic>{};
@ -56,6 +61,9 @@ class AutomationDTO {
if (name != null) { if (name != null) {
json[r'name'] = name; json[r'name'] = name;
} }
if (active != null) {
json[r'active'] = active;
}
if (userId != null) { if (userId != null) {
json[r'userId'] = userId; json[r'userId'] = userId;
} }
@ -75,6 +83,7 @@ class AutomationDTO {
: AutomationDTO( : AutomationDTO(
id: json[r'id'], id: json[r'id'],
name: json[r'name'], name: json[r'name'],
active: json[r'active'],
userId: json[r'userId'], userId: json[r'userId'],
createdDate: json[r'createdDate'] == null createdDate: json[r'createdDate'] == null
? null ? null

View File

@ -0,0 +1,80 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
// @dart=2.0
// ignore_for_file: unused_element, unused_import
// ignore_for_file: always_put_required_named_parameters_first
// ignore_for_file: lines_longer_than_80_chars
part of openapi.api;
class AutomationState {
/// Returns a new [AutomationState] instance.
AutomationState({
this.name,
this.value,
});
String name;
String value;
@override
bool operator ==(Object other) => identical(this, other) || other is AutomationState &&
other.name == name &&
other.value == value;
@override
int get hashCode =>
(name == null ? 0 : name.hashCode) +
(value == null ? 0 : value.hashCode);
@override
String toString() => 'AutomationState[name=$name, value=$value]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
if (name != null) {
json[r'name'] = name;
}
if (value != null) {
json[r'value'] = value;
}
return json;
}
/// Returns a new [AutomationState] instance and imports its values from
/// [json] if it's non-null, null if [json] is null.
static AutomationState fromJson(Map<String, dynamic> json) => json == null
? null
: AutomationState(
name: json[r'name'],
value: json[r'value'],
);
static List<AutomationState> listFromJson(List<dynamic> json, {bool emptyIsNull, bool growable,}) =>
json == null || json.isEmpty
? true == emptyIsNull ? null : <AutomationState>[]
: json.map((v) => AutomationState.fromJson(v)).toList(growable: true == growable);
static Map<String, AutomationState> mapFromJson(Map<String, dynamic> json) {
final map = <String, AutomationState>{};
if (json != null && json.isNotEmpty) {
json.forEach((String key, dynamic v) => map[key] = AutomationState.fromJson(v));
}
return map;
}
// maps a json object with a list of AutomationState-objects as value to a dart map
static Map<String, List<AutomationState>> mapListFromJson(Map<String, dynamic> json, {bool emptyIsNull, bool growable,}) {
final map = <String, List<AutomationState>>{};
if (json != null && json.isNotEmpty) {
json.forEach((String key, dynamic v) {
map[key] = AutomationState.listFromJson(v, emptyIsNull: emptyIsNull, growable: growable);
});
}
return map;
}
}

View File

@ -22,7 +22,7 @@ class Condition {
String deviceId; String deviceId;
OneOfState state; OneOfAutomationState state;
String startTime; String startTime;
@ -82,7 +82,7 @@ class Condition {
? null ? null
: Condition( : Condition(
deviceId: json[r'deviceId'], deviceId: json[r'deviceId'],
state: OneOfState.fromJson(json[r'state']), state: OneOfAutomationState.fromJson(json[r'state']),
startTime: json[r'startTime'], startTime: json[r'startTime'],
endTime: json[r'endTime'], endTime: json[r'endTime'],
type: ConditionType.fromJson(json[r'type']), type: ConditionType.fromJson(json[r'type']),

View File

@ -24,7 +24,7 @@ class OddNice {
String homeTeam; String homeTeam;
OneOfOddH2H odds; OneOfOddObject odds;
@override @override
bool operator ==(Object other) => identical(this, other) || other is OddNice && bool operator ==(Object other) => identical(this, other) || other is OddNice &&
@ -70,7 +70,7 @@ class OddNice {
: (json[r'teams'] as List).cast<String>(), : (json[r'teams'] as List).cast<String>(),
commenceTime: json[r'commence_time'], commenceTime: json[r'commence_time'],
homeTeam: json[r'home_team'], homeTeam: json[r'home_team'],
odds: OneOfOddH2H.fromJson(json[r'odds']), odds: OneOfOddObject.fromJson(json[r'odds']),
); );
static List<OddNice> listFromJson(List<dynamic> json, {bool emptyIsNull, bool growable,}) => static List<OddNice> listFromJson(List<dynamic> json, {bool emptyIsNull, bool growable,}) =>

View File

@ -0,0 +1,89 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
// @dart=2.0
// ignore_for_file: unused_element, unused_import
// ignore_for_file: always_put_required_named_parameters_first
// ignore_for_file: lines_longer_than_80_chars
part of openapi.api;
class OddObject {
/// Returns a new [OddObject] instance.
OddObject({
this.homeOdd,
this.drawOdd,
this.visitOdd,
});
double homeOdd;
double drawOdd;
double visitOdd;
@override
bool operator ==(Object other) => identical(this, other) || other is OddObject &&
other.homeOdd == homeOdd &&
other.drawOdd == drawOdd &&
other.visitOdd == visitOdd;
@override
int get hashCode =>
(homeOdd == null ? 0 : homeOdd.hashCode) +
(drawOdd == null ? 0 : drawOdd.hashCode) +
(visitOdd == null ? 0 : visitOdd.hashCode);
@override
String toString() => 'OddObject[homeOdd=$homeOdd, drawOdd=$drawOdd, visitOdd=$visitOdd]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
if (homeOdd != null) {
json[r'homeOdd'] = homeOdd;
}
if (drawOdd != null) {
json[r'drawOdd'] = drawOdd;
}
if (visitOdd != null) {
json[r'visitOdd'] = visitOdd;
}
return json;
}
/// Returns a new [OddObject] instance and imports its values from
/// [json] if it's non-null, null if [json] is null.
static OddObject fromJson(Map<String, dynamic> json) => json == null
? null
: OddObject(
homeOdd: json[r'homeOdd'],
drawOdd: json[r'drawOdd'],
visitOdd: json[r'visitOdd'],
);
static List<OddObject> listFromJson(List<dynamic> json, {bool emptyIsNull, bool growable,}) =>
json == null || json.isEmpty
? true == emptyIsNull ? null : <OddObject>[]
: json.map((v) => OddObject.fromJson(v)).toList(growable: true == growable);
static Map<String, OddObject> mapFromJson(Map<String, dynamic> json) {
final map = <String, OddObject>{};
if (json != null && json.isNotEmpty) {
json.forEach((String key, dynamic v) => map[key] = OddObject.fromJson(v));
}
return map;
}
// maps a json object with a list of OddObject-objects as value to a dart map
static Map<String, List<OddObject>> mapListFromJson(Map<String, dynamic> json, {bool emptyIsNull, bool growable,}) {
final map = <String, List<OddObject>>{};
if (json != null && json.isNotEmpty) {
json.forEach((String key, dynamic v) {
map[key] = OddObject.listFromJson(v, emptyIsNull: emptyIsNull, growable: growable);
});
}
return map;
}
}

View File

@ -26,7 +26,7 @@ class ScreenConfiguration {
String type; String type;
List<Widget> widgets; List<ScreenWidget> widgets;
int height; int height;
@ -84,7 +84,7 @@ class ScreenConfiguration {
id: json[r'id'], id: json[r'id'],
name: json[r'name'], name: json[r'name'],
type: json[r'type'], type: json[r'type'],
widgets: Widget.listFromJson(json[r'widgets']), widgets: ScreenWidget.listFromJson(json[r'widgets']),
height: json[r'height'], height: json[r'height'],
width: json[r'width'], width: json[r'width'],
); );

View File

@ -0,0 +1,179 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
// @dart=2.0
// ignore_for_file: unused_element, unused_import
// ignore_for_file: always_put_required_named_parameters_first
// ignore_for_file: lines_longer_than_80_chars
part of openapi.api;
class ScreenWidget {
/// Returns a new [ScreenWidget] instance.
ScreenWidget({
this.id,
this.name,
this.displayName,
this.type,
this.activated,
this.form,
this.font,
this.color,
this.size,
this.width,
this.height,
this.positionX,
this.positionY,
});
String id;
String name;
String displayName;
String type;
bool activated;
String form;
String font;
String color;
String size;
int width;
int height;
int positionX;
int positionY;
@override
bool operator ==(Object other) => identical(this, other) || other is ScreenWidget &&
other.id == id &&
other.name == name &&
other.displayName == displayName &&
other.type == type &&
other.activated == activated &&
other.form == form &&
other.font == font &&
other.color == color &&
other.size == size &&
other.width == width &&
other.height == height &&
other.positionX == positionX &&
other.positionY == positionY;
@override
int get hashCode =>
(id == null ? 0 : id.hashCode) +
(name == null ? 0 : name.hashCode) +
(displayName == null ? 0 : displayName.hashCode) +
(type == null ? 0 : type.hashCode) +
(activated == null ? 0 : activated.hashCode) +
(form == null ? 0 : form.hashCode) +
(font == null ? 0 : font.hashCode) +
(color == null ? 0 : color.hashCode) +
(size == null ? 0 : size.hashCode) +
(width == null ? 0 : width.hashCode) +
(height == null ? 0 : height.hashCode) +
(positionX == null ? 0 : positionX.hashCode) +
(positionY == null ? 0 : positionY.hashCode);
@override
String toString() => 'ScreenWidget[id=$id, name=$name, displayName=$displayName, type=$type, activated=$activated, form=$form, font=$font, color=$color, size=$size, width=$width, height=$height, positionX=$positionX, positionY=$positionY]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
if (id != null) {
json[r'id'] = id;
}
if (name != null) {
json[r'name'] = name;
}
if (displayName != null) {
json[r'displayName'] = displayName;
}
if (type != null) {
json[r'type'] = type;
}
if (activated != null) {
json[r'activated'] = activated;
}
if (form != null) {
json[r'form'] = form;
}
if (font != null) {
json[r'font'] = font;
}
if (color != null) {
json[r'color'] = color;
}
if (size != null) {
json[r'size'] = size;
}
if (width != null) {
json[r'width'] = width;
}
if (height != null) {
json[r'height'] = height;
}
if (positionX != null) {
json[r'positionX'] = positionX;
}
if (positionY != null) {
json[r'positionY'] = positionY;
}
return json;
}
/// Returns a new [ScreenWidget] instance and imports its values from
/// [json] if it's non-null, null if [json] is null.
static ScreenWidget fromJson(Map<String, dynamic> json) => json == null
? null
: ScreenWidget(
id: json[r'id'],
name: json[r'name'],
displayName: json[r'displayName'],
type: json[r'type'],
activated: json[r'activated'],
form: json[r'form'],
font: json[r'font'],
color: json[r'color'],
size: json[r'size'],
width: json[r'width'],
height: json[r'height'],
positionX: json[r'positionX'],
positionY: json[r'positionY'],
);
static List<ScreenWidget> listFromJson(List<dynamic> json, {bool emptyIsNull, bool growable,}) =>
json == null || json.isEmpty
? true == emptyIsNull ? null : <ScreenWidget>[]
: json.map((v) => ScreenWidget.fromJson(v)).toList(growable: true == growable);
static Map<String, ScreenWidget> mapFromJson(Map<String, dynamic> json) {
final map = <String, ScreenWidget>{};
if (json != null && json.isNotEmpty) {
json.forEach((String key, dynamic v) => map[key] = ScreenWidget.fromJson(v));
}
return map;
}
// maps a json object with a list of ScreenWidget-objects as value to a dart map
static Map<String, List<ScreenWidget>> mapListFromJson(Map<String, dynamic> json, {bool emptyIsNull, bool growable,}) {
final map = <String, List<ScreenWidget>>{};
if (json != null && json.isNotEmpty) {
json.forEach((String key, dynamic v) {
map[key] = ScreenWidget.listFromJson(v, emptyIsNull: emptyIsNull, growable: growable);
});
}
return map;
}
}

View File

@ -0,0 +1,118 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
// @dart=2.0
// ignore_for_file: unused_element, unused_import
// ignore_for_file: always_put_required_named_parameters_first
// ignore_for_file: lines_longer_than_80_chars
part of openapi.api;
class TokenDTO {
/// Returns a new [TokenDTO] instance.
TokenDTO({
this.accessToken,
this.refreshToken,
this.scope,
this.tokenType,
this.expiresIn,
this.expiration,
});
String accessToken;
String refreshToken;
String scope;
String tokenType;
int expiresIn;
DateTime expiration;
@override
bool operator ==(Object other) => identical(this, other) || other is TokenDTO &&
other.accessToken == accessToken &&
other.refreshToken == refreshToken &&
other.scope == scope &&
other.tokenType == tokenType &&
other.expiresIn == expiresIn &&
other.expiration == expiration;
@override
int get hashCode =>
(accessToken == null ? 0 : accessToken.hashCode) +
(refreshToken == null ? 0 : refreshToken.hashCode) +
(scope == null ? 0 : scope.hashCode) +
(tokenType == null ? 0 : tokenType.hashCode) +
(expiresIn == null ? 0 : expiresIn.hashCode) +
(expiration == null ? 0 : expiration.hashCode);
@override
String toString() => 'TokenDTO[accessToken=$accessToken, refreshToken=$refreshToken, scope=$scope, tokenType=$tokenType, expiresIn=$expiresIn, expiration=$expiration]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
if (accessToken != null) {
json[r'access_token'] = accessToken;
}
if (refreshToken != null) {
json[r'refresh_token'] = refreshToken;
}
if (scope != null) {
json[r'scope'] = scope;
}
if (tokenType != null) {
json[r'token_type'] = tokenType;
}
if (expiresIn != null) {
json[r'expires_in'] = expiresIn;
}
if (expiration != null) {
json[r'expiration'] = expiration.toUtc().toIso8601String();
}
return json;
}
/// Returns a new [TokenDTO] instance and imports its values from
/// [json] if it's non-null, null if [json] is null.
static TokenDTO fromJson(Map<String, dynamic> json) => json == null
? null
: TokenDTO(
accessToken: json[r'access_token'],
refreshToken: json[r'refresh_token'],
scope: json[r'scope'],
tokenType: json[r'token_type'],
expiresIn: json[r'expires_in'],
expiration: json[r'expiration'] == null
? null
: DateTime.parse(json[r'expiration']),
);
static List<TokenDTO> listFromJson(List<dynamic> json, {bool emptyIsNull, bool growable,}) =>
json == null || json.isEmpty
? true == emptyIsNull ? null : <TokenDTO>[]
: json.map((v) => TokenDTO.fromJson(v)).toList(growable: true == growable);
static Map<String, TokenDTO> mapFromJson(Map<String, dynamic> json) {
final map = <String, TokenDTO>{};
if (json != null && json.isNotEmpty) {
json.forEach((String key, dynamic v) => map[key] = TokenDTO.fromJson(v));
}
return map;
}
// maps a json object with a list of TokenDTO-objects as value to a dart map
static Map<String, List<TokenDTO>> mapListFromJson(Map<String, dynamic> json, {bool emptyIsNull, bool growable,}) {
final map = <String, List<TokenDTO>>{};
if (json != null && json.isNotEmpty) {
json.forEach((String key, dynamic v) {
map[key] = TokenDTO.listFromJson(v, emptyIsNull: emptyIsNull, growable: growable);
});
}
return map;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,31 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
// @dart=2.0
// ignore_for_file: unused_element, unused_import
// ignore_for_file: always_put_required_named_parameters_first
// ignore_for_file: lines_longer_than_80_chars
import 'package:counterapi/api.dart';
import 'package:test/test.dart';
// tests for AutomationState
void main() {
final instance = AutomationState();
group('test AutomationState', () {
// String name
test('to test the property `name`', () async {
// TODO
});
// String value
test('to test the property `value`', () async {
// TODO
});
});
}

View File

@ -0,0 +1,36 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
// @dart=2.0
// ignore_for_file: unused_element, unused_import
// ignore_for_file: always_put_required_named_parameters_first
// ignore_for_file: lines_longer_than_80_chars
import 'package:counterapi/api.dart';
import 'package:test/test.dart';
// tests for OddObject
void main() {
final instance = OddObject();
group('test OddObject', () {
// double homeOdd
test('to test the property `homeOdd`', () async {
// TODO
});
// double drawOdd
test('to test the property `drawOdd`', () async {
// TODO
});
// double visitOdd
test('to test the property `visitOdd`', () async {
// TODO
});
});
}

View File

@ -0,0 +1,86 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
// @dart=2.0
// ignore_for_file: unused_element, unused_import
// ignore_for_file: always_put_required_named_parameters_first
// ignore_for_file: lines_longer_than_80_chars
import 'package:counterapi/api.dart';
import 'package:test/test.dart';
// tests for ScreenWidget
void main() {
final instance = ScreenWidget();
group('test ScreenWidget', () {
// String id
test('to test the property `id`', () async {
// TODO
});
// String name
test('to test the property `name`', () async {
// TODO
});
// String displayName
test('to test the property `displayName`', () async {
// TODO
});
// String type
test('to test the property `type`', () async {
// TODO
});
// bool activated
test('to test the property `activated`', () async {
// TODO
});
// String form
test('to test the property `form`', () async {
// TODO
});
// String font
test('to test the property `font`', () async {
// TODO
});
// String color
test('to test the property `color`', () async {
// TODO
});
// String size
test('to test the property `size`', () async {
// TODO
});
// int width
test('to test the property `width`', () async {
// TODO
});
// int height
test('to test the property `height`', () async {
// TODO
});
// int positionX
test('to test the property `positionX`', () async {
// TODO
});
// int positionY
test('to test the property `positionY`', () async {
// TODO
});
});
}

View File

@ -0,0 +1,51 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
// @dart=2.0
// ignore_for_file: unused_element, unused_import
// ignore_for_file: always_put_required_named_parameters_first
// ignore_for_file: lines_longer_than_80_chars
import 'package:counterapi/api.dart';
import 'package:test/test.dart';
// tests for TokenDTO
void main() {
final instance = TokenDTO();
group('test TokenDTO', () {
// String accessToken
test('to test the property `accessToken`', () async {
// TODO
});
// String refreshToken
test('to test the property `refreshToken`', () async {
// TODO
});
// String scope
test('to test the property `scope`', () async {
// TODO
});
// String tokenType
test('to test the property `tokenType`', () async {
// TODO
});
// int expiresIn
test('to test the property `expiresIn`', () async {
// TODO
});
// DateTime expiration
test('to test the property `expiration`', () async {
// TODO
});
});
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff