objectScanned method
this will upload the image and the scanned service will return the inventory details of the object scanned
Implementation
@override
Future<Either<Failure, String>> objectScanned(
XFile photo, String accessToken) async {
try {
final formData = FormData.fromMap({
'file': await MultipartFile.fromFile(photo.path, filename: photo.name),
});
final options = Options(headers: {
"Authorization": "Bearer $accessToken",
});
final response = await dio.post(
'$baseUrl/v2/scanner/scan_image',
options: options,
data: formData,
);
if (response.statusCode == 201) {
return Right(response.data["data"].toString());
} else {
return Left(GetItemByIDRemoteFailure());
}
} catch (e) {
_sentryUtil.captureException(e);
return Left(GetItemByIDRemoteFailure());
}
}