-
-
Notifications
You must be signed in to change notification settings - Fork 69
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: 831 - Prices getLocation, getPriceProduct, getStatus methods #855
Changes from all commits
fa419b6
1d1fe78
cc67219
f4a9c91
6719844
cb560f4
52c4a48
4772390
e1f55a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import 'package:json_annotation/json_annotation.dart'; | ||
|
||
import 'location_osm_type.dart'; | ||
import '../interface/json_object.dart'; | ||
import '../utils/json_helper.dart'; | ||
|
||
part 'location.g.dart'; | ||
|
||
/// Location object in the Prices API. | ||
/// | ||
/// cf. `LocationBase` in https://prices.openfoodfacts.net/docs | ||
@JsonSerializable() | ||
class Location extends JsonObject { | ||
/// ID of the location in OpenStreetMap: the store where the product was bought. | ||
@JsonKey(name: 'osm_id') | ||
late int osmId; | ||
|
||
/// Type of the OpenStreetMap location object. | ||
/// | ||
/// Stores can be represented as nodes, ways or relations in OpenStreetMap. | ||
/// It is necessary to be able to fetch the correct information about the | ||
/// store using the ID. | ||
@JsonKey(name: 'osm_type') | ||
late LocationOSMType type; | ||
|
||
/// ID in the Prices API. | ||
@JsonKey(name: 'id') | ||
late int locationId; | ||
|
||
@JsonKey(name: 'osm_name') | ||
String? name; | ||
|
||
@JsonKey(name: 'osm_display_name') | ||
String? displayName; | ||
|
||
@JsonKey(name: 'osm_address_postcode') | ||
String? postcode; | ||
|
||
@JsonKey(name: 'osm_address_city') | ||
String? city; | ||
|
||
@JsonKey(name: 'osm_address_country') | ||
String? country; | ||
|
||
@JsonKey(name: 'osm_lat') | ||
double? latitude; | ||
|
||
@JsonKey(name: 'osm_lon') | ||
double? longitude; | ||
|
||
/// Date when the product was bought. | ||
@JsonKey(fromJson: JsonHelper.stringTimestampToDate) | ||
late DateTime created; | ||
|
||
/// Date when the product was bought. | ||
@JsonKey(fromJson: JsonHelper.nullableStringTimestampToDate) | ||
DateTime? updated; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since you renamed latitude/longitude, I would rename it to |
||
|
||
Location(); | ||
|
||
factory Location.fromJson(Map<String, dynamic> json) => | ||
_$LocationFromJson(json); | ||
|
||
@override | ||
Map<String, dynamic> toJson() => _$LocationToJson(this); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,27 +40,27 @@ class Price extends JsonObject { | |
/// If the price is about a barcode-less product, it must be the price per | ||
/// kilogram or per liter. | ||
@JsonKey() | ||
num? price; | ||
late num price; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By curiosity, why don't you include JsonKeys in this file? |
||
|
||
/// Currency of the price. | ||
@JsonKey() | ||
Currency? currency; | ||
late Currency currency; | ||
|
||
/// ID of the location in OpenStreetMap: the store where the product was bought. | ||
@JsonKey(name: 'location_osm_id') | ||
int? locationOSMId; | ||
late int locationOSMId; | ||
|
||
/// Type of the OpenStreetMap location object. | ||
/// | ||
/// Stores can be represented as nodes, ways or relations in OpenStreetMap. | ||
/// It is necessary to be able to fetch the correct information about the | ||
/// store using the ID. | ||
@JsonKey(name: 'location_osm_type') | ||
LocationOSMType? locationOSMType; | ||
late LocationOSMType locationOSMType; | ||
|
||
/// Date when the product was bought. | ||
@JsonKey(fromJson: JsonHelper.stringTimestampToDate) | ||
DateTime? date; | ||
late DateTime date; | ||
|
||
/// ID of the proof, if any. | ||
/// | ||
|
@@ -77,7 +77,7 @@ class Price extends JsonObject { | |
int? locationId; | ||
|
||
@JsonKey(fromJson: JsonHelper.stringTimestampToDate) | ||
DateTime? created; | ||
late DateTime created; | ||
|
||
Price(); | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import 'package:json_annotation/json_annotation.dart'; | ||
|
||
import '../interface/json_object.dart'; | ||
import '../utils/json_helper.dart'; | ||
|
||
part 'price_product.g.dart'; | ||
|
||
/// Product object in the Prices API. | ||
/// | ||
/// cf. `ProductBase` in https://prices.openfoodfacts.net/docs | ||
@JsonSerializable() | ||
class PriceProduct extends JsonObject { | ||
@JsonKey() | ||
late String code; | ||
|
||
@JsonKey(name: 'id') | ||
late int productId; | ||
|
||
@JsonKey() | ||
String? source; | ||
|
||
@JsonKey(name: 'product_name') | ||
String? name; | ||
|
||
@JsonKey(name: 'product_quantity') | ||
int? quantity; | ||
|
||
@JsonKey(name: 'image_url') | ||
String? imageURL; | ||
|
||
@JsonKey(fromJson: JsonHelper.stringTimestampToDate) | ||
late DateTime created; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same suggestion as before |
||
|
||
@JsonKey(fromJson: JsonHelper.nullableStringTimestampToDate) | ||
DateTime? updated; | ||
|
||
PriceProduct(); | ||
|
||
factory PriceProduct.fromJson(Map<String, dynamic> json) => | ||
_$PriceProductFromJson(json); | ||
|
||
@override | ||
Map<String, dynamic> toJson() => _$PriceProductToJson(this); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you renamed latitude/longitude, I would rename it to
createDate