Skip to content

Commit

Permalink
feat: integrate create flag route
Browse files Browse the repository at this point in the history
  • Loading branch information
Valimp committed Jan 22, 2025
1 parent 3f20cca commit 290d3fa
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 1 deletion.
75 changes: 75 additions & 0 deletions lib/src/nutripatrol/create_flag_request.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import 'package:json_annotation/json_annotation.dart';

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

part 'create_flag_request.g.dart';

@JsonSerializable()
class CreateFlagRequest extends JsonObject {
/// Barcode of the product.
@JsonKey()
String? barcode;

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

/// Url of the product
@JsonKey()
late String url;

/// User ID
@JsonKey(name: 'user_id')
late String userId;

/// Device ID
@JsonKey(name: 'device_id')
late String deviceId;

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

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

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

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

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

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

/// Created date of the flag
@JsonKey(name: 'created_at')
late DateTime createdAt;

CreateFlagRequest();

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

@override
Map<String, dynamic> toJson() => _$CreateFlagRequestToJson(this);
}

enum NutripatrolSource {
@JsonValue('mobile')
mobile,

@JsonValue('web')
web,

@JsonValue('robotoff')
robotoff,
}
38 changes: 38 additions & 0 deletions lib/src/nutripatrol/create_flag_request.g.dart

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

3 changes: 2 additions & 1 deletion lib/src/nutripatrol_api_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:convert';

import 'package:http/http.dart';
import 'package:openfoodfacts/src/nutripatrol/create_flag.dart';
import 'package:openfoodfacts/src/nutripatrol/create_flag_request.dart';
import 'package:openfoodfacts/src/nutripatrol/get_tickets.dart';
import 'package:openfoodfacts/src/prices/maybe_error.dart';
import 'utils/http_helper.dart';
Expand Down Expand Up @@ -106,7 +107,7 @@ class NutripatrolApiClient {
///
/// [flag] is the flag to create.
static Future<MaybeError<CreateFlag>> createFlag({
required final CreateFlag flag,
required final CreateFlagRequest flag,
final UriProductHelper uriHelper = uriHelperFoodProd,
}) async {
final Uri uri = getUri(
Expand Down

0 comments on commit 290d3fa

Please sign in to comment.