setThumbnailForCrmLead method

  1. @override
Future<NetworkResponse> setThumbnailForCrmLead(
  1. dynamic bytes,
  2. dynamic path,
  3. dynamic uuid
)
override

Implementation

@override
Future<NetworkResponse> setThumbnailForCrmLead(bytes, path, uuid) async {
  bool isDisconnect = await WifiService.isDisconnectWhenCallApi();
  if (isDisconnect) return NetworkResponse.withDisconnect();
  try {
    String fileName = path.split('/').last;
    FormData data = FormData.fromMap({
      'uuid': uuid,
      "fileName": MultipartFile.fromBytes(bytes, filename: fileName),
    });
    Response response = await AppClientsWeb(
            requiredToken: true, token: await appPrefs.getNormalToken())
        .post(AppEndpoint.setThumbnailForCrmLead(), data: data);
    return NetworkResponse.fromResponse(response,
        converter: (json) => json['fileName']);
  } on DioError catch (e) {
    appDebugPrint('DioError: $e');
    return NetworkResponse.withErrorRequest(e);
  } catch (e) {
    return NetworkResponse.withErrorConvert(e);
  }
}