searchProduct method
Implementation
Future<NetworkResponse<ProductInfo>> searchProduct(
String barcode, {
required String merchantId,
required String outletId,
}) async {
return _safeCall(() async {
final resp = await _dio.get(
'/search/product/$barcode',
queryParameters: {
'merchantId': merchantId,
'outletId': outletId,
'isMemberLogin': 'false',
},
);
final empty = _emptyBodyError<ProductInfo>(resp, 'Product not found');
if (empty != null) return empty;
final json = asJsonMap(resp.data);
if (json == null) {
return NetworkError('Product not found', code: resp.statusCode);
}
return NetworkSuccess(ProductInfo.fromJson(json));
});
}