feat(code_push_protocol): add hasActiveSubscription to User (#246)
This commit is contained in:
@@ -8,7 +8,7 @@ part 'user.g.dart';
|
||||
@JsonSerializable()
|
||||
class User {
|
||||
/// {@macro user}
|
||||
const User({required this.id});
|
||||
const User({required this.id, this.hasActiveSubscription = false});
|
||||
|
||||
/// Converts a Map<String, dynamic> to a [User]
|
||||
factory User.fromJson(Map<String, dynamic> json) => _$UserFromJson(json);
|
||||
@@ -18,4 +18,7 @@ class User {
|
||||
|
||||
/// The unique user identifier.
|
||||
final int id;
|
||||
|
||||
/// Whether the user is currently a paying customer.
|
||||
final bool hasActiveSubscription;
|
||||
}
|
||||
|
||||
@@ -14,11 +14,15 @@ User _$UserFromJson(Map<String, dynamic> json) => $checkedCreate(
|
||||
($checkedConvert) {
|
||||
final val = User(
|
||||
id: $checkedConvert('id', (v) => v as int),
|
||||
hasActiveSubscription: $checkedConvert(
|
||||
'has_active_subscription', (v) => v as bool? ?? false),
|
||||
);
|
||||
return val;
|
||||
},
|
||||
fieldKeyMap: const {'hasActiveSubscription': 'has_active_subscription'},
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$UserToJson(User instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'has_active_subscription': instance.hasActiveSubscription,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user