getDevices method
Implementation
Future<Map<String, dynamic>> getDevices() async {
try {
if (_accountId == null) {
await _getAccountId();
}
final String url = constants['routes']!['getDevices'] as String;
final getDevicesServiceResponse = await _executeServiceRequest({
"baseUrl": constants['baseUrls']!['device'],
"url": url.replaceAll('{accountId}', _accountId),
"method": 'get'
});
if (getDevicesServiceResponse.data == null ||
getDevicesServiceResponse.data['items'] == null) {
throw MyQError(
'Service did not return valid devices', 'INVALID_SERVICE_RESPONSE');
}
_devices = getDevicesServiceResponse.data['items'];
return {"code": constants['codes']!['OK'], "devices": _devices};
} catch (e) {
return {
"code": constants['codes']!['ERR_MYQ_AUTHENTICATION_FAILED_LOCKED_OUT'],
"devices": null
};
}
}