feat(code_push_protocol): add availableRoles to ShorebirdPlan (#3423)
This commit is contained in:
@@ -22,6 +22,7 @@ class Plan {
|
||||
required this.cancelAtPeriodEnd,
|
||||
required this.isTiered,
|
||||
required this.isTrial,
|
||||
required this.availableRoles,
|
||||
this.pricePerOverageInstall,
|
||||
this.maxTeamSize,
|
||||
});
|
||||
@@ -74,4 +75,7 @@ class Plan {
|
||||
/// The maximum number of collaborators allowed per account. This will be null
|
||||
/// for accounts with unlimited collaborators.
|
||||
final int? maxTeamSize;
|
||||
|
||||
/// Roles assignable to users associated with this plan.
|
||||
final List<Role> availableRoles;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,12 @@ Plan _$PlanFromJson(Map<String, dynamic> json) => $checkedCreate(
|
||||
),
|
||||
isTiered: $checkedConvert('is_tiered', (v) => v as bool),
|
||||
isTrial: $checkedConvert('is_trial', (v) => v as bool),
|
||||
availableRoles: $checkedConvert(
|
||||
'available_roles',
|
||||
(v) => (v as List<dynamic>)
|
||||
.map((e) => $enumDecode(_$RoleEnumMap, e))
|
||||
.toList(),
|
||||
),
|
||||
pricePerOverageInstall: $checkedConvert(
|
||||
'price_per_overage_install',
|
||||
(v) => v == null ? null : Decimal.fromJson(v as String),
|
||||
@@ -53,6 +59,7 @@ Plan _$PlanFromJson(Map<String, dynamic> json) => $checkedCreate(
|
||||
'cancelAtPeriodEnd': 'cancel_at_period_end',
|
||||
'isTiered': 'is_tiered',
|
||||
'isTrial': 'is_trial',
|
||||
'availableRoles': 'available_roles',
|
||||
'pricePerOverageInstall': 'price_per_overage_install',
|
||||
'maxTeamSize': 'max_team_size',
|
||||
},
|
||||
@@ -70,4 +77,14 @@ Map<String, dynamic> _$PlanToJson(Plan instance) => <String, dynamic>{
|
||||
'is_tiered': instance.isTiered,
|
||||
'is_trial': instance.isTrial,
|
||||
'max_team_size': instance.maxTeamSize,
|
||||
'available_roles': instance.availableRoles
|
||||
.map((e) => _$RoleEnumMap[e]!)
|
||||
.toList(),
|
||||
};
|
||||
|
||||
const _$RoleEnumMap = {
|
||||
Role.owner: 'owner',
|
||||
Role.admin: 'admin',
|
||||
Role.developer: 'developer',
|
||||
Role.none: 'none',
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:decimal/decimal.dart';
|
||||
import 'package:shorebird_code_push_protocol/src/models/plan.dart';
|
||||
import 'package:shorebird_code_push_protocol/shorebird_code_push_protocol.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
@@ -17,6 +17,7 @@ void main() {
|
||||
maxTeamSize: 42,
|
||||
pricePerOverageInstall: Decimal.fromInt(10),
|
||||
isTrial: true,
|
||||
availableRoles: [Role.admin, Role.developer],
|
||||
);
|
||||
|
||||
expect(Plan.fromJson(plan.toJson()).toJson(), equals(plan.toJson()));
|
||||
|
||||
Reference in New Issue
Block a user