objectScannedV4 method
Implementation
@override
Future<Either<Failure, ScanResponseModel>> objectScannedV4(
XFile photo, String accessToken,
{String? email}) async {
try {
final formData = FormData.fromMap({
'file': await MultipartFile.fromFile(photo.path, filename: photo.name),
});
final options = Options(headers: {
"Authorization": "Bearer $accessToken",
"X-GATHERER-USER-EMAIL": email ?? ""
});
final response = await dio.post(
'$baseUrl/v4/scanner/scan_image',
options: options,
data: formData,
);
if (response.statusCode == 201) {
return Right(ScanResponseModel.fromJson(response.data));
} else if (response.statusCode == 200) {
return Right(ScanResponseModel.fromJson(jsonDecode(response.data)));
} else {
return Left(GetItemByIDRemoteFailure());
}
} catch (e) {
return Left(GetItemByIDRemoteFailure());
}
}