getDeviceMasterAccount method

Future<Map<String, dynamic>> getDeviceMasterAccount(
  1. String cameraId
)

Implementation

Future<Map<String, dynamic>> getDeviceMasterAccount(String cameraId) async {
  try {
    final response = await http
        .get(Uri.parse('$baseURL/camera/device-user?cameraId=$cameraId'));

    if (response.statusCode == 200) {
      final details = json.decode(response.body);

      return {
        'isError': false,
        'account': details["account"],
        // 'isOnline': details["isOnline"] ?? false,
        // 'message': details["message"] ?? ""
      };
    } else {
      final errorData = json.decode(response.body);
      return {
        'isError': true,
        'message': errorData['message'],
      };
    }
  } catch (error) {
    return {
      'isError': true,
      'message': 'An error occurred: $error',
    };
  }
}