Skip to content

Commit

Permalink
feat(shorebird_code_push_protocol): Add email field to User (#276)
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanoltman authored Apr 12, 2023
1 parent 34cfb4b commit 28a925d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, dynamic> to a [User]
factory User.fromJson(Map<String, dynamic> json) => _$UserFromJson(json);
Expand All @@ -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;
}

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
Expand Up @@ -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: '[email protected]');
expect(
User.fromJson(user.toJson()).toJson(),
equals(user.toJson()),
Expand Down

0 comments on commit 28a925d

Please sign in to comment.