home screen wip + update service generation + clientmqtt and client api etc

This commit is contained in:
Fransolet Thomas 2022-04-10 02:20:42 +02:00
parent 8a687ca076
commit fd168a9f2c
41 changed files with 13079 additions and 12470 deletions

View File

@ -8,7 +8,7 @@ import 'package:provider/provider.dart';
import 'custom_clipper.dart';
class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
final double _preferredHeight = 55;
final double _preferredHeight = 50;
@override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;

View File

@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flare_flutter/flare_actor.dart';
import 'package:myhomie_app/Screens/Main/MainPage.dart';
import 'package:myhomie_app/Screens/Main/index.dart';
import 'package:myhomie_app/constants.dart';
import 'package:provider/provider.dart';
class CustomNavItem extends StatelessWidget {
@ -22,8 +23,12 @@ class CustomNavItem extends StatelessWidget {
setPage();
},
child: Container(
width: 50,
height: 50,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(25),
color: kMainColor,
),
width: 55,
height: 55,
child: getIconSvg(icon, size.width * 0.1, index.getIndex()),
),
);

View File

@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:mqtt_client/mqtt_server_client.dart';
import 'package:mycoreapi/api.dart';
import 'dart:convert';
import 'package:myhomie_app/client.dart';
@ -22,7 +23,7 @@ class HomieAppContext with ChangeNotifier{
'homeId': homeId,
'host': host,
'language': language,
'token': token,
'token': token
};
}
@ -32,7 +33,8 @@ class HomieAppContext with ChangeNotifier{
host: json['host'] as String,
homeId: json['homeId'] as String,
language: json['language'] as String,
token: json['token'] as String
token: json['token'] as String,
//roomsMainDetails: json['roomsMainDetails'] as List<RoomMainDetailDTO>
);
}

View File

@ -64,11 +64,13 @@ class _BodyState extends State<Body> {
UserInfoDetailDTO user = await clientAPI.userApi.userGet("6182c472e20a6dbcfe8fe82c"); // TO replace user get by email
print(user);
homieAppContext.host = "http://192.168.31.140";// TODO
homieAppContext.clientMQTT = new MqttServerClient(homieAppContext.host.replaceAll('http://', ''),'my_homie_app_'+ Uuid().v1());
homieAppContext.clientAPI = clientAPI;
homieAppContext.userId = user.id;
homieAppContext.language = user.language;
homieAppContext.language = user.language == null ? 'FR': user.language; //
homieAppContext.token = token.accessToken;
// TODO check if we select by default or ask user to select

View File

@ -1,5 +1,9 @@
import 'package:flutter/material.dart';
import 'package:mycoreapi/api.dart';
import 'package:myhomie_app/Components/loading.dart';
import 'package:myhomie_app/Models/homieContext.dart';
import 'package:myhomie_app/app_context.dart';
import 'package:myhomie_app/constants.dart';
import 'package:provider/provider.dart';
class HomeScreen extends StatefulWidget {
@ -22,17 +26,25 @@ class _HomeScreenState extends State<HomeScreen> {
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
final appContext = Provider.of<AppContext>(context);
HomieAppContext homieAppContext = appContext.getContext();
return interfaceElements();
print(homieAppContext.homeId);
print(homieAppContext.clientAPI.roomApi);
// TODO
/*if(appContext.getContext().feed != null) {
return interfaceElements();
} else {
} else {*/
return FutureBuilder(
future: Message.getMessages(this.messages, appContext, false, true),
builder: (context, AsyncSnapshot<List<Message>> snapshot) {
future: homieAppContext.clientAPI.roomApi.roomGetAllWithMainDetails(homieAppContext.homeId),
builder: (context, AsyncSnapshot<List<RoomMainDetailDTO>> snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
return interfaceElements();
print("connectionState done");
print(snapshot);
if(snapshot.data != null) {
return interfaceElements(snapshot.data);
} else {
return Text("No data - or error");
}
} else if (snapshot.connectionState == ConnectionState.none) {
print('ConnectionState.none');
return Text("No data");
@ -41,18 +53,24 @@ class _HomeScreenState extends State<HomeScreen> {
}
}
);
}*/
//}
}
interfaceElements() {
interfaceElements(List<RoomMainDetailDTO> roomsMaindetails) {
Size size = MediaQuery.of(context).size;
final appContext = Provider.of<AppContext>(context);
HomieAppContext homieAppContext = appContext.getContext();
print(roomsMaindetails.length);
print(roomsMaindetails[0].door);
print(roomsMaindetails[0].isDoor);
return RefreshIndicator(
color: Theme.of(context).primaryColor,
displacement: 20,
onRefresh: () async {
print("TODO refresh");
//await Message.getMessages(this.messages, appContext, true, true);
print("onRefresh");
await homieAppContext.clientAPI.roomApi.roomGetAllWithMainDetails(homieAppContext.homeId);
},
child: Container(
height: size.height * 0.8,
@ -60,7 +78,111 @@ class _HomeScreenState extends State<HomeScreen> {
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text("TODO Home - coucou test")
GridView.builder(
shrinkWrap: true,
gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, childAspectRatio: 1),
itemCount: roomsMaindetails.length,
itemBuilder: (BuildContext context, int index) {
return InkWell(
onTap: () {
setState(() {
//selectedSection = menuDTO.sections[index];
print("Hero to room detail");
});
},
child: Container(
decoration: boxDecorationRoom(roomsMaindetails[index], false),
padding: const EdgeInsets.all(5),
margin: EdgeInsets.symmetric(vertical: 8, horizontal: 8),
child: Stack(
children: [
Column(
children: [
Align(
alignment: Alignment.bottomLeft,
child: Text(
roomsMaindetails[index].name,
style: new TextStyle(fontSize: kDetailSize, color: kBackgroundSecondGrey),
),
),
],
),
if(roomsMaindetails[index].isTemperature)
Positioned(
bottom: 10,
left: 0,
child: Row(
children: [
Icon(
Icons.thermostat,
size: 20,
color: kMainColor,
),
Text(
roomsMaindetails[index].temperature,
style: new TextStyle(fontSize: kDescriptionDetailSize, color: kBackgroundSecondGrey),
maxLines: 1,
),
],
)
),
if(roomsMaindetails[index].isHumidity)
Positioned(
bottom: 10,
left: roomsMaindetails[index].isTemperature ? 55 : 0,
child: Row(
children: [
Icon(
Icons.water,
size: 20,
color: kMainColor,
),
Text(
roomsMaindetails[index].humidity,
style: new TextStyle(fontSize: kDescriptionDetailSize, color: kBackgroundSecondGrey),
maxLines: 1,
),
],
)
),
if(roomsMaindetails[index].isDoor)
Positioned(
bottom: 10,
right: 5,
child: Row(
children: [
Icon(
Icons.motion_photos_on_rounded,
size: 20,
color: !roomsMaindetails[index].door ? kMainColor : kBackgroundSecondGrey,
),
],
)
),
if(roomsMaindetails[index].isMotion)
Positioned(
bottom: 10,
right: roomsMaindetails[index].isDoor ? 20 : 5,
child: Row(
children: [
Icon(
Icons.directions_walk,
size: 20,
color: roomsMaindetails[index].motion ? kMainColor : kBackgroundSecondGrey,
),
],
)
),
],
),
),
);
}
),
],
),
),
@ -68,3 +190,26 @@ class _HomeScreenState extends State<HomeScreen> {
);
}
}
boxDecorationRoom(RoomMainDetailDTO roomMainDetailDTO, bool isSelected) {
return BoxDecoration(
color: kBackgroundLight,
shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(20.0),
/*image: roomMainDetailDTO.imageSource != null ? new DecorationImage(
fit: BoxFit.contain,
colorFilter: !isSelected? new ColorFilter.mode(Colors.black.withOpacity(0.5), BlendMode.dstATop) : null,
image: new NetworkImage(
section.imageSource,
),
): null,*/
boxShadow: [
BoxShadow(
color: kBackgroundSecondGrey,
spreadRadius: 0.5,
blurRadius: 6,
offset: Offset(0, 1.5), // changes position of shadow
),
],
);
}

View File

@ -1,8 +1,5 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:mqtt_client/mqtt_client.dart';
import 'package:mqtt_client/mqtt_server_client.dart';
import 'package:myhomie_app/Components/Custom_Navigation_Bar/custom_app_bar.dart';
import 'package:myhomie_app/Components/Custom_Navigation_Bar/custom_bottom_navigation_bar.dart';
@ -32,105 +29,19 @@ class MainPage extends StatefulWidget {
}
class _MainPageState extends State<MainPage> {
int _counter = 0;
final MqttServerClient client = MqttServerClient.withPort('192.168.31.140', 'flutter_client', 1883); // TODO Add switch button or check online connexion if local broker available
setPage() {
setState(() {
pageController.jumpToPage(currentIndex);
});
}
//final MqttServerClient client = MqttServerClient.withPort('myhomie.be', 'flutter_client00', 1883); // TODO ONLINE
/*void _incrementCounter() {
setState(() {
_counter++;
print("client.connectionStatus !!! ==" + client.connectionStatus.toString());
if (client.connectionStatus.state == MqttConnectionState.connected) {
const pubTopic = 'topic/test';
final builder = MqttClientPayloadBuilder();
builder.addString('Hello MQTT');
client.publishMessage(pubTopic, MqttQos.atLeastOnce, builder.payload);
}
});
}*/
// connection succeeded
/* void onConnected() {
print('Connected !!!!!!!!!!!! ----------------------------------');
client.updates.listen((List<MqttReceivedMessage<MqttMessage>> c) {
final MqttPublishMessage message = c[0].payload;
final payload = MqttPublishPayload.bytesToStringAsString(message.payload.message);
print('Received message:$payload from topic: ${c[0].topic}>');
});
}
// unconnected
void onDisconnected() {
print('Disconnected');
}
// subscribe to topic succeeded
void onSubscribed(String topic) {
print('Subscribed topic: $topic');
}
// subscribe to topic failed
void onSubscribeFail(String topic) {
print('Failed to subscribe $topic');
}
// unsubscribe succeeded
void onUnsubscribed(String topic) {
print('Unsubscribed topic: $topic');
}
Future<MqttServerClient> connect() async {
client.logging(on: false);
client.keepAlivePeriod = 20;
client.onDisconnected = onDisconnected;
client.onConnected = onConnected;
client.onSubscribed = onSubscribed;
/// Security context
/*SecurityContext context = new SecurityContext()
..useCertificateChain('path/to/my_cert.pem')
..usePrivateKey('path/to/my_key.pem', password: 'key_password')
..setClientAuthorities('path/to/client.crt', password: 'password');*/
//client.setProtocolV31();
//client.secure = true;
//client.securityContext = context;
final connMessage = MqttConnectMessage()
.authenticateAs('thomas', 'MyCore,1') // TODO ONLINE
/*.keepAliveFor(60)
.withWillTopic('willtopic')
.withWillMessage('Will message')*/
.withClientIdentifier("TESSST")
.startClean();
//.withWillQos(MqttQos.atLeastOnce);
//client.secure = true;
client.connectionMessage = connMessage;
client.autoReconnect = true;
try {
await client.connect();
} catch (e) {
print('Exception: $e');
client.disconnect();
}
client.subscribe("#", MqttQos.atLeastOnce);
return client;
return null;
}*/
@override
Widget build(BuildContext context) {
final appContext = Provider.of<AppContext>(context);
HomieAppContext homieAppContext = appContext.getContext(); // TODO something if null
final MqttServerClient client = homieAppContext.clientMQTT; // TODO Add switch button or check online connexion if local broker available
//homieAppContext.clientMQTT = new MqttServerClient(homieAppContext.host.replaceAll('http://', ''),'my_homie_app_'+ Uuid().v1());
Size size = MediaQuery.of(context).size;
if (!MQTTHelper.instance.isInstantiated)
@ -139,8 +50,6 @@ class _MainPageState extends State<MainPage> {
MQTTHelper.instance.connect(appContext);
}
HomieAppContext homieAppContext = appContext.getContext();
return ChangeNotifierProvider<Index>(
create: (_) => Index(0, appContext.getContext()),
child: Scaffold(
@ -188,7 +97,7 @@ class _MainPageState extends State<MainPage> {
floatingActionButton: FloatingActionButton(
backgroundColor: kMainColor,
onPressed: () {
var message = {
/* var message = {
"userId": homieAppContext.userId,
"width": size.width,
"height": size.height,
@ -211,15 +120,10 @@ class _MainPageState extends State<MainPage> {
builder2.addString(jsonEncode(message2));
print("Send request");
homieAppContext.clientMQTT.publishMessage(pubTopic2, MqttQos.atLeastOnce, builder2.payload);
/*Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return DebugPage();
},
)
)*/
*/
},
child: CustomNavItem(setPage: setPage, icon: NavItemIcon.home, id: 0),
),

View File

@ -6,6 +6,12 @@ const kTitleTextColor = Color(0xFF303030);
const kBodyTextColor = Color(0xFF4B4B4B); // TODO
const kTextLightColor = Color(0xFFCED5DF); // #ced5df
const kBackgroundLight = Color(0xfff3f3f3);
const kBackgroundSecondGrey = Color(0xFF5b5b63);
const kDetailSize = 20.0;
const kDescriptionDetailSize = 15.0;
const kMainColor = Color(0xFF308aae);
/*
const kTextStyle = TextStyle(

View File

@ -20,7 +20,8 @@ void main() async {
if(localContext != null) {
print("we've got an local db !");
localContext.clientAPI = new Client(localContext.host); // TODO "http://192.168.31.140"
isLogged = localContext.token != null; // TODO refresh token..
//isLogged = localContext.token != null; // TODO refresh token..
isLogged = false;
print(localContext);
} else {
print("NO LOCAL DB !");

View File

@ -208,9 +208,3 @@ lib/model/user_info.dart
lib/model/user_info_detail_dto.dart
lib/model/view_by.dart
pubspec.yaml
test/event_filter_test.dart
test/event_home_filter_all_of_test.dart
test/event_home_filter_test.dart
test/list_response_of_event_detail_dto_and_event_home_filter_test.dart
test/room_main_detail_dto_all_of_test.dart
test/room_main_detail_dto_test.dart

View File

@ -56,7 +56,7 @@ try {
## Documentation for API Endpoints
All URIs are relative to *https://localhost:5001*
All URIs are relative to *http://localhost:5000*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
@ -127,9 +127,10 @@ Class | Method | HTTP request | Description
*ProviderApi* | [**providerDelete**](doc\/ProviderApi.md#providerdelete) | **DELETE** /api/provider/{providerId} | Delete a provider
*ProviderApi* | [**providerGetAll**](doc\/ProviderApi.md#providergetall) | **GET** /api/provider/{homeId} | Get all home providers
*ProviderApi* | [**providerUpdate**](doc\/ProviderApi.md#providerupdate) | **PUT** /api/provider | Update a provider
*RoomApi* | [**roomAddDeviceToRoom**](doc\/RoomApi.md#roomadddevicetoroom) | **PUT** /api/room/{roomId} | Add devices in the specified 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* | [**roomDelete2**](doc\/RoomApi.md#roomdelete2) | **DELETE** /api/room/{roomId} | Delete a room
*RoomApi* | [**roomDelete**](doc\/RoomApi.md#roomdelete) | **DELETE** /api/room/{roomId} | Delete a room
*RoomApi* | [**roomDelete2**](doc\/RoomApi.md#roomdelete2) | **DELETE** /api/room/{roomId}/device/{deviceId} | Delete device from a room
*RoomApi* | [**roomDeleteAllForHome**](doc\/RoomApi.md#roomdeleteallforhome) | **DELETE** /api/room/home/{homeId} | Delete all rooms for a specified home
*RoomApi* | [**roomGetAll**](doc\/RoomApi.md#roomgetall) | **GET** /api/room/{homeId} | Get all rooms for the specified home
*RoomApi* | [**roomGetAllWithMainDetails**](doc\/RoomApi.md#roomgetallwithmaindetails) | **GET** /api/room/{homeId}/details | Get all rooms main details for the specified home

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -5,13 +5,14 @@
import 'package:mycoreapi/api.dart';
```
All URIs are relative to *https://localhost:5001*
All URIs are relative to *http://localhost:5000*
Method | HTTP request | Description
------------- | ------------- | -------------
[**roomAddDeviceToRoom**](RoomApi.md#roomadddevicetoroom) | **PUT** /api/room/{roomId} | Add devices in the specified 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
[**roomDelete2**](RoomApi.md#roomdelete2) | **DELETE** /api/room/{roomId} | Delete a room
[**roomDelete**](RoomApi.md#roomdelete) | **DELETE** /api/room/{roomId} | Delete a room
[**roomDelete2**](RoomApi.md#roomdelete2) | **DELETE** /api/room/{roomId}/device/{deviceId} | Delete device from a room
[**roomDeleteAllForHome**](RoomApi.md#roomdeleteallforhome) | **DELETE** /api/room/home/{homeId} | Delete all rooms for a specified home
[**roomGetAll**](RoomApi.md#roomgetall) | **GET** /api/room/{homeId} | Get all rooms for the specified home
[**roomGetAllWithMainDetails**](RoomApi.md#roomgetallwithmaindetails) | **GET** /api/room/{homeId}/details | Get all rooms main details for the specified home
@ -19,6 +20,51 @@ Method | HTTP request | Description
[**roomUpdate**](RoomApi.md#roomupdate) | **PUT** /api/room | Update a room
# **roomAddDeviceToRoom**
> RoomDetailDTO roomAddDeviceToRoom(roomId, requestBody)
Add devices in the specified room
### 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 = RoomApi();
final roomId = roomId_example; // String | Room Id
final requestBody = [List<String>()]; // List<String> | Device Ids
try {
final result = api_instance.roomAddDeviceToRoom(roomId, requestBody);
print(result);
} catch (e) {
print('Exception when calling RoomApi->roomAddDeviceToRoom: $e\n');
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**roomId** | **String**| Room Id |
**requestBody** | [**List<String>**](String.md)| Device Ids |
### Return type
[**RoomDetailDTO**](RoomDetailDTO.md)
### Authorization
[bearer](../README.md#bearer)
### HTTP request headers
- **Content-Type**: application/json
- **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)
# **roomCreate**
> RoomDetailDTO roomCreate(roomCreateOrUpdateDetailDTO)
@ -63,9 +109,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)
# **roomDelete**
> String roomDelete(deviceId, roomId)
> String roomDelete(roomId)
Delete device from a room
Delete a room
### Example
```dart
@ -74,11 +120,10 @@ import 'package:mycoreapi/api.dart';
//defaultApiClient.getAuthentication<OAuth>('bearer').accessToken = 'YOUR_ACCESS_TOKEN';
final api_instance = RoomApi();
final deviceId = deviceId_example; // String | Id of device to delete from the room
final roomId = roomId_example; // String | Id of room
try {
final result = api_instance.roomDelete(deviceId, roomId);
final result = api_instance.roomDelete(roomId);
print(result);
} catch (e) {
print('Exception when calling RoomApi->roomDelete: $e\n');
@ -89,7 +134,6 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**deviceId** | **String**| Id of device to delete from the room |
**roomId** | **String**| Id of room |
### Return type
@ -108,9 +152,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)
# **roomDelete2**
> String roomDelete2(roomId)
> String roomDelete2(deviceId, roomId)
Delete a room
Delete device from a room
### Example
```dart
@ -119,10 +163,11 @@ import 'package:mycoreapi/api.dart';
//defaultApiClient.getAuthentication<OAuth>('bearer').accessToken = 'YOUR_ACCESS_TOKEN';
final api_instance = RoomApi();
final deviceId = deviceId_example; // String | Id of device to delete from the room
final roomId = roomId_example; // String | Id of room
try {
final result = api_instance.roomDelete2(roomId);
final result = api_instance.roomDelete2(deviceId, roomId);
print(result);
} catch (e) {
print('Exception when calling RoomApi->roomDelete2: $e\n');
@ -133,6 +178,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**deviceId** | **String**| Id of device to delete from the room |
**roomId** | **String**| Id of room |
### Return type

View File

@ -13,6 +13,14 @@ Name | Type | Description | Notes
**name** | **String** | | [optional]
**createdDate** | [**DateTime**](DateTime.md) | | [optional]
**updatedDate** | [**DateTime**](DateTime.md) | | [optional]
**isTemperature** | **bool** | | [optional]
**temperature** | **String** | | [optional]
**isHumidity** | **bool** | | [optional]
**humidity** | **String** | | [optional]
**isMotion** | **bool** | | [optional]
**motion** | **bool** | | [optional]
**isDoor** | **bool** | | [optional]
**door** | **bool** | | [optional]
**environmentalDevices** | [**List<DeviceDetailDTO>**](DeviceDetailDTO.md) | | [optional] [default to const []]
**securityDevices** | [**List<DeviceDetailDTO>**](DeviceDetailDTO.md) | | [optional] [default to const []]

View File

@ -10,6 +10,14 @@ Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**createdDate** | [**DateTime**](DateTime.md) | | [optional]
**updatedDate** | [**DateTime**](DateTime.md) | | [optional]
**isTemperature** | **bool** | | [optional]
**temperature** | **String** | | [optional]
**isHumidity** | **bool** | | [optional]
**humidity** | **String** | | [optional]
**isMotion** | **bool** | | [optional]
**motion** | **bool** | | [optional]
**isDoor** | **bool** | | [optional]
**door** | **bool** | | [optional]
**environmentalDevices** | [**List<DeviceDetailDTO>**](DeviceDetailDTO.md) | | [optional] [default to const []]
**securityDevices** | [**List<DeviceDetailDTO>**](DeviceDetailDTO.md) | | [optional] [default to const []]

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -15,6 +15,86 @@ class RoomApi {
final ApiClient apiClient;
/// Add devices in the specified room
///
/// Note: This method returns the HTTP [Response].
///
/// Parameters:
///
/// * [String] roomId (required):
/// Room Id
///
/// * [List<String>] requestBody (required):
/// Device Ids
Future<Response> roomAddDeviceToRoomWithHttpInfo(String roomId, List<String> requestBody) async {
// Verify required params are set.
if (roomId == null) {
throw ApiException(HttpStatus.badRequest, 'Missing required param: roomId');
}
if (requestBody == null) {
throw ApiException(HttpStatus.badRequest, 'Missing required param: requestBody');
}
final path = r'/api/room/{roomId}'
.replaceAll('{' + 'roomId' + '}', roomId.toString());
Object postBody = requestBody;
final queryParams = <QueryParam>[];
final headerParams = <String, String>{};
final formParams = <String, String>{};
final contentTypes = <String>['application/json'];
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,
'PUT',
queryParams,
postBody,
headerParams,
formParams,
nullableContentType,
authNames,
);
}
/// Add devices in the specified room
///
/// Parameters:
///
/// * [String] roomId (required):
/// Room Id
///
/// * [List<String>] requestBody (required):
/// Device Ids
Future<RoomDetailDTO> roomAddDeviceToRoom(String roomId, List<String> requestBody) async {
final response = await roomAddDeviceToRoomWithHttpInfo(roomId, requestBody);
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), 'RoomDetailDTO') as RoomDetailDTO;
}
return Future<RoomDetailDTO>.value(null);
}
/// Create a room
///
/// Note: This method returns the HTTP [Response].
@ -85,6 +165,77 @@ class RoomApi {
return Future<RoomDetailDTO>.value(null);
}
/// Delete a room
///
/// Note: This method returns the HTTP [Response].
///
/// Parameters:
///
/// * [String] roomId (required):
/// Id of room
Future<Response> roomDeleteWithHttpInfo(String roomId) async {
// Verify required params are set.
if (roomId == null) {
throw ApiException(HttpStatus.badRequest, 'Missing required param: roomId');
}
final path = r'/api/room/{roomId}'
.replaceAll('{' + 'roomId' + '}', roomId.toString());
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,
'DELETE',
queryParams,
postBody,
headerParams,
formParams,
nullableContentType,
authNames,
);
}
/// Delete a room
///
/// Parameters:
///
/// * [String] roomId (required):
/// Id of room
Future<String> roomDelete(String roomId) async {
final response = await roomDeleteWithHttpInfo(roomId);
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), 'String') as String;
}
return Future<String>.value(null);
}
/// Delete device from a room
///
/// Note: This method returns the HTTP [Response].
@ -96,7 +247,7 @@ class RoomApi {
///
/// * [String] roomId (required):
/// Id of room
Future<Response> roomDeleteWithHttpInfo(String deviceId, String roomId) async {
Future<Response> roomDelete2WithHttpInfo(String deviceId, String roomId) async {
// Verify required params are set.
if (deviceId == null) {
throw ApiException(HttpStatus.badRequest, 'Missing required param: deviceId');
@ -152,79 +303,8 @@ class RoomApi {
///
/// * [String] roomId (required):
/// Id of room
Future<String> roomDelete(String deviceId, String roomId) async {
final response = await roomDeleteWithHttpInfo(deviceId, roomId);
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), 'String') as String;
}
return Future<String>.value(null);
}
/// Delete a room
///
/// Note: This method returns the HTTP [Response].
///
/// Parameters:
///
/// * [String] roomId (required):
/// Id of room
Future<Response> roomDelete2WithHttpInfo(String roomId) async {
// Verify required params are set.
if (roomId == null) {
throw ApiException(HttpStatus.badRequest, 'Missing required param: roomId');
}
final path = r'/api/room/{roomId}'
.replaceAll('{' + 'roomId' + '}', roomId.toString());
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,
'DELETE',
queryParams,
postBody,
headerParams,
formParams,
nullableContentType,
authNames,
);
}
/// Delete a room
///
/// Parameters:
///
/// * [String] roomId (required):
/// Id of room
Future<String> roomDelete2(String roomId) async {
final response = await roomDelete2WithHttpInfo(roomId);
Future<String> roomDelete2(String deviceId, String roomId) async {
final response = await roomDelete2WithHttpInfo(deviceId, roomId);
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, _decodeBodyBytes(response));
}

View File

@ -10,7 +10,7 @@
part of openapi.api;
class ApiClient {
ApiClient({this.basePath = 'https://localhost:5001'}) {
ApiClient({this.basePath = 'http://localhost:5000'}) {
// Setup authentications (key: authentication name, value: authentication).
_authentications[r'bearer'] = OAuth();
}

View File

@ -17,6 +17,14 @@ class RoomMainDetailDTO {
this.name,
this.createdDate,
this.updatedDate,
this.isTemperature,
this.temperature,
this.isHumidity,
this.humidity,
this.isMotion,
this.motion,
this.isDoor,
this.door,
this.environmentalDevices,
this.securityDevices,
});
@ -31,6 +39,22 @@ class RoomMainDetailDTO {
DateTime updatedDate;
bool isTemperature;
String temperature;
bool isHumidity;
String humidity;
bool isMotion;
bool motion;
bool isDoor;
bool door;
List<DeviceDetailDTO> environmentalDevices;
List<DeviceDetailDTO> securityDevices;
@ -42,6 +66,14 @@ class RoomMainDetailDTO {
other.name == name &&
other.createdDate == createdDate &&
other.updatedDate == updatedDate &&
other.isTemperature == isTemperature &&
other.temperature == temperature &&
other.isHumidity == isHumidity &&
other.humidity == humidity &&
other.isMotion == isMotion &&
other.motion == motion &&
other.isDoor == isDoor &&
other.door == door &&
other.environmentalDevices == environmentalDevices &&
other.securityDevices == securityDevices;
@ -52,11 +84,19 @@ class RoomMainDetailDTO {
(name == null ? 0 : name.hashCode) +
(createdDate == null ? 0 : createdDate.hashCode) +
(updatedDate == null ? 0 : updatedDate.hashCode) +
(isTemperature == null ? 0 : isTemperature.hashCode) +
(temperature == null ? 0 : temperature.hashCode) +
(isHumidity == null ? 0 : isHumidity.hashCode) +
(humidity == null ? 0 : humidity.hashCode) +
(isMotion == null ? 0 : isMotion.hashCode) +
(motion == null ? 0 : motion.hashCode) +
(isDoor == null ? 0 : isDoor.hashCode) +
(door == null ? 0 : door.hashCode) +
(environmentalDevices == null ? 0 : environmentalDevices.hashCode) +
(securityDevices == null ? 0 : securityDevices.hashCode);
@override
String toString() => 'RoomMainDetailDTO[id=$id, homeId=$homeId, name=$name, createdDate=$createdDate, updatedDate=$updatedDate, environmentalDevices=$environmentalDevices, securityDevices=$securityDevices]';
String toString() => 'RoomMainDetailDTO[id=$id, homeId=$homeId, name=$name, createdDate=$createdDate, updatedDate=$updatedDate, isTemperature=$isTemperature, temperature=$temperature, isHumidity=$isHumidity, humidity=$humidity, isMotion=$isMotion, motion=$motion, isDoor=$isDoor, door=$door, environmentalDevices=$environmentalDevices, securityDevices=$securityDevices]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
@ -75,6 +115,30 @@ class RoomMainDetailDTO {
if (updatedDate != null) {
json[r'updatedDate'] = updatedDate.toUtc().toIso8601String();
}
if (isTemperature != null) {
json[r'isTemperature'] = isTemperature;
}
if (temperature != null) {
json[r'temperature'] = temperature;
}
if (isHumidity != null) {
json[r'isHumidity'] = isHumidity;
}
if (humidity != null) {
json[r'humidity'] = humidity;
}
if (isMotion != null) {
json[r'isMotion'] = isMotion;
}
if (motion != null) {
json[r'motion'] = motion;
}
if (isDoor != null) {
json[r'isDoor'] = isDoor;
}
if (door != null) {
json[r'door'] = door;
}
if (environmentalDevices != null) {
json[r'environmentalDevices'] = environmentalDevices;
}
@ -98,6 +162,14 @@ class RoomMainDetailDTO {
updatedDate: json[r'updatedDate'] == null
? null
: DateTime.parse(json[r'updatedDate']),
isTemperature: json[r'isTemperature'],
temperature: json[r'temperature'],
isHumidity: json[r'isHumidity'],
humidity: json[r'humidity'],
isMotion: json[r'isMotion'],
motion: json[r'motion'],
isDoor: json[r'isDoor'],
door: json[r'door'],
environmentalDevices: DeviceDetailDTO.listFromJson(json[r'environmentalDevices']),
securityDevices: DeviceDetailDTO.listFromJson(json[r'securityDevices']),
);

View File

@ -14,6 +14,14 @@ class RoomMainDetailDTOAllOf {
RoomMainDetailDTOAllOf({
this.createdDate,
this.updatedDate,
this.isTemperature,
this.temperature,
this.isHumidity,
this.humidity,
this.isMotion,
this.motion,
this.isDoor,
this.door,
this.environmentalDevices,
this.securityDevices,
});
@ -22,6 +30,22 @@ class RoomMainDetailDTOAllOf {
DateTime updatedDate;
bool isTemperature;
String temperature;
bool isHumidity;
String humidity;
bool isMotion;
bool motion;
bool isDoor;
bool door;
List<DeviceDetailDTO> environmentalDevices;
List<DeviceDetailDTO> securityDevices;
@ -30,6 +54,14 @@ class RoomMainDetailDTOAllOf {
bool operator ==(Object other) => identical(this, other) || other is RoomMainDetailDTOAllOf &&
other.createdDate == createdDate &&
other.updatedDate == updatedDate &&
other.isTemperature == isTemperature &&
other.temperature == temperature &&
other.isHumidity == isHumidity &&
other.humidity == humidity &&
other.isMotion == isMotion &&
other.motion == motion &&
other.isDoor == isDoor &&
other.door == door &&
other.environmentalDevices == environmentalDevices &&
other.securityDevices == securityDevices;
@ -37,11 +69,19 @@ class RoomMainDetailDTOAllOf {
int get hashCode =>
(createdDate == null ? 0 : createdDate.hashCode) +
(updatedDate == null ? 0 : updatedDate.hashCode) +
(isTemperature == null ? 0 : isTemperature.hashCode) +
(temperature == null ? 0 : temperature.hashCode) +
(isHumidity == null ? 0 : isHumidity.hashCode) +
(humidity == null ? 0 : humidity.hashCode) +
(isMotion == null ? 0 : isMotion.hashCode) +
(motion == null ? 0 : motion.hashCode) +
(isDoor == null ? 0 : isDoor.hashCode) +
(door == null ? 0 : door.hashCode) +
(environmentalDevices == null ? 0 : environmentalDevices.hashCode) +
(securityDevices == null ? 0 : securityDevices.hashCode);
@override
String toString() => 'RoomMainDetailDTOAllOf[createdDate=$createdDate, updatedDate=$updatedDate, environmentalDevices=$environmentalDevices, securityDevices=$securityDevices]';
String toString() => 'RoomMainDetailDTOAllOf[createdDate=$createdDate, updatedDate=$updatedDate, isTemperature=$isTemperature, temperature=$temperature, isHumidity=$isHumidity, humidity=$humidity, isMotion=$isMotion, motion=$motion, isDoor=$isDoor, door=$door, environmentalDevices=$environmentalDevices, securityDevices=$securityDevices]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
@ -51,6 +91,30 @@ class RoomMainDetailDTOAllOf {
if (updatedDate != null) {
json[r'updatedDate'] = updatedDate.toUtc().toIso8601String();
}
if (isTemperature != null) {
json[r'isTemperature'] = isTemperature;
}
if (temperature != null) {
json[r'temperature'] = temperature;
}
if (isHumidity != null) {
json[r'isHumidity'] = isHumidity;
}
if (humidity != null) {
json[r'humidity'] = humidity;
}
if (isMotion != null) {
json[r'isMotion'] = isMotion;
}
if (motion != null) {
json[r'motion'] = motion;
}
if (isDoor != null) {
json[r'isDoor'] = isDoor;
}
if (door != null) {
json[r'door'] = door;
}
if (environmentalDevices != null) {
json[r'environmentalDevices'] = environmentalDevices;
}
@ -71,6 +135,14 @@ class RoomMainDetailDTOAllOf {
updatedDate: json[r'updatedDate'] == null
? null
: DateTime.parse(json[r'updatedDate']),
isTemperature: json[r'isTemperature'],
temperature: json[r'temperature'],
isHumidity: json[r'isHumidity'],
humidity: json[r'humidity'],
isMotion: json[r'isMotion'],
motion: json[r'motion'],
isDoor: json[r'isDoor'],
door: json[r'door'],
environmentalDevices: DeviceDetailDTO.listFromJson(json[r'environmentalDevices']),
securityDevices: DeviceDetailDTO.listFromJson(json[r'securityDevices']),
);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff