diff --git a/packages/shorebird_code_push_protocol/lib/src/models/user.dart b/packages/shorebird_code_push_protocol/lib/src/models/user.dart index 7b81ee954..bd3afa807 100644 --- a/packages/shorebird_code_push_protocol/lib/src/models/user.dart +++ b/packages/shorebird_code_push_protocol/lib/src/models/user.dart @@ -8,7 +8,11 @@ part 'user.g.dart'; @JsonSerializable() class User { /// {@macro user} - const User({required this.id, this.hasActiveSubscription = false}); + const User({ + required this.id, + required this.email, + this.hasActiveSubscription = false, + }); /// Converts a Map to a [User] factory User.fromJson(Map json) => _$UserFromJson(json); @@ -19,6 +23,9 @@ class User { /// The unique user identifier. final int id; + /// The user's email address, as provided by the user during signup. + final String email; + /// Whether the user is currently a paying customer. final bool hasActiveSubscription; } diff --git a/packages/shorebird_code_push_protocol/lib/src/models/user.g.dart b/packages/shorebird_code_push_protocol/lib/src/models/user.g.dart index c33baa78f..c997396a5 100644 --- a/packages/shorebird_code_push_protocol/lib/src/models/user.g.dart +++ b/packages/shorebird_code_push_protocol/lib/src/models/user.g.dart @@ -14,6 +14,7 @@ User _$UserFromJson(Map json) => $checkedCreate( ($checkedConvert) { final val = User( id: $checkedConvert('id', (v) => v as int), + email: $checkedConvert('email', (v) => v as String), hasActiveSubscription: $checkedConvert( 'has_active_subscription', (v) => v as bool? ?? false), ); @@ -24,5 +25,6 @@ User _$UserFromJson(Map json) => $checkedCreate( Map _$UserToJson(User instance) => { 'id': instance.id, + 'email': instance.email, 'has_active_subscription': instance.hasActiveSubscription, }; diff --git a/packages/shorebird_code_push_protocol/test/src/models/user_test.dart b/packages/shorebird_code_push_protocol/test/src/models/user_test.dart index a0f2653ce..67d8e04f0 100644 --- a/packages/shorebird_code_push_protocol/test/src/models/user_test.dart +++ b/packages/shorebird_code_push_protocol/test/src/models/user_test.dart @@ -4,7 +4,7 @@ import 'package:test/test.dart'; void main() { group('User', () { test('can be (de)serialized', () { - const user = User(id: 1); + const user = User(id: 1, email: 'test@shorebird.dev'); expect( User.fromJson(user.toJson()).toJson(), equals(user.toJson()),