diff --git a/lib/src/open_prices_api_client.dart b/lib/src/open_prices_api_client.dart index 0b7a2bdd1..d53c3e90a 100644 --- a/lib/src/open_prices_api_client.dart +++ b/lib/src/open_prices_api_client.dart @@ -45,11 +45,13 @@ class OpenPricesAPIClient { required final String path, final Map? queryParameters, final UriProductHelper uriHelper = uriHelperFoodProd, + final bool? addUserAgentParameters, }) => uriHelper.getUri( path: path, queryParameters: queryParameters, forcedHost: _getHost(uriHelper), + addUserAgentParameters: addUserAgentParameters, ); static Future> getPrices( @@ -319,14 +321,8 @@ class OpenPricesAPIClient { required final String bearerToken, final UriProductHelper uriHelper = uriHelperFoodProd, }) async { - final String? appName = OpenFoodAPIConfiguration.userAgent?.name; final Uri uri = getUri( path: '/api/v1/prices', - queryParameters: appName == null - ? null - : { - 'app_name': appName, - }, uriHelper: uriHelper, ); final StringBuffer body = StringBuffer(); @@ -440,14 +436,8 @@ class OpenPricesAPIClient { required final String bearerToken, final UriProductHelper uriHelper = uriHelperFoodProd, }) async { - final String? appName = OpenFoodAPIConfiguration.userAgent?.name; final Uri uri = getUri( path: '/api/v1/proofs/upload', - queryParameters: appName == null - ? null - : { - 'app_name': appName, - }, uriHelper: uriHelper, ); diff --git a/lib/src/prices/proof.dart b/lib/src/prices/proof.dart index afbb25b60..83439717b 100644 --- a/lib/src/prices/proof.dart +++ b/lib/src/prices/proof.dart @@ -55,5 +55,6 @@ class Proof extends JsonObject { : OpenPricesAPIClient.getUri( path: 'img/$filePath', uriHelper: uriProductHelper, + addUserAgentParameters: false, ); } diff --git a/test/api_prices_test.dart b/test/api_prices_test.dart index d180a53e5..79a11ed07 100644 --- a/test/api_prices_test.dart +++ b/test/api_prices_test.dart @@ -1,3 +1,5 @@ +import 'package:http/http.dart' as http; + import 'package:http_parser/http_parser.dart'; import 'package:openfoodfacts/openfoodfacts.dart'; import 'package:test/test.dart'; @@ -8,6 +10,7 @@ void main() { const UriProductHelper uriHelper = uriHelperFoodTest; const User user = TestConstants.TEST_USER; const String invalidBearerToken = 'invalid bearer token'; + const int HTTP_OK = 200; group('$OpenPricesAPIClient default', () { test('getStatus', () async { @@ -610,6 +613,11 @@ void main() { expect(maybeProof.value.mimetype, proof.mimetype); expect(maybeProof.value.created, proof.created); expect(maybeProof.value.filePath, proof.filePath); + if (proof.filePath != null) { + final Uri uri = proof.getFileUrl(uriProductHelper: uriHelper)!; + final http.Response response = await http.get(uri); + expect(response.statusCode, HTTP_OK); + } }); test('upload', () async {