feat(code_push_protocol): add cancelAtPeriodEnd to GetUsageResponse (#1259)

This commit is contained in:
Felix Angelov
2023-09-12 20:32:29 +02:00
committed by GitHub
parent 18b414d2be
commit c826819f76
7 changed files with 14 additions and 52 deletions
@@ -1,2 +1,2 @@
// Generated code. Do not modify.
const packageVersion = '0.5.0+1';
const packageVersion = '0.6.0+1';
@@ -1,6 +1,6 @@
name: shorebird_code_push_client
description: Library which allows Dart applications to interact with the ShoreBird CodePush API
version: 0.5.0+1
version: 0.6.0+1
repository: https://github.com/shorebirdtech/shorebird
publish_to: none
@@ -2054,6 +2054,7 @@ void main() {
currentPeriodCost: Money.fromIntWithCurrency(0, usd),
currentPeriodStart: DateTime(2023),
currentPeriodEnd: DateTime(2023, 2),
cancelAtPeriodEnd: false,
);
when(() => httpClient.send(any())).thenAnswer(
@@ -15,6 +15,7 @@ class GetUsageResponse {
required this.currentPeriodStart,
required this.currentPeriodEnd,
required this.currentPeriodCost,
required this.cancelAtPeriodEnd,
});
/// Converts a Map<String, dynamic> to a [GetUsageResponse].
@@ -40,6 +41,10 @@ class GetUsageResponse {
/// monthly cost and any overages.
@MoneyConverter()
final Money currentPeriodCost;
/// Whether the subscription will be canceled
/// at the end of the current billing period.
final bool cancelAtPeriodEnd;
}
/// {@template app_usage}
@@ -27,13 +27,16 @@ GetUsageResponse _$GetUsageResponseFromJson(Map<String, dynamic> json) =>
'current_period_end', (v) => DateTime.parse(v as String)),
currentPeriodCost: $checkedConvert('current_period_cost',
(v) => const MoneyConverter().fromJson(v as int)),
cancelAtPeriodEnd:
$checkedConvert('cancel_at_period_end', (v) => v as bool),
);
return val;
},
fieldKeyMap: const {
'currentPeriodStart': 'current_period_start',
'currentPeriodEnd': 'current_period_end',
'currentPeriodCost': 'current_period_cost'
'currentPeriodCost': 'current_period_cost',
'cancelAtPeriodEnd': 'cancel_at_period_end'
},
);
@@ -45,6 +48,7 @@ Map<String, dynamic> _$GetUsageResponseToJson(GetUsageResponse instance) =>
'current_period_end': instance.currentPeriodEnd.toIso8601String(),
'current_period_cost':
const MoneyConverter().toJson(instance.currentPeriodCost),
'cancel_at_period_end': instance.cancelAtPeriodEnd,
};
AppUsage _$AppUsageFromJson(Map<String, dynamic> json) => $checkedCreate(
@@ -1,49 +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 'patch_install_event.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
PatchInstallEvent _$PatchInstallEventFromJson(Map<String, dynamic> json) =>
$checkedCreate(
'PatchInstallEvent',
json,
($checkedConvert) {
final val = PatchInstallEvent(
clientId: $checkedConvert('client_id', (v) => v as String),
appId: $checkedConvert('app_id', (v) => v as String),
releaseVersion:
$checkedConvert('release_version', (v) => v as String),
patchNumber: $checkedConvert('patch_number', (v) => v as int),
platform: $checkedConvert(
'platform', (v) => $enumDecode(_$ReleasePlatformEnumMap, v)),
arch: $checkedConvert('arch', (v) => v as String),
);
return val;
},
fieldKeyMap: const {
'clientId': 'client_id',
'appId': 'app_id',
'releaseVersion': 'release_version',
'patchNumber': 'patch_number'
},
);
Map<String, dynamic> _$PatchInstallEventToJson(PatchInstallEvent instance) =>
<String, dynamic>{
'client_id': instance.clientId,
'app_id': instance.appId,
'release_version': instance.releaseVersion,
'patch_number': instance.patchNumber,
'platform': _$ReleasePlatformEnumMap[instance.platform]!,
'arch': instance.arch,
};
const _$ReleasePlatformEnumMap = {
ReleasePlatform.android: 'android',
ReleasePlatform.ios: 'ios',
};
@@ -18,6 +18,7 @@ void main() {
currentPeriodCost: Money.fromIntWithCurrency(0, usd),
currentPeriodStart: DateTime(2021),
currentPeriodEnd: DateTime(2021, 1, 2),
cancelAtPeriodEnd: false,
);
expect(
GetUsageResponse.fromJson(response.toJson()).toJson(),