objectScannedV2 method
Future<Either<Failure, InventoryItemModel> >
objectScannedV2(
- XFile photo,
- String accessToken
override
Implementation
@override
Future<Either<Failure, InventoryItemModel>> objectScannedV2(
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/v3/scanner/scan_image',
options: options,
data: formData,
);
if (response.statusCode == 201) {
return Right(InventoryItemModel.fromJson(response.data));
} else if (response.statusCode == 200) {
return Right(
InventoryItemModel.fromJson(jsonDecode(response.data["data"])));
} else {
return Left(GetItemByIDRemoteFailure());
}
// if (response.statusCode == 201) {
// return Right(response.data["data"].toString());
// } else {
// return Left(GetItemByIDRemoteFailure());
// }
} catch (e) {
_sentryUtil.captureException(e);
return Left(GetItemByIDRemoteFailure());
}
}