postShareDeviceViaEmail method

  1. @override
Future<String> postShareDeviceViaEmail(
  1. String deviceId,
  2. String? destinationEmail
)
override

Implementation

@override
Future<String> postShareDeviceViaEmail(
    String deviceId, String? destinationEmail) async {
  try {
    final String body = json.encode({
      'device_id': deviceId,
      'email': (destinationEmail != null) ? destinationEmail : ''
    });
    return await dio
        .post('${ApiEndpoints.SHARE}/0', data: body)
        .then((value) => value.data['vcode']);
  } on Exception catch (e) {
    throw HttpHelper.decodeErrorResponse(e,
        tag: TAG,
        logger: logger,
        defaultErrorMessage: 'Failed to share this device via email',
        meta: {
          'device': deviceId,
          'email': (destinationEmail != null) ? destinationEmail : '',
          'method': 'postShareDeviceViaEmail'
        });
  }
}