252 lines
5.2 KiB
Dart
252 lines
5.2 KiB
Dart
import 'package:json_annotation/json_annotation.dart';
|
|
|
|
part 'bean.g.dart';
|
|
|
|
enum RoastLevel {
|
|
@JsonValue('Light')
|
|
light,
|
|
@JsonValue('Medium')
|
|
medium,
|
|
@JsonValue('Medium-Dark')
|
|
mediumDark,
|
|
@JsonValue('Dark')
|
|
dark,
|
|
@JsonValue('Medium-Light')
|
|
mediumLight,
|
|
}
|
|
|
|
enum TastingNotes {
|
|
// Fruity notes
|
|
@JsonValue('Berry')
|
|
berry,
|
|
@JsonValue('Citrus')
|
|
citrus,
|
|
@JsonValue('Stone Fruit')
|
|
stoneFruit,
|
|
@JsonValue('Apple')
|
|
apple,
|
|
@JsonValue('Tropical Fruit')
|
|
tropical,
|
|
@JsonValue('Dried Fruit')
|
|
driedFruit,
|
|
@JsonValue('Cherry')
|
|
cherry,
|
|
@JsonValue('Grape')
|
|
grape,
|
|
@JsonValue('Fruity')
|
|
fruity,
|
|
|
|
// Floral notes
|
|
@JsonValue('Jasmine')
|
|
jasmine,
|
|
@JsonValue('Rose')
|
|
rose,
|
|
@JsonValue('Lavender')
|
|
lavender,
|
|
@JsonValue('Hibiscus')
|
|
hibiscus,
|
|
@JsonValue('Floral')
|
|
floral,
|
|
|
|
// Nutty & sweet
|
|
@JsonValue('Almond')
|
|
almond,
|
|
@JsonValue('Hazelnut')
|
|
hazelnut,
|
|
@JsonValue('Caramel')
|
|
caramel,
|
|
@JsonValue('Honey')
|
|
honey,
|
|
@JsonValue('Vanilla')
|
|
vanilla,
|
|
@JsonValue('Chocolate')
|
|
chocolate,
|
|
@JsonValue('Cocoa')
|
|
cocoa,
|
|
@JsonValue('Brown Sugar')
|
|
brownSugar,
|
|
@JsonValue('Molasses')
|
|
molasses,
|
|
@JsonValue('Maple')
|
|
maple,
|
|
@JsonValue('Nutty')
|
|
nutty,
|
|
|
|
// Earthy, herbal, and savory
|
|
@JsonValue('Tobacco')
|
|
tobacco,
|
|
@JsonValue('Leather')
|
|
leather,
|
|
@JsonValue('Spice')
|
|
spice,
|
|
@JsonValue('Spicy')
|
|
spicy,
|
|
@JsonValue('Clove')
|
|
clove,
|
|
}
|
|
|
|
enum Acidity {
|
|
@JsonValue('High')
|
|
high,
|
|
@JsonValue('Medium-High')
|
|
mediumHigh,
|
|
@JsonValue('Medium')
|
|
medium,
|
|
@JsonValue('Medium-Low')
|
|
mediumLow,
|
|
@JsonValue('Low')
|
|
low,
|
|
}
|
|
|
|
enum Body {
|
|
@JsonValue('Light')
|
|
light,
|
|
@JsonValue('Medium-Light')
|
|
mediumLight,
|
|
@JsonValue('Medium')
|
|
medium,
|
|
@JsonValue('Medium-Full')
|
|
mediumFull,
|
|
@JsonValue('Full')
|
|
full,
|
|
}
|
|
|
|
enum Availability {
|
|
@JsonValue('Available')
|
|
available,
|
|
@JsonValue('Limited')
|
|
limited,
|
|
@JsonValue('Seasonal')
|
|
seasonal,
|
|
@JsonValue('Sold Out')
|
|
soldOut,
|
|
}
|
|
|
|
@JsonSerializable()
|
|
class OriginCountry {
|
|
final String id;
|
|
final String continent;
|
|
final int avgElevation;
|
|
final String details;
|
|
final String? image;
|
|
final String notes;
|
|
final double rating;
|
|
|
|
OriginCountry({
|
|
required this.id,
|
|
required this.continent,
|
|
required this.avgElevation,
|
|
required this.details,
|
|
this.image,
|
|
required this.notes,
|
|
required this.rating,
|
|
});
|
|
|
|
factory OriginCountry.fromJson(Map<String, dynamic> json) =>
|
|
_$OriginCountryFromJson(json);
|
|
Map<String, dynamic> toJson() => _$OriginCountryToJson(this);
|
|
}
|
|
|
|
@JsonSerializable()
|
|
class OriginFarm {
|
|
final String id;
|
|
final String details;
|
|
|
|
OriginFarm({required this.id, required this.details});
|
|
|
|
factory OriginFarm.fromJson(Map<String, dynamic> json) =>
|
|
_$OriginFarmFromJson(json);
|
|
Map<String, dynamic> toJson() => _$OriginFarmToJson(this);
|
|
}
|
|
|
|
@JsonSerializable()
|
|
class Roaster {
|
|
final String id;
|
|
final String name;
|
|
final String location;
|
|
final String details;
|
|
|
|
Roaster({
|
|
required this.id,
|
|
required this.name,
|
|
required this.location,
|
|
required this.details,
|
|
});
|
|
|
|
factory Roaster.fromJson(Map<String, dynamic> json) =>
|
|
_$RoasterFromJson(json);
|
|
Map<String, dynamic> toJson() => _$RoasterToJson(this);
|
|
}
|
|
|
|
@JsonSerializable()
|
|
class Bean {
|
|
final String id;
|
|
final String name;
|
|
final String origin;
|
|
final String farm;
|
|
final String producer;
|
|
final String varietal;
|
|
final int altitude;
|
|
final String processingMethod;
|
|
final String harvestSeason;
|
|
final List<TastingNotes> flavorNotes;
|
|
final Acidity acidity;
|
|
final Body body;
|
|
final int sweetness;
|
|
final RoastLevel roastLevel;
|
|
final double cupScore;
|
|
final double price;
|
|
final Availability availability;
|
|
final List<String> certifications;
|
|
final String roaster;
|
|
@JsonKey(fromJson: _dateTimeFromJson, toJson: _dateTimeToJson)
|
|
final DateTime roastDate;
|
|
@JsonKey(fromJson: _dateTimeFromJson, toJson: _dateTimeToJson)
|
|
final DateTime bestByDate;
|
|
final List<String> brewingMethods;
|
|
final bool isOwned;
|
|
final double quantity;
|
|
final String notes;
|
|
|
|
// Keep these for compatibility with existing code
|
|
bool get preferred => isOwned;
|
|
List<TastingNotes> get tastingNotes => flavorNotes;
|
|
DateTime get roastedDate => roastDate;
|
|
OriginCountry? get originCountry => null; // Will be null for CSV data
|
|
|
|
Bean({
|
|
required this.id,
|
|
required this.name,
|
|
required this.origin,
|
|
required this.farm,
|
|
required this.producer,
|
|
required this.varietal,
|
|
required this.altitude,
|
|
required this.processingMethod,
|
|
required this.harvestSeason,
|
|
required this.flavorNotes,
|
|
required this.acidity,
|
|
required this.body,
|
|
required this.sweetness,
|
|
required this.roastLevel,
|
|
required this.cupScore,
|
|
required this.price,
|
|
required this.availability,
|
|
required this.certifications,
|
|
required this.roaster,
|
|
required this.roastDate,
|
|
required this.bestByDate,
|
|
required this.brewingMethods,
|
|
required this.isOwned,
|
|
required this.quantity,
|
|
required this.notes,
|
|
});
|
|
|
|
factory Bean.fromJson(Map<String, dynamic> json) => _$BeanFromJson(json);
|
|
Map<String, dynamic> toJson() => _$BeanToJson(this);
|
|
|
|
static DateTime _dateTimeFromJson(String json) => DateTime.parse(json);
|
|
static String _dateTimeToJson(DateTime dateTime) =>
|
|
dateTime.toIso8601String();
|
|
}
|