Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Integrate all routes from nutripatrol's API #991

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions lib/openfoodfacts.dart
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll probably need to add the other nutripatrol classes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And nutripatrol_types.dart

Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ export 'src/model/taxonomy_packaging_recycling.dart';
export 'src/model/taxonomy_packaging_shape.dart';
export 'src/model/user.dart';
export 'src/model/user_agent.dart';
export 'src/nutripatrol/create_flag.dart';
export 'src/nutripatrol/get_flag.dart';
export 'src/nutripatrol/get_ticket.dart';
export 'src/nutripatrol/get_tickets.dart';
export 'src/nutripatrol_api_client.dart';
export 'src/open_food_api_client.dart';
export 'src/open_food_search_api_client.dart';
export 'src/open_prices_api_client.dart';
Expand All @@ -103,15 +108,14 @@ export 'src/prices/flavor.dart';
export 'src/prices/get_locations_order.dart';
export 'src/prices/get_locations_parameters.dart';
export 'src/prices/get_locations_result.dart';

export 'src/prices/get_price_count_parameters_helper.dart';
// export 'src/prices/get_parameters_helper.dart'; // uncomment if really needed
export 'src/prices/get_prices_order.dart';
export 'src/prices/get_prices_parameters.dart';
export 'src/prices/get_price_products_order.dart';
export 'src/prices/get_price_products_parameters.dart';
export 'src/prices/get_price_products_result.dart';
export 'src/prices/get_prices_result.dart';
export 'src/prices/get_price_count_parameters_helper.dart';
export 'src/prices/get_proofs_order.dart';
export 'src/prices/get_proofs_parameters.dart';
export 'src/prices/get_proofs_result.dart';
Expand All @@ -134,6 +138,7 @@ export 'src/prices/proof_type.dart';
export 'src/prices/session.dart';
export 'src/prices/update_price_parameters.dart';
export 'src/prices/update_proof_parameters.dart';
export 'src/robot_off_api_client.dart';
export 'src/search/autocomplete_search_result.dart';
export 'src/search/autocomplete_single_result.dart';
export 'src/search/fuzziness.dart';
Expand Down Expand Up @@ -165,4 +170,3 @@ export 'src/utils/too_many_requests_manager.dart';
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';
2 changes: 0 additions & 2 deletions lib/src/model/old_product_result.g.dart
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep the comment as it was.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions lib/src/nutripatrol/create_flag.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:openfoodfacts/src/nutripatrol/get_ticket.dart';

import '../interface/json_object.dart';

part 'create_flag.g.dart';

/// Flag (report) created by the Nutripatrol API.
@JsonSerializable()
class CreateNutripatrolFlag extends JsonObject {
/// Ticket ID associated with the flag
@JsonKey()
late NutripatrolTicket ticket;

/// id of the flag.
@JsonKey()
late int id;

CreateNutripatrolFlag();

factory CreateNutripatrolFlag.fromJson(Map<String, dynamic> json) =>
_$CreateNutripatrolFlagFromJson(json);

@override
Map<String, dynamic> toJson() => _$CreateNutripatrolFlagToJson(this);
}
21 changes: 21 additions & 0 deletions lib/src/nutripatrol/create_flag.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

76 changes: 76 additions & 0 deletions lib/src/nutripatrol/get_flag.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import 'package:json_annotation/json_annotation.dart';
import 'get_ticket.dart';
import '../prices/flavor.dart';

import '../interface/json_object.dart';
import 'nutripatrol_types.dart';

part 'get_flag.g.dart';

/// Get one flag by its ID.
@JsonSerializable()
class NutripatrolFlag extends JsonObject {
/// Flag ID. Read-only.
@JsonKey()
late String id;

/// Ticket ID. Read-only.
@JsonKey()
late NutripatrolTicket ticket;

/// Barcode of the product. Read-only.
@JsonKey()
String? barcode;

/// Type of the flag
@JsonKey()
late NutripatrolType type;

/// Url of the product. Read-only.
@JsonKey()
late String url;

/// User ID. Read-only.
@JsonKey(name: 'user_id')
late String userId;

/// Device ID. Read-only.
@JsonKey(name: 'device_id')
late String deviceId;

/// Source of the flag
@JsonKey()
late NutripatrolSource source;

/// Confidence of the flag
@JsonKey()
double? confidence;

/// Image ID of the flag. Read-only.
@JsonKey(name: 'image_id')
String? imageId;

/// Flavor of the flag
@JsonKey()
late Flavor flavor;

/// Reason of the flag
@JsonKey()
String? reason;

/// Comment of the flag
@JsonKey()
String? comment;

/// created date of the ticket. Read-only.
@JsonKey()
late DateTime created;

NutripatrolFlag();

factory NutripatrolFlag.fromJson(Map<String, dynamic> json) =>
_$NutripatrolFlagFromJson(json);

@override
Map<String, dynamic> toJson() => _$NutripatrolFlagToJson(this);
}
63 changes: 63 additions & 0 deletions lib/src/nutripatrol/get_flag.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 47 additions & 0 deletions lib/src/nutripatrol/get_ticket.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:openfoodfacts/openfoodfacts.dart';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove that line.

import 'nutripatrol_types.dart';

import '../interface/json_object.dart';

part 'get_ticket.g.dart';

/// Get a ticket by its ID.
@JsonSerializable()
class NutripatrolTicket extends JsonObject {
/// Flag ID. Read-only.
@JsonKey()
late int id;

/// Barcode of the product. Read-only.
@JsonKey()
String? barcode;

/// Type of the ticket.
@JsonKey()
late NutripatrolType type;

/// Url of the ticket. Read-only.
@JsonKey()
late String url;

/// Status of the ticket.
@JsonKey()
late NutripatrolTicketStatus status;

/// Image id of the ticket. Read-only.
@JsonKey(name: 'image_id')
String? imageId;

/// Flavor of the ticket.
@JsonKey()
late Flavor flavor;

NutripatrolTicket();

factory NutripatrolTicket.fromJson(Map<String, dynamic> json) =>
_$NutripatrolTicketFromJson(json);

@override
Map<String, dynamic> toJson() => _$NutripatrolTicketToJson(this);
}
47 changes: 47 additions & 0 deletions lib/src/nutripatrol/get_ticket.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions lib/src/nutripatrol/get_tickets.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import 'package:json_annotation/json_annotation.dart';
import 'get_ticket.dart';

import '../interface/json_object.dart';

part 'get_tickets.g.dart';

/// Get the list of tickets.
@JsonSerializable()
class NutripatrolTickets extends JsonObject {
/// List of Tickets
@JsonKey()
late List<NutripatrolTicket> tickets;

/// Max Page
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is a "max page"?

@JsonKey(name: 'max_page')
late int maxPage;

NutripatrolTickets();

factory NutripatrolTickets.fromJson(Map<String, dynamic> json) =>
_$NutripatrolTicketsFromJson(json);

@override
Map<String, dynamic> toJson() => _$NutripatrolTicketsToJson(this);
}
20 changes: 20 additions & 0 deletions lib/src/nutripatrol/get_tickets.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading