login method
Implementation
Future<Map<String, dynamic>> login(String email, String password) async {
try {
final loginResponse = await _executeServiceRequest({
"baseUrl": constants['baseUrls']!['auth'],
"url": constants['routes']!['login'],
"method": 'post',
"headers": {
"securityToken": null,
},
"data": {
"Username": email,
"Password": password,
}
});
if (loginResponse.data['SecurityToken'] == null) {
throw MyQError('Service did not return security token',
'INVALID_SERVICE_RESPONSE');
}
_securityToken = loginResponse.data['SecurityToken'];
_accountId = null;
_devices = [];
return {
"code": constants['codes']!['OK'],
"securityToken": _securityToken,
};
} catch (e) {
// print('login exception e $e');
return {
"code": constants['codes']!['SERVICE_REQUEST_FAILED'],
"securityToken": null
};
}
}