import 'package:contacts_plus_plus/config.dart'; class AuthenticationData { static const _unauthenticated = AuthenticationData(userId: "", token: "", secretMachineIdHash: "", isAuthenticated: false); final String userId; final String token; final String secretMachineIdHash; final bool isAuthenticated; const AuthenticationData({ required this.userId, required this.token, required this.secretMachineIdHash, required this.isAuthenticated }); factory AuthenticationData.fromMap(Map map) { map = map["entity"]; final userId = map["userId"]; final token = map["token"]; final machineId = map["secretMachineIdHash"]; if (userId == null || token == null || machineId == null) { return _unauthenticated; } return AuthenticationData(userId: userId, token: token, secretMachineIdHash: machineId, isAuthenticated: true); } factory AuthenticationData.unauthenticated() => _unauthenticated; Map get authorizationHeader => { "Authorization": "res $userId:$token", "SecretClientAccessKey": Config.secretClientKey, "UID":"2cde2bd72c104d1785af28ae77c29fc2", }; Map toMap() { return { "userId": userId, "token": token, "secretMachineId": secretMachineIdHash, }; } }