Skip to content

Commit

Permalink
Merge branch 'master' into feat/openfoodfacts#517
Browse files Browse the repository at this point in the history
  • Loading branch information
monsieurtanuki authored Aug 3, 2022
2 parents fcfbfdd + 2961310 commit 9bcd6c6
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/auto-assign-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ jobs:
assign-author:
runs-on: ubuntu-latest
steps:
- uses: toshimaru/auto-author-assign@v1.5.1
- uses: toshimaru/auto-author-assign@v1.6.1
24 changes: 14 additions & 10 deletions lib/openfoodfacts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import 'utils/HttpHelper.dart';
import 'utils/LanguageHelper.dart';
import 'utils/ProductHelper.dart';
import 'utils/ProductQueryConfigurations.dart';
import 'utils/ProductSearchQueryConfiguration.dart';

export 'events.dart';
export 'folksonomy.dart';
Expand Down Expand Up @@ -293,14 +292,6 @@ class OpenFoodAPIClient {
/// Returns the list of products as SearchResult.
/// Query the language specific host from OpenFoodFacts.
static Future<SearchResult> searchProducts(
final User? user,
final ProductSearchQueryConfiguration configuration, {
final QueryType? queryType,
}) async =>
getProducts(user, configuration, queryType: queryType);

/// Returns products searched according to a [configuration].
static Future<SearchResult> getProducts(
final User? user,
final AbstractQueryConfiguration configuration, {
final QueryType? queryType,
Expand All @@ -312,7 +303,20 @@ class OpenFoodAPIClient {
return result;
}

/// Returns products searched according to a [configuration].
// TODO: deprecated from 2022-07-26; remove when old enough
@Deprecated('Use searchProducts instead')
static Future<SearchResult> getProducts(
final User? user,
final AbstractQueryConfiguration configuration, {
final QueryType? queryType,
}) async =>
searchProducts(user, configuration, queryType: queryType);

/// Search the OpenFoodFacts product database: multiple barcodes in input.
// TODO: deprecated from 2022-07-26; remove when old enough
@Deprecated(
'Use method searchProducts with ProductListQueryConfiguration instead')
static Future<SearchResult> getProductList(
final User? user,
final ProductListQueryConfiguration configuration, {
Expand All @@ -328,7 +332,7 @@ class OpenFoodAPIClient {
final OpenFoodFactsCountry? country,
final QueryType? queryType,
}) async {
final SearchResult searchResult = await getProductList(
final SearchResult searchResult = await searchProducts(
user,
ProductListQueryConfiguration(
barcodes,
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/ProductListQueryConfiguration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ProductListQueryConfiguration extends AbstractQueryConfiguration {
Map<String, String> getParametersMap() {
final Map<String, String> result = super.getParametersMap();

result['code'] = '${barcodes.join(',')}.json';
result['code'] = barcodes.join(',');

return result;
}
Expand Down
2 changes: 1 addition & 1 deletion test/api_getToBeCompletedProducts_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void main() {

final SearchResult result;
try {
result = await OpenFoodAPIClient.getProducts(
result = await OpenFoodAPIClient.searchProducts(
OpenFoodAPIConfiguration.globalUser,
configuration,
queryType: OpenFoodAPIConfiguration.globalQueryType,
Expand Down
2 changes: 1 addition & 1 deletion test/api_getUserProducts_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void main() {

final SearchResult result;
try {
result = await OpenFoodAPIClient.getProducts(
result = await OpenFoodAPIClient.searchProducts(
OpenFoodAPIConfiguration.globalUser,
configuration,
queryType: OpenFoodAPIConfiguration.globalQueryType,
Expand Down
2 changes: 1 addition & 1 deletion test/api_matchedProductV2_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void main() {
BARCODE_CHORIZO,
];

final SearchResult result = await OpenFoodAPIClient.getProductList(
final SearchResult result = await OpenFoodAPIClient.searchProducts(
OpenFoodAPIConfiguration.globalUser,
ProductListQueryConfiguration(
inputBarcodes,
Expand Down
2 changes: 1 addition & 1 deletion test/api_saveProduct_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void main() {
);

testProductResult1(result2);
});
}, skip: 'Random results');

/// Returns a timestamp up to the minute level.
String _getMinuteTimestamp() =>
Expand Down
6 changes: 3 additions & 3 deletions test/api_searchProducts_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ void main() {
language: OpenFoodFactsLanguage.FRENCH,
);

final SearchResult result = await OpenFoodAPIClient.getProductList(
final SearchResult result = await OpenFoodAPIClient.searchProducts(
TestConstants.PROD_USER,
configuration,
queryType: QueryType.PROD,
Expand Down Expand Up @@ -573,7 +573,7 @@ void main() {
sortOption: SortOption.PRODUCT_NAME,
);

final result = await OpenFoodAPIClient.getProductList(
final result = await OpenFoodAPIClient.searchProducts(
TestConstants.PROD_USER, configuration);
if (result.products == null || result.products!.isEmpty) {
break;
Expand Down Expand Up @@ -629,7 +629,7 @@ void main() {
language: OpenFoodFactsLanguage.FRENCH,
);

final SearchResult result = await OpenFoodAPIClient.getProductList(
final SearchResult result = await OpenFoodAPIClient.searchProducts(
TestConstants.PROD_USER,
configuration,
queryType: QueryType.PROD,
Expand Down

0 comments on commit 9bcd6c6

Please sign in to comment.