added createDevice function but have issues
This commit is contained in:
parent
779d9c2808
commit
07457869af
|
@ -49,10 +49,21 @@ class CloudServiceAPI{
|
||||||
Response r = await get(url, headers: headers);
|
Response r = await get(url, headers: headers);
|
||||||
return json.decode(r.body) as Map<String, dynamic>;
|
return json.decode(r.body) as Map<String, dynamic>;
|
||||||
}
|
}
|
||||||
Future<bool> createDevice(
|
Future<bool> createDevice(id, primaryThumbprint, secondaryThumbprint) async{
|
||||||
id,
|
var url = Uri.https(address, '/api/devices');
|
||||||
primaryThumbprint,
|
Response r = await post(
|
||||||
secondaryThumbprint) async{
|
url,
|
||||||
|
headers: headers,
|
||||||
|
body: jsonEncode(<String, String>{
|
||||||
|
'id': id,
|
||||||
|
'primaryThumbprint' : primaryThumbprint,
|
||||||
|
'secondaryThumbprint' : secondaryThumbprint
|
||||||
|
})
|
||||||
|
);
|
||||||
|
if (r.statusCode == 200){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
debugPrint('Error createDevice: ${r.statusCode.toString()}');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -39,6 +39,8 @@ class _CloudService extends State<CloudService>{
|
||||||
debugPrint('Devices: ${respond1[0].toString()}');
|
debugPrint('Devices: ${respond1[0].toString()}');
|
||||||
var respond2 = await cloudServiceAPI.getInformation();
|
var respond2 = await cloudServiceAPI.getInformation();
|
||||||
debugPrint('Information: ${respond2.toString()}');
|
debugPrint('Information: ${respond2.toString()}');
|
||||||
|
var respond3 = await cloudServiceAPI.createDevice('1', 'asdas', 'sdwe1');
|
||||||
|
debugPrint('CreateDevice: ${respond3.toString()}');
|
||||||
}, child: const Text("Example"),
|
}, child: const Text("Example"),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in New Issue