diff --git a/packages/shorebird_code_push_protocol/lib/src/models/models.dart b/packages/shorebird_code_push_protocol/lib/src/models/models.dart index 016b5479..46a6db5f 100644 --- a/packages/shorebird_code_push_protocol/lib/src/models/models.dart +++ b/packages/shorebird_code_push_protocol/lib/src/models/models.dart @@ -9,7 +9,6 @@ export 'organization_membership.dart'; export 'organization_user.dart'; export 'patch.dart'; export 'patch_artifact.dart'; -export 'plan.dart'; export 'private_user.dart'; export 'public_user.dart'; export 'release.dart'; diff --git a/packages/shorebird_code_push_protocol/lib/src/models/plan.dart b/packages/shorebird_code_push_protocol/lib/src/models/plan.dart deleted file mode 100644 index de0ed5e8..00000000 --- a/packages/shorebird_code_push_protocol/lib/src/models/plan.dart +++ /dev/null @@ -1,86 +0,0 @@ -import 'package:decimal/decimal.dart'; -import 'package:json_annotation/json_annotation.dart'; -import 'package:shorebird_code_push_protocol/shorebird_code_push_protocol.dart'; - -part 'plan.g.dart'; - -/// {@template plan} -/// A plan represents a user's subscription to the Code Push product. It -/// includes details about the plan, such as the name, price, and billing -/// period. -/// {@endtemplate} -@JsonSerializable() -class Plan { - /// {@macro plan} - Plan({ - required this.name, - required this.currency, - required this.basePrice, - required this.baseInstallCount, - required this.currentPeriodStart, - required this.currentPeriodEnd, - required this.cancelAtPeriodEnd, - required this.isTiered, - required this.isTrial, - required this.availableRoles, - required this.mauInsightEnabled, - this.pricePerOverageInstall, - this.maxTeamSize, - }); - - /// Deserialize a [Plan] from [json]. - static Plan fromJson(Map json) => _$PlanFromJson(json); - - /// Serialize the [Plan] to [Json]. - Json toJson() => _$PlanToJson(this); - - /// The display name of the plan - final String name; - - /// The ISO 4217 currency code for the plan. - final String currency; - - /// The price paid per billing period, irrespective of the number of patch - /// installs used. This number is in minor units of [currency] - /// (e.g., cents for USD). - final int basePrice; - - /// The number of patch installs included with the base price. - final int baseInstallCount; - - /// The price per patch install over [baseInstallCount]. This is in minor - /// units of [currency] (e.g., cents for USD) and may be a fractional value. - /// Will be null if the user's plan does not support overage billing. - final Decimal? pricePerOverageInstall; - - /// The start of the current billing period. - /// If the user is on a free plan, this will be the start of the current - /// month. - final DateTime currentPeriodStart; - - /// The end of the current billing period. - /// If the user is on a free plan, this will be the start of the next month. - final DateTime currentPeriodEnd; - - /// Whether the subscription will be canceled at the end of the current - /// billing period. - final bool cancelAtPeriodEnd; - - /// Whether the plan is tier (i.e., whether the user can change their plan). - final bool isTiered; - - /// Whether the user is on a trial plan. Trial plans are not billed and cancel - /// automatically at the end of the trial period. - final bool isTrial; - - /// Whether or not MAU insights are supported for the plan. - final bool mauInsightEnabled; - - /// 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, mapped to the - /// permissions they have. - final Map> availableRoles; -} diff --git a/packages/shorebird_code_push_protocol/lib/src/models/plan.g.dart b/packages/shorebird_code_push_protocol/lib/src/models/plan.g.dart deleted file mode 100644 index e1a7585f..00000000 --- a/packages/shorebird_code_push_protocol/lib/src/models/plan.g.dart +++ /dev/null @@ -1,101 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -// ignore_for_file: implicit_dynamic_parameter, require_trailing_commas, cast_nullable_to_non_nullable, lines_longer_than_80_chars - -part of 'plan.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -Plan _$PlanFromJson(Map json) => $checkedCreate( - 'Plan', - json, - ($checkedConvert) { - final val = Plan( - name: $checkedConvert('name', (v) => v as String), - currency: $checkedConvert('currency', (v) => v as String), - basePrice: $checkedConvert('base_price', (v) => (v as num).toInt()), - baseInstallCount: $checkedConvert( - 'base_install_count', - (v) => (v as num).toInt(), - ), - currentPeriodStart: $checkedConvert( - 'current_period_start', - (v) => DateTime.parse(v as String), - ), - currentPeriodEnd: $checkedConvert( - 'current_period_end', - (v) => DateTime.parse(v as String), - ), - cancelAtPeriodEnd: $checkedConvert( - 'cancel_at_period_end', - (v) => v as bool, - ), - isTiered: $checkedConvert('is_tiered', (v) => v as bool), - isTrial: $checkedConvert('is_trial', (v) => v as bool), - availableRoles: $checkedConvert( - 'available_roles', - (v) => (v as Map).map( - (k, e) => MapEntry( - $enumDecode(_$RoleEnumMap, k), - (e as List).map((e) => e as String).toList(), - ), - ), - ), - mauInsightEnabled: $checkedConvert( - 'mau_insight_enabled', - (v) => v as bool, - ), - pricePerOverageInstall: $checkedConvert( - 'price_per_overage_install', - (v) => v == null ? null : Decimal.fromJson(v as String), - ), - maxTeamSize: $checkedConvert( - 'max_team_size', - (v) => (v as num?)?.toInt(), - ), - ); - return val; - }, - fieldKeyMap: const { - 'basePrice': 'base_price', - 'baseInstallCount': 'base_install_count', - 'currentPeriodStart': 'current_period_start', - 'currentPeriodEnd': 'current_period_end', - 'cancelAtPeriodEnd': 'cancel_at_period_end', - 'isTiered': 'is_tiered', - 'isTrial': 'is_trial', - 'availableRoles': 'available_roles', - 'mauInsightEnabled': 'mau_insight_enabled', - 'pricePerOverageInstall': 'price_per_overage_install', - 'maxTeamSize': 'max_team_size', - }, -); - -Map _$PlanToJson(Plan instance) => { - 'name': instance.name, - 'currency': instance.currency, - 'base_price': instance.basePrice, - 'base_install_count': instance.baseInstallCount, - 'price_per_overage_install': instance.pricePerOverageInstall?.toJson(), - 'current_period_start': instance.currentPeriodStart.toIso8601String(), - 'current_period_end': instance.currentPeriodEnd.toIso8601String(), - 'cancel_at_period_end': instance.cancelAtPeriodEnd, - 'is_tiered': instance.isTiered, - 'is_trial': instance.isTrial, - 'mau_insight_enabled': instance.mauInsightEnabled, - 'max_team_size': instance.maxTeamSize, - 'available_roles': instance.availableRoles.map( - (k, e) => MapEntry(_$RoleEnumMap[k]!, e), - ), -}; - -const _$RoleEnumMap = { - Role.owner: 'owner', - Role.admin: 'admin', - Role.appManager: 'appManager', - Role.developer: 'developer', - Role.viewer: 'viewer', - Role.none: 'none', -}; diff --git a/packages/shorebird_code_push_protocol/test/src/models/plan_test.dart b/packages/shorebird_code_push_protocol/test/src/models/plan_test.dart deleted file mode 100644 index c4f0af9e..00000000 --- a/packages/shorebird_code_push_protocol/test/src/models/plan_test.dart +++ /dev/null @@ -1,49 +0,0 @@ -import 'package:decimal/decimal.dart'; -import 'package:shorebird_code_push_protocol/shorebird_code_push_protocol.dart'; -import 'package:test/test.dart'; - -void main() { - group(Plan, () { - test('can be (de)serialized', () { - final plan = Plan( - name: 'name', - currency: 'currency', - basePrice: 42, - baseInstallCount: 42, - currentPeriodStart: DateTime.now(), - currentPeriodEnd: DateTime.now(), - cancelAtPeriodEnd: true, - isTiered: true, - maxTeamSize: 42, - pricePerOverageInstall: Decimal.fromInt(10), - isTrial: true, - mauInsightEnabled: true, - availableRoles: { - Role.admin: [ - 'apps.view', - 'releases.view', - 'patches.view', - 'channels.view', - 'organizations.view', - 'organizationApps.view', - 'organizationMembers.view', - 'appRoleGrants.view', - 'insights.view', - 'plans.view', - ], - Role.developer: [ - 'apps.view', - 'releases.view', - 'patches.view', - 'channels.view', - 'organizations.view', - 'organizationApps.view', - 'organizationMembers.view', - ], - }, - ); - - expect(Plan.fromJson(plan.toJson()).toJson(), equals(plan.toJson())); - }); - }); -}