From 8d011687036e0b3ae622c0a354cefbc6c39a27f3 Mon Sep 17 00:00:00 2001 From: monsieurtanuki Date: Sat, 2 Sep 2023 18:00:34 +0200 Subject: [PATCH] fix!: removed deprecated code (#791) --- lib/openfoodfacts.dart | 2 - lib/src/model/allergens.dart | 4 - lib/src/model/environment_impact_levels.dart | 35 ---- lib/src/model/ingredients_analysis_tags.dart | 12 -- lib/src/model/insight.dart | 13 -- lib/src/model/knowledge_panel_element.dart | 15 -- lib/src/model/parameter/tag_filter.dart | 4 - lib/src/model/product.dart | 28 +-- lib/src/model/product.g.dart | 9 - lib/src/model/product_image.dart | 23 --- lib/src/model/product_result.dart | 26 --- lib/src/model/product_result.g.dart | 28 --- lib/src/model/taxonomy_additive.dart | 4 - lib/src/model/taxonomy_allergen.dart | 4 - lib/src/model/taxonomy_category.dart | 4 - lib/src/model/taxonomy_country.dart | 4 - lib/src/model/taxonomy_ingredient.dart | 4 - lib/src/model/taxonomy_label.dart | 4 - lib/src/model/taxonomy_language.dart | 4 - lib/src/model/taxonomy_packaging.dart | 4 - lib/src/open_food_api_client.dart | 171 ------------------ lib/src/robot_off_api_client.dart | 49 ----- lib/src/utils/country_helper.dart | 4 - lib/src/utils/ocr_field.dart | 4 - lib/src/utils/product_fields.dart | 12 -- .../utils/product_query_configurations.dart | 8 - lib/src/utils/tag_type.dart | 4 - ...er_product_search_query_configuration.dart | 143 --------------- 28 files changed, 1 insertion(+), 625 deletions(-) delete mode 100644 lib/src/model/environment_impact_levels.dart delete mode 100644 lib/src/model/product_result.dart delete mode 100644 lib/src/model/product_result.g.dart delete mode 100644 lib/src/utils/user_product_search_query_configuration.dart diff --git a/lib/openfoodfacts.dart b/lib/openfoodfacts.dart index 27e8d69a95..6386316b6b 100644 --- a/lib/openfoodfacts.dart +++ b/lib/openfoodfacts.dart @@ -48,7 +48,6 @@ export 'src/model/product.dart'; export 'src/model/product_freshness.dart'; export 'src/model/product_image.dart'; export 'src/model/product_packaging.dart'; -export 'src/model/product_result.dart'; export 'src/model/product_result_field_answer.dart'; export 'src/model/product_result_v3.dart'; export 'src/model/product_state.dart'; @@ -111,4 +110,3 @@ export 'src/utils/unit_helper.dart'; export 'src/utils/uri_helper.dart'; export 'src/utils/uri_reader.dart'; export 'src/robot_off_api_client.dart'; -export 'src/utils/user_product_search_query_configuration.dart'; diff --git a/lib/src/model/allergens.dart b/lib/src/model/allergens.dart index 0fd61e9d73..f500b9804e 100644 --- a/lib/src/model/allergens.dart +++ b/lib/src/model/allergens.dart @@ -23,10 +23,6 @@ enum AllergensTag implements OffTagged { @override final String offTag; - - // TODO: deprecated from 2022-11-12; remove when old enough - @Deprecated('Use offTag instead') - String get tag => offTag; } /// List of known allergens for a [Product]. diff --git a/lib/src/model/environment_impact_levels.dart b/lib/src/model/environment_impact_levels.dart deleted file mode 100644 index 5d4c08e0f2..0000000000 --- a/lib/src/model/environment_impact_levels.dart +++ /dev/null @@ -1,35 +0,0 @@ -import 'nutrient_levels.dart'; - -class EnvironmentImpactLevels { - List levels; - - EnvironmentImpactLevels(this.levels); - - static EnvironmentImpactLevels? fromJson(List? json) { - if (json == null) { - return null; - } - List result = []; - - for (String s in json) { - result.add(NutrientLevelExtension.getLevel(s.substring(3))); - } - - return EnvironmentImpactLevels(result); - } - - static List? toJson( - EnvironmentImpactLevels? environmentImpactLevels) { - if (environmentImpactLevels == null) { - return null; - } - - List result = []; - - for (NutrientLevel level in environmentImpactLevels.levels) { - result.add('en:${level.value}'); - } - - return result; - } -} diff --git a/lib/src/model/ingredients_analysis_tags.dart b/lib/src/model/ingredients_analysis_tags.dart index c069b6fa14..030ac66754 100644 --- a/lib/src/model/ingredients_analysis_tags.dart +++ b/lib/src/model/ingredients_analysis_tags.dart @@ -12,10 +12,6 @@ enum VeganStatus implements OffTagged { @override final String offTag; - - // TODO: deprecated from 2022-11-12; remove when old enough - @Deprecated('Use offTag instead') - String get tag => offTag; } enum VegetarianStatus implements OffTagged { @@ -30,10 +26,6 @@ enum VegetarianStatus implements OffTagged { @override final String offTag; - - // TODO: deprecated from 2022-11-12; remove when old enough - @Deprecated('Use offTag instead') - String get tag => offTag; } enum PalmOilFreeStatus implements OffTagged { @@ -48,10 +40,6 @@ enum PalmOilFreeStatus implements OffTagged { @override final String offTag; - - // TODO: deprecated from 2022-11-12; remove when old enough - @Deprecated('Use offTag instead') - String get tag => offTag; } class IngredientsAnalysisTags { diff --git a/lib/src/model/insight.dart b/lib/src/model/insight.dart index 0693834943..d03a905098 100644 --- a/lib/src/model/insight.dart +++ b/lib/src/model/insight.dart @@ -49,19 +49,6 @@ enum InsightType implements OffTagged { OffTagged.fromOffTag(offTag, InsightType.values) as InsightType?; } -// TODO: deprecated from 2023-06-13; remove when old enough -@Deprecated('Use directly InsightType instead') -extension InsightTypesExtension on InsightType? { - // TODO: deprecated from 2023-06-13; remove when old enough - @Deprecated('Use offTag instead') - String? get value => this?.offTag; - - // TODO: deprecated from 2023-06-13; remove when old enough - @Deprecated('Use InsightType.fromOffTag instead') - static InsightType getType(String? s) => - InsightType.fromOffTag(s) ?? InsightType.UNDEFINED; -} - @JsonSerializable() class InsightsResult extends JsonObject { final String? status; diff --git a/lib/src/model/knowledge_panel_element.dart b/lib/src/model/knowledge_panel_element.dart index dbb58da57e..a387cfc1d7 100644 --- a/lib/src/model/knowledge_panel_element.dart +++ b/lib/src/model/knowledge_panel_element.dart @@ -298,21 +298,6 @@ class KnowledgePanelTableElement extends JsonObject { /// "Contribute action" element of the Knowledge panel. @JsonSerializable() class KnowledgePanelActionElement extends JsonObject { - /// Possible needed contribute action: add categories. - // TODO: deprecated from 2023-05-13; remove when old enough - @Deprecated('Use KnowledgePanelAction instead') - static const String ACTION_ADD_CATEGORIES = 'add_categories'; - - /// Possible needed contribute action: add ingredients text. - // TODO: deprecated from 2023-05-13; remove when old enough - @Deprecated('Use KnowledgePanelAction instead') - static const String ACTION_ADD_INGREDIENTS_TEXT = 'add_ingredients_text'; - - /// Possible needed contribute action: add nutrition facts. - // TODO: deprecated from 2023-05-13; remove when old enough - @Deprecated('Use KnowledgePanelAction instead') - static const String ACTION_ADD_NUTRITION_FACTS = 'add_nutrition_facts'; - /// HTML description. final String html; diff --git a/lib/src/model/parameter/tag_filter.dart b/lib/src/model/parameter/tag_filter.dart index d8e18aec7f..51a417b6a8 100644 --- a/lib/src/model/parameter/tag_filter.dart +++ b/lib/src/model/parameter/tag_filter.dart @@ -39,10 +39,6 @@ enum TagFilterType implements OffTagged { @override final String offTag; - - // TODO: deprecated from 2022-11-06; remove when old enough - @Deprecated('Use offTag instead') - String get key => offTag; } /// Tag filter ("LIST contains/without ITEM") search API parameter diff --git a/lib/src/model/product.dart b/lib/src/model/product.dart index f841e894cf..4239adf0c0 100644 --- a/lib/src/model/product.dart +++ b/lib/src/model/product.dart @@ -5,7 +5,6 @@ import 'allergens.dart'; import 'attribute.dart'; import 'attribute_group.dart'; import 'ecoscore_data.dart'; -import 'environment_impact_levels.dart'; import 'ingredient.dart'; import 'ingredients_analysis_tags.dart'; import 'knowledge_panels.dart'; @@ -69,10 +68,6 @@ enum ProductImprovement { }); final ProductImprovementCategory category; - - // TODO: deprecated from 2022-11-12; remove when old enough - @Deprecated('Use category instead') - ProductImprovementCategory getCategory() => category; } /// Category: what would this [ProductImprovement] help compute? @@ -245,15 +240,6 @@ class Product extends JsonObject { toJson: Additives.additivesToJson) Additives? additives; - // TODO: deprecated from 2022-10-25; remove when old enough - @Deprecated('Use ecoscore fields instead') - @JsonKey( - name: 'environment_impact_level_tags', - includeIfNull: false, - fromJson: EnvironmentImpactLevels.fromJson, - toJson: EnvironmentImpactLevels.toJson) - EnvironmentImpactLevels? environmentImpactLevels; - @JsonKey( name: 'allergens_tags', includeIfNull: false, @@ -314,8 +300,6 @@ class Product extends JsonObject { includeIfNull: false) Map>? labelsTagsInLanguages; - // TODO: deprecated from 2022-12-16; remove when old enough - @Deprecated('User packagingS instead') @JsonKey(name: 'packaging', includeIfNull: false) String? packaging; @@ -449,14 +433,6 @@ class Product extends JsonObject { toJson: KnowledgePanels.toJsonHelper) KnowledgePanels? knowledgePanels; - // TODO: deprecated from 2022-10-25; remove when old enough - @Deprecated('Use ecoscore fields instead') - @JsonKey( - name: 'environment_infocard', - includeIfNull: false, - ) - String? environmentInfoCard; - @JsonKey(name: 'emb_codes', includeIfNull: false) String? embCodes; @@ -505,7 +481,6 @@ class Product extends JsonObject { this.ingredientsTagsInLanguages, this.ingredientsAnalysisTags, this.additives, - this.environmentImpactLevels, this.allergens, this.nutrientLevels, this.nutrimentEnergyUnit, @@ -517,8 +492,7 @@ class Product extends JsonObject { this.labels, this.labelsTags, this.labelsTagsInLanguages, - // TODO: deprecated from 2022-12-16; remove when old enough - @Deprecated('Use packagingS field instead') this.packaging, + this.packaging, this.packagingTags, this.miscTags, this.statesTags, diff --git a/lib/src/model/product.g.dart b/lib/src/model/product.g.dart index 53d66b0dc8..4f454d1600 100644 --- a/lib/src/model/product.g.dart +++ b/lib/src/model/product.g.dart @@ -1,6 +1,3 @@ -// ignore_for_file: deprecated_member_use_from_same_package -// That's a bit ugly, but we need the previous line in order to pass the pub.dev -// tests, so put that line back after code generation. // GENERATED CODE - DO NOT MODIFY BY HAND part of 'product.dart'; @@ -55,8 +52,6 @@ Product _$ProductFromJson(Map json) => Product( ingredientsAnalysisTags: IngredientsAnalysisTags.fromJson( json['ingredients_analysis_tags'] as List?), additives: Additives.additivesFromJson(json['additives_tags'] as List?), - environmentImpactLevels: EnvironmentImpactLevels.fromJson( - json['environment_impact_level_tags'] as List?), allergens: Allergens.allergensFromJson(json['allergens_tags'] as List?), nutrientLevels: NutrientLevels.fromJson(json['nutrient_levels'] as Map?), nutrimentEnergyUnit: json['nutriment_energy_unit'] as String?, @@ -146,7 +141,6 @@ Product _$ProductFromJson(Map json) => Product( .toList() ..knowledgePanels = KnowledgePanels.fromJsonHelper(json['knowledge_panels'] as Map?) - ..environmentInfoCard = json['environment_infocard'] as String? ..embCodes = json['emb_codes'] as String? ..manufacturingPlaces = json['manufacturing_places'] as String? ..origins = json['origins'] as String? @@ -205,8 +199,6 @@ Map _$ProductToJson(Product instance) { val['ingredients_analysis_tags'] = IngredientsAnalysisTags.toJson(instance.ingredientsAnalysisTags); writeNotNull('additives_tags', Additives.additivesToJson(instance.additives)); - writeNotNull('environment_impact_level_tags', - EnvironmentImpactLevels.toJson(instance.environmentImpactLevels)); writeNotNull('allergens_tags', Allergens.allergensToJson(instance.allergens)); writeNotNull( 'nutrient_levels', NutrientLevels.toJson(instance.nutrientLevels)); @@ -259,7 +251,6 @@ Map _$ProductToJson(Product instance) { 'ecoscore_data', EcoscoreData.toJsonHelper(instance.ecoscoreData)); writeNotNull('knowledge_panels', KnowledgePanels.toJsonHelper(instance.knowledgePanels)); - writeNotNull('environment_infocard', instance.environmentInfoCard); writeNotNull('emb_codes', instance.embCodes); writeNotNull('manufacturing_places', instance.manufacturingPlaces); writeNotNull('origins', instance.origins); diff --git a/lib/src/model/product_image.dart b/lib/src/model/product_image.dart index 541dc0ea15..a71f5b0079 100644 --- a/lib/src/model/product_image.dart +++ b/lib/src/model/product_image.dart @@ -18,21 +18,6 @@ enum ImageField implements OffTagged { /// Returns the first [ImageField] that matches the [offTag]. static ImageField? fromOffTag(final String? offTag) => OffTagged.fromOffTag(offTag, ImageField.values) as ImageField?; - - // TODO: deprecated from 2022-11-13; remove when old enough - @Deprecated('Use field.offTag instead') - String get value => offTag; -} - -extension ImageFieldExtension on ImageField { - // TODO: deprecated from 2022-11-13; remove when old enough - @Deprecated('Use field.offTag instead') - static String getValue(ImageField field) => field.offTag; - - // TODO: deprecated from 2022-11-13; remove when old enough - @Deprecated('Use ImageField.fromOffTag instead') - static ImageField getType(String s) => - ImageField.fromOffTag(s.toLowerCase()) ?? ImageField.OTHER; } enum ImageSize implements OffTagged { @@ -63,14 +48,6 @@ enum ImageSize implements OffTagged { } extension ImageSizeExtension on ImageSize? { - // TODO: deprecated from 2022-11-13; remove when old enough - @Deprecated('Use offTag instead') - String get value => (this ?? ImageSize.UNKNOWN).offTag; - - // TODO: deprecated from 2022-11-13; remove when old enough - @Deprecated('Use number instead') - String toNumber() => (this ?? ImageSize.UNKNOWN).number; - static ImageSize getType(String s) => ImageSize.values.firstWhere( (final ImageSize key) => key.offTag == s.toLowerCase(), orElse: () => ImageSize.UNKNOWN, diff --git a/lib/src/model/product_result.dart b/lib/src/model/product_result.dart deleted file mode 100644 index 8394121db6..0000000000 --- a/lib/src/model/product_result.dart +++ /dev/null @@ -1,26 +0,0 @@ -import 'package:json_annotation/json_annotation.dart'; -import '../interface/json_object.dart'; -import 'product.dart'; - -part 'product_result.g.dart'; - -// TODO: deprecated from 2022-12-01; remove when old enough -@Deprecated('Use ProductResultV3 instead') -@JsonSerializable() -class ProductResult extends JsonObject { - final int? status; - @JsonKey(name: 'code') - final String? barcode; - @JsonKey(name: 'status_verbose') - final String? statusVerbose; - final Product? product; - - const ProductResult( - {this.status, this.barcode, this.statusVerbose, this.product}); - - factory ProductResult.fromJson(Map json) => - _$ProductResultFromJson(json); - - @override - Map toJson() => _$ProductResultToJson(this); -} diff --git a/lib/src/model/product_result.g.dart b/lib/src/model/product_result.g.dart deleted file mode 100644 index c2e917ec83..0000000000 --- a/lib/src/model/product_result.g.dart +++ /dev/null @@ -1,28 +0,0 @@ -// ignore_for_file: deprecated_member_use_from_same_package -// That's a bit ugly, but we need the previous line in order to pass the pub.dev -// tests, so put that line back after code generation. -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'product_result.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -ProductResult _$ProductResultFromJson(Map json) => - ProductResult( - status: json['status'] as int?, - barcode: json['code'] as String?, - statusVerbose: json['status_verbose'] as String?, - product: json['product'] == null - ? null - : Product.fromJson(json['product'] as Map), - ); - -Map _$ProductResultToJson(ProductResult instance) => - { - 'status': instance.status, - 'code': instance.barcode, - 'status_verbose': instance.statusVerbose, - 'product': instance.product, - }; diff --git a/lib/src/model/taxonomy_additive.dart b/lib/src/model/taxonomy_additive.dart index cb8fabab1b..aed570ff37 100644 --- a/lib/src/model/taxonomy_additive.dart +++ b/lib/src/model/taxonomy_additive.dart @@ -53,10 +53,6 @@ enum TaxonomyAdditiveField implements OffTagged { @override final String offTag; - - // TODO: deprecated from 2022-11-12; remove when old enough - @Deprecated('Use offTag instead') - String get key => offTag; } /// A JSON-serializable version of a Additive taxonomy result. diff --git a/lib/src/model/taxonomy_allergen.dart b/lib/src/model/taxonomy_allergen.dart index 2253990274..f1337aeb57 100644 --- a/lib/src/model/taxonomy_allergen.dart +++ b/lib/src/model/taxonomy_allergen.dart @@ -22,10 +22,6 @@ enum TaxonomyAllergenField implements OffTagged { @override final String offTag; - - // TODO: deprecated from 2022-11-12; remove when old enough - @Deprecated('Use offTag instead') - String get key => offTag; } /// A JSON-serializable version of a Allergen taxonomy result. diff --git a/lib/src/model/taxonomy_category.dart b/lib/src/model/taxonomy_category.dart index cb272ea5ef..0f48fce2a3 100644 --- a/lib/src/model/taxonomy_category.dart +++ b/lib/src/model/taxonomy_category.dart @@ -49,10 +49,6 @@ enum TaxonomyCategoryField implements OffTagged { @override final String offTag; - - // TODO: deprecated from 2022-11-12; remove when old enough - @Deprecated('Use offTag instead') - String get key => offTag; } /// A JSON-serializable version of a category taxonomy result. diff --git a/lib/src/model/taxonomy_country.dart b/lib/src/model/taxonomy_country.dart index bf1118176e..a5adbdb844 100644 --- a/lib/src/model/taxonomy_country.dart +++ b/lib/src/model/taxonomy_country.dart @@ -24,10 +24,6 @@ enum TaxonomyCountryField implements OffTagged { @override final String offTag; - - // TODO: deprecated from 2022-11-06; remove when old enough - @Deprecated('Use offTag instead') - String get key => offTag; } /// A JSON-serializable version of a Country taxonomy result. diff --git a/lib/src/model/taxonomy_ingredient.dart b/lib/src/model/taxonomy_ingredient.dart index dd85350326..d85fe4694e 100644 --- a/lib/src/model/taxonomy_ingredient.dart +++ b/lib/src/model/taxonomy_ingredient.dart @@ -69,10 +69,6 @@ enum TaxonomyIngredientField implements OffTagged { @override final String offTag; - - // TODO: deprecated from 2022-11-12; remove when old enough - @Deprecated('Use offTag instead') - String get key => offTag; } /// A JSON-serializable version of a Ingredient taxonomy result. diff --git a/lib/src/model/taxonomy_label.dart b/lib/src/model/taxonomy_label.dart index 960a3c91ae..e81bfa22bd 100644 --- a/lib/src/model/taxonomy_label.dart +++ b/lib/src/model/taxonomy_label.dart @@ -43,10 +43,6 @@ enum TaxonomyLabelField implements OffTagged { @override final String offTag; - - // TODO: deprecated from 2022-11-12; remove when old enough - @Deprecated('Use offTag instead') - String get key => offTag; } /// A JSON-serializable version of a Label taxonomy result. diff --git a/lib/src/model/taxonomy_language.dart b/lib/src/model/taxonomy_language.dart index a8a17a5e3a..a9c8b26055 100644 --- a/lib/src/model/taxonomy_language.dart +++ b/lib/src/model/taxonomy_language.dart @@ -23,10 +23,6 @@ enum TaxonomyLanguageField implements OffTagged { @override final String offTag; - - // TODO: deprecated from 2022-11-12; remove when old enough - @Deprecated('Use offTag instead') - String get key => offTag; } /// A JSON-serializable version of a Language taxonomy result. diff --git a/lib/src/model/taxonomy_packaging.dart b/lib/src/model/taxonomy_packaging.dart index b12bbf4aed..0d4d7a8618 100644 --- a/lib/src/model/taxonomy_packaging.dart +++ b/lib/src/model/taxonomy_packaging.dart @@ -32,10 +32,6 @@ enum TaxonomyPackagingField implements OffTagged { @override final String offTag; - - // TODO: deprecated from 2022-11-12; remove when old enough - @Deprecated('Use offTag instead') - String get key => offTag; } /// A JSON-serializable version of a Packaging taxonomy result. diff --git a/lib/src/open_food_api_client.dart b/lib/src/open_food_api_client.dart index 42f4a67acb..b360b9a5da 100644 --- a/lib/src/open_food_api_client.dart +++ b/lib/src/open_food_api_client.dart @@ -4,7 +4,6 @@ import 'dart:convert'; import 'package:http/http.dart'; import 'interface/json_object.dart'; -import 'model/insight.dart'; import 'model/login_status.dart'; import 'model/ocr_ingredients_result.dart'; import 'model/ocr_packaging_result.dart'; @@ -14,9 +13,7 @@ import 'model/product.dart'; import 'model/product_freshness.dart'; import 'model/product_image.dart'; import 'model/product_packaging.dart'; -import 'model/product_result.dart'; import 'model/product_result_v3.dart'; -import 'model/robotoff_question.dart'; import 'model/search_result.dart'; import 'model/send_image.dart'; import 'model/sign_up_status.dart'; @@ -35,7 +32,6 @@ import 'model/taxonomy_packaging_material.dart'; import 'model/taxonomy_packaging_recycling.dart'; import 'model/taxonomy_packaging_shape.dart'; import 'model/user.dart'; -import 'robot_off_api_client.dart'; import 'utils/abstract_query_configuration.dart'; import 'utils/country_helper.dart'; import 'utils/http_helper.dart'; @@ -229,65 +225,6 @@ class OpenFoodAPIClient { ); } - /// Returns the product for the given barcode. - /// The ProductResult does not contain a product, if the product is not available. - /// No parsing of ingredients. - /// No adjustment by language. - /// No replacing of '"' with '"'. -// TODO: deprecated from 2022-12-01; remove when old enough - @Deprecated('Use getProductV3 instead') - static Future getProductRaw( - String barcode, - OpenFoodFactsLanguage language, { - User? user, - QueryType? queryType, - }) async { - final String productString = await getProductString( - ProductQueryConfiguration( - barcode, - language: language, - country: null, - fields: null, - version: ProductQueryVersion.v3, - ), - user: user, - queryType: queryType, - ); - return ProductResult.fromJson(HttpHelper().jsonDecode(productString)); - } - - /// Returns the product for the given barcode. - /// The ProductResult does not contain a product, if the product is not available. - /// ingredients, images and product name will be prepared for the given language. - /// - /// Please read the language mechanics explanation if you intend to show - /// or update data in specific language: https://github.com/openfoodfacts/openfoodfacts-dart/blob/master/DOCUMENTATION.md#about-languages-mechanics -// TODO: deprecated from 2022-12-01; remove when old enough - @Deprecated('Use getProductV3 instead') - static Future getProduct( - ProductQueryConfiguration configuration, { - User? user, - QueryType? queryType, - }) async { - if (configuration.matchesV3()) { - Exception("The configuration must not match V3!"); - } - final String productString = await getProductString( - configuration, - user: user, - queryType: queryType, - ); - final String jsonStr = _replaceQuotes(productString); - final ProductResult result = ProductResult.fromJson( - HttpHelper().jsonDecode(jsonStr), - ); - if (result.product != null) { - ProductHelper.removeImages(result.product!, configuration.language); - ProductHelper.createImageUrls(result.product!, queryType: queryType); - } - return result; - } - /// The [ProductResultV3] does not contain a product, if the product is not available. /// ingredients, images and product name will be prepared for the given language. /// @@ -788,62 +725,6 @@ class OpenFoodAPIClient { } } - //TODO: deprecated from 2023-04-05; remove when old enough - @Deprecated('Use [RobotOffAPIClient.getProductInsights] Instead') - static Future getProductInsights( - String barcode, - User user, { - QueryType? queryType, - }) => - RobotoffAPIClient.getProductInsights(barcode, queryType: queryType); - - //TODO: deprecated from 2023-04-05; remove when old enough - @Deprecated('Use [RobotOffAPIClient.getProductQuestions] Instead') - static Future getRobotoffQuestionsForProduct( - String barcode, - String lang, { - User? user, - int? count, - QueryType? queryType, - }) => - RobotoffAPIClient.getProductQuestions( - barcode, - OpenFoodFactsLanguage.fromOffTag(lang) ?? - OpenFoodFactsLanguage.ENGLISH, - user: user, - count: count, - queryType: queryType); - - //TODO: deprecated from 2023-04-05; remove when old enough - @Deprecated('Use [RobotOffAPIClient.getRandomQuestions] Instead') - static Future getRandomRobotoffQuestion( - String lang, - User? user, { - int? count, - List? types, - QueryType? queryType, - }) => - RobotoffAPIClient.getRandomQuestions( - OpenFoodFactsLanguage.fromOffTag(lang) ?? - OpenFoodFactsLanguage.ENGLISH, - user, - count: count, - types: types, - queryType: queryType); - - //TODO: deprecated from 2023-04-05; remove when old enough - @Deprecated('Use [RobotOffAPIClient.postInsightAnnotation] Instead') - static Future postInsightAnnotation( - String? insightId, - InsightAnnotation annotation, { - User? user, - String? deviceId, - bool update = true, - final QueryType? queryType, - }) => - RobotoffAPIClient.postInsightAnnotation(insightId, annotation, - deviceId: deviceId, update: update, queryType: queryType); - /// Extract the ingredients from image with the given parameters. /// The ingredients' language should be given (ingredients_fr, ingredients_de, ingredients_en) /// @@ -939,48 +820,6 @@ class OpenFoodAPIClient { ); } - /// Returns suggestions. - /// - /// The [limit] has a max value of 400 on the server side. - /// - /// ```dart - /// List suggestions = - /// await OpenFoodAPIClient.getAutocompletedSuggestions( - /// TagType.CATEGORIES, - /// input: 'Mil', - /// ); - /// - /// print(suggestions); // [Milk drinks fermented with Bifidus, Milk drinks fermented with L casei, Milk jams] - /// ``` - // TODO: deprecated from 2023-02-01; remove when old enough - @Deprecated('Use getSuggestions instead') - static Future> getAutocompletedSuggestions( - final TagType taxonomyType, { - final String input = '', - final OpenFoodFactsLanguage language = OpenFoodFactsLanguage.ENGLISH, - final QueryType? queryType, - final int limit = 25, - }) async { - final Uri uri = UriHelper.getPostUri( - path: '/cgi/suggest.pl', - queryType: queryType, - ); - final Map queryParameters = { - 'tagtype': taxonomyType.offTag, - 'term': input, - 'lc': language.offTag, - 'limit': limit.toString(), - }; - final Response response = await HttpHelper().doPostRequest( - uri, - queryParameters, - null, - queryType: queryType, - addCredentialsToBody: false, - ); - return HttpHelper().jsonDecode(response.body); - } - /// cf. https://openfoodfacts.github.io/openfoodfacts-server/reference/api-v3/#get-/api/v3/taxonomy_suggestions /// /// Consider using [SuggestionManager]. @@ -1024,16 +863,6 @@ class OpenFoodAPIClient { return result; } - /// Uses the auth.pl API to see if login was successful - /// Returns a bool if the login data of the provided user is correct - // TODO: deprecated from 2022-10-12; remove when old enough - @Deprecated('Use login2 instead') - static Future login( - User user, { - QueryType? queryType, - }) async => - (await login2(user, queryType: queryType))?.successful ?? false; - /// Logs in and returns data about the user if relevant. /// /// Returns null if connection issue. diff --git a/lib/src/robot_off_api_client.dart b/lib/src/robot_off_api_client.dart index e691b35241..2fbc8c86c2 100644 --- a/lib/src/robot_off_api_client.dart +++ b/lib/src/robot_off_api_client.dart @@ -21,8 +21,6 @@ class RobotoffAPIClient { InsightType? type, Iterable? countries, String? valueTag, - // TODO: deprecated from 2023-06-13; remove when old enough - @Deprecated('Not used anymore') String? serverDomain, ServerType? serverType, int? count, QueryType? queryType, @@ -114,53 +112,6 @@ class RobotoffAPIClient { return result; } - // TODO: deprecated from 2023-06-13; remove when old enough - @Deprecated('Use getQuestions instead') - static Future getRandomQuestions( - OpenFoodFactsLanguage language, - User? user, { - int? count, - List? types, - QueryType? queryType, - }) async { - if (count == null || count <= 0) { - count = 1; - } - - final List typesValues = []; - if (types != null) { - for (final InsightType t in types) { - final String? value = t.value; - if (value != null) { - typesValues.add(value); - } - } - } - - final Map parameters = { - 'lang': language.code, - 'count': count.toString(), - if (typesValues.isNotEmpty) 'insight_types': typesValues.join(',') - }; - - var robotoffQuestionUri = UriHelper.getRobotoffUri( - path: 'api/v1/questions/random', - queryParameters: parameters, - queryType: queryType, - ); - - Response response = await HttpHelper().doGetRequest( - robotoffQuestionUri, - user: user, - queryType: queryType, - ); - var result = RobotoffQuestionResult.fromJson( - HttpHelper().jsonDecode(utf8.decode(response.bodyBytes)), - ); - - return result; - } - /// cf. https://openfoodfacts.github.io/robotoff/references/api/#tag/Questions/paths/~1questions/get static Future getQuestions( OpenFoodFactsLanguage language, { diff --git a/lib/src/utils/country_helper.dart b/lib/src/utils/country_helper.dart index c43859f9e2..f5053640d9 100644 --- a/lib/src/utils/country_helper.dart +++ b/lib/src/utils/country_helper.dart @@ -764,10 +764,6 @@ enum OpenFoodFactsCountry implements OffTagged { static OpenFoodFactsCountry? fromOffTag(final String? offTag) => OffTagged.fromOffTag(offTag, OpenFoodFactsCountry.values) as OpenFoodFactsCountry?; - - // TODO: deprecated from 2022-11-13; remove when old enough - @Deprecated('Use offTag instead') - String get iso2Code => offTag; } /// Helper class around [OpenFoodFactsCountry] diff --git a/lib/src/utils/ocr_field.dart b/lib/src/utils/ocr_field.dart index 5285a4cdfe..d5b2949306 100644 --- a/lib/src/utils/ocr_field.dart +++ b/lib/src/utils/ocr_field.dart @@ -10,8 +10,4 @@ enum OcrField implements OffTagged { @override final String offTag; - - // TODO: deprecated from 2022-11-12; remove when old enough - @Deprecated('Use offTag instead') - String get key => offTag; } diff --git a/lib/src/utils/product_fields.dart b/lib/src/utils/product_fields.dart index 6d1cc8f015..1e63f3eb45 100644 --- a/lib/src/utils/product_fields.dart +++ b/lib/src/utils/product_fields.dart @@ -51,8 +51,6 @@ enum ProductField implements OffTagged { LABELS(offTag: 'labels'), LABELS_TAGS(offTag: 'labels_tags'), LABELS_TAGS_IN_LANGUAGES(offTag: 'labels_tags_'), - // TODO: deprecated from 2022-12-16; remove when old enough - @Deprecated('Use packagingS field instead') PACKAGING(offTag: 'packaging'), PACKAGINGS(offTag: 'packagings'), PACKAGINGS_COMPLETE(offTag: 'packagings_complete'), @@ -66,9 +64,6 @@ enum ProductField implements OffTagged { STORES(offTag: 'stores'), INGREDIENTS_ANALYSIS_TAGS(offTag: 'ingredients_analysis_tags'), ALLERGENS(offTag: 'allergens_tags'), - // TODO: deprecated from 2022-10-25; remove when old enough - @Deprecated('Use ecoscore fields instead') - ENVIRONMENT_IMPACT_LEVELS(offTag: 'environment_impact_level_tags'), ATTRIBUTE_GROUPS(offTag: 'attribute_groups'), LAST_MODIFIED(offTag: 'last_modified_t'), LAST_MODIFIER(offTag: 'last_modified_by'), @@ -87,9 +82,6 @@ enum ProductField implements OffTagged { ECOSCORE_SCORE(offTag: 'ecoscore_score'), ECOSCORE_DATA(offTag: 'ecoscore_data'), KNOWLEDGE_PANELS(offTag: 'knowledge_panels'), - // TODO: deprecated from 2022-10-25; remove when old enough - @Deprecated('Use ecoscore fields instead') - ENVIRONMENT_INFOCARD(offTag: 'environment_infocard'), EMB_CODES(offTag: 'emb_codes'), MANUFACTURING_PLACES(offTag: 'manufacturing_places'), ORIGINS(offTag: 'origins'), @@ -106,10 +98,6 @@ enum ProductField implements OffTagged { @override final String offTag; - - // TODO: deprecated from 2022-10-19; remove when old enough - @Deprecated('Use offTag instead') - String get key => offTag; } /// NOTE: if one of the fields is IN_LANGUAGES and [languages] is empty - diff --git a/lib/src/utils/product_query_configurations.dart b/lib/src/utils/product_query_configurations.dart index b41ce9e235..b42093c93c 100644 --- a/lib/src/utils/product_query_configurations.dart +++ b/lib/src/utils/product_query_configurations.dart @@ -14,14 +14,6 @@ class ProductQueryVersion { final int version; - // TODO: deprecated from 2022-12-29; remove when old enough - @Deprecated('Use v3 instead') - static const ProductQueryVersion v0 = ProductQueryVersion(0); - - // TODO: deprecated from 2022-12-29; remove when old enough - @Deprecated('Use v3 instead') - static const ProductQueryVersion v2 = ProductQueryVersion(2); - static const ProductQueryVersion v3 = ProductQueryVersion(3); String getPath(final String barcode) { diff --git a/lib/src/utils/tag_type.dart b/lib/src/utils/tag_type.dart index b79d863a95..f01f0808e4 100644 --- a/lib/src/utils/tag_type.dart +++ b/lib/src/utils/tag_type.dart @@ -28,8 +28,4 @@ enum TagType implements OffTagged { /// Returns the first [TagType] that matches the [offTag]. static TagType? fromOffTag(final String? offTag) => OffTagged.fromOffTag(offTag, TagType.values) as TagType?; - - // TODO: deprecated from 2022-10-23; remove when old enough - @Deprecated('Use offTag instead') - String get key => offTag; } diff --git a/lib/src/utils/user_product_search_query_configuration.dart b/lib/src/utils/user_product_search_query_configuration.dart deleted file mode 100644 index 063a9a8206..0000000000 --- a/lib/src/utils/user_product_search_query_configuration.dart +++ /dev/null @@ -1,143 +0,0 @@ -// ignore_for_file: deprecated_member_use_from_same_package - -import '../interface/parameter.dart'; -import '../model/parameter/page_number.dart'; -import '../model/parameter/page_size.dart'; -import 'abstract_query_configuration.dart'; -import 'language_helper.dart'; -import 'product_fields.dart'; - -// TODO: deprecated from 2022-12-29; remove when old enough -/// Get products a user created, photographed, -/// -/// Deprecated, use standard queries instead -/// -/// ```dart -/// UserProductSearchQueryConfiguration configuration = -/// UserProductSearchQueryConfiguration( -/// // Products user photographed -/// type: UserProductSearchType.PHOTOGRAPHER, -/// userId: '', -/// ); -/// -/// SearchResult result = await OpenFoodAPIClient.searchProducts( -/// User(userId: '', password: ''), -/// configuration, -/// ); -/// -/// print(result.count); -/// ยดยดยด -/// -@Deprecated('Use standard queries instead') -class UserProductSearchQueryConfiguration extends AbstractQueryConfiguration { - UserProductSearchQueryConfiguration({ - required this.type, - required this.userId, - final OpenFoodFactsLanguage? language, - final List languages = const [], - final List? fields, - final int? pageNumber, - final int? pageSize, - }) : super( - language: language, - languages: languages, - fields: fields, - additionalParameters: _convertToParametersList(pageNumber, pageSize), - ); - - final UserProductSearchType type; - final String userId; - - static List _convertToParametersList( - int? page, - int? pageSize, - ) { - final result = []; - if (page != null) { - result.add(PageNumber(page: page)); - } - if (pageSize != null) { - result.add(PageSize(size: pageSize)); - } - return result; - } - - @override - String getUriPath() => type.getPath(userId); - - @override - Map getParametersMap() { - final Map parameters = super.getParametersMap(); - String? tmp; - tmp = type.getUserTag(); - if (tmp != null) { - parameters[tmp] = userId; - } - tmp = type.getStateTag(); - if (tmp != null) { - parameters['states_tags'] = tmp; - } - return parameters; - } -} - -// TODO: deprecated from 2022-12-29; remove when old enough -/// Types of user-related searches. -@Deprecated('Use standard queries instead') -enum UserProductSearchType { - /// Where the user created the product. - @Deprecated('Use a standard query with TagFilterType.CREATOR instead') - CONTRIBUTOR, - - /// Where the user edited the product. - @Deprecated('Use a standard query with TagFilterType.INFORMERS instead') - INFORMER, - - /// Where the user photographed the product. - @Deprecated('Use a standard query with TagFilterType.PHOTOGRAPHERS instead') - PHOTOGRAPHER, - - /// Where the user edited a product that still needs to be completed. - @Deprecated( - 'Use a standard query with TagFilterType.INFORMERS and TagFilterType.STATES=ProductState.COMPLETED.toBeCompletedTag instead') - TO_BE_COMPLETED, -} - -// TODO: deprecated from 2022-12-29; remove when old enough -extension UserProductSearchTypeExtension on UserProductSearchType { - /// Returns the URI path for the search. - String getPath(final String userId) { - switch (this) { - case UserProductSearchType.CONTRIBUTOR: - return '/contributor/$userId.json'; // TODO(monsieurtanuki): use '/api/v2/search' instead - case UserProductSearchType.INFORMER: - case UserProductSearchType.PHOTOGRAPHER: - case UserProductSearchType.TO_BE_COMPLETED: - return '/api/v2/search'; - } - } - - String? getUserTag() { - switch (this) { - case UserProductSearchType.CONTRIBUTOR: - return null; - case UserProductSearchType.PHOTOGRAPHER: - return 'photographers_tags'; - case UserProductSearchType.INFORMER: - return 'informers_tags'; - case UserProductSearchType.TO_BE_COMPLETED: - return 'informers_tags'; - } - } - - String? getStateTag() { - switch (this) { - case UserProductSearchType.CONTRIBUTOR: - case UserProductSearchType.PHOTOGRAPHER: - case UserProductSearchType.INFORMER: - return null; - case UserProductSearchType.TO_BE_COMPLETED: - return 'en:to-be-completed'; - } - } -}