putDevice method

  1. @override
Future<bool> putDevice(
  1. DeviceClaimParam param,
  2. DeviceOption options
)
override

Implementation

@override
Future<bool> putDevice(DeviceClaimParam param, DeviceOption options) async {
  try {
    final String body = json.encode({
      'sn': '${param.sn}',
      'model': '${param.model}',
      'name': '${param.name}',
      'desc': '${param.desc}',
      'map_lat': '${param.mapLat}',
      'map_lng': '${param.mapLng}',
      'logo': '${param.logo}',
      'admin_id': '${param.userId}',
      'status': '${param.status}',
      'options': options
    });
    return await dio
        .put('${ApiEndpoints.DEVICES}/${param.id}', data: body)
        .then((value) => true);
  } on Exception catch (e) {
    throw HttpHelper.decodeErrorResponse(e,
        tag: TAG,
        logger: logger,
        defaultErrorMessage: 'Failed to update this device properties',
        meta: {'sn': param.sn, 'method': 'putDevice'});
  }
}