chore(code_push_protocol): remove CheckForPatchesRequest and CheckForPatchesResponse (#1348)

This commit is contained in:
Felix Angelov
2023-10-03 12:09:16 -05:00
committed by GitHub
parent 6845de7fcd
commit 01ef592178
8 changed files with 0 additions and 230 deletions
@@ -1,2 +0,0 @@
export 'check_for_patches_request.dart';
export 'check_for_patches_response.dart';
@@ -1,49 +0,0 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:shorebird_code_push_protocol/shorebird_code_push_protocol.dart';
part 'check_for_patches_request.g.dart';
/// {@template check_for_patches_request}
/// The request body for POST /api/v1/patches/check
/// {@endtemplate}
@JsonSerializable()
class CheckForPatchesRequest {
/// {@macro check_for_patches_request}
const CheckForPatchesRequest({
required this.releaseVersion,
required this.patchNumber,
required this.patchHash,
required this.platform,
required this.arch,
required this.appId,
required this.channel,
});
/// Converts a Map<String, dynamic> to a [CheckForPatchesRequest]
factory CheckForPatchesRequest.fromJson(Map<String, dynamic> json) =>
_$CheckForPatchesRequestFromJson(json);
/// Converts a [CheckForPatchesRequest] to a Map<String, dynamic>
Map<String, dynamic> toJson() => _$CheckForPatchesRequestToJson(this);
/// The release version of the app.
final String releaseVersion;
/// The current patch number of the app.
final int? patchNumber;
/// The current patch hash of the app.
final String? patchHash;
/// The platform of the app.
final ReleasePlatform platform;
/// The architecture of the app.
final String arch;
/// The ID of the app.
final String appId;
/// The channel of the app.
final String channel;
}
@@ -1,53 +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 'check_for_patches_request.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
CheckForPatchesRequest _$CheckForPatchesRequestFromJson(
Map<String, dynamic> json) =>
$checkedCreate(
'CheckForPatchesRequest',
json,
($checkedConvert) {
final val = CheckForPatchesRequest(
releaseVersion:
$checkedConvert('release_version', (v) => v as String),
patchNumber: $checkedConvert('patch_number', (v) => v as int?),
patchHash: $checkedConvert('patch_hash', (v) => v as String?),
platform: $checkedConvert(
'platform', (v) => $enumDecode(_$ReleasePlatformEnumMap, v)),
arch: $checkedConvert('arch', (v) => v as String),
appId: $checkedConvert('app_id', (v) => v as String),
channel: $checkedConvert('channel', (v) => v as String),
);
return val;
},
fieldKeyMap: const {
'releaseVersion': 'release_version',
'patchNumber': 'patch_number',
'patchHash': 'patch_hash',
'appId': 'app_id'
},
);
Map<String, dynamic> _$CheckForPatchesRequestToJson(
CheckForPatchesRequest instance) =>
<String, dynamic>{
'release_version': instance.releaseVersion,
'patch_number': instance.patchNumber,
'patch_hash': instance.patchHash,
'platform': _$ReleasePlatformEnumMap[instance.platform]!,
'arch': instance.arch,
'app_id': instance.appId,
'channel': instance.channel,
};
const _$ReleasePlatformEnumMap = {
ReleasePlatform.android: 'android',
ReleasePlatform.ios: 'ios',
};
@@ -1,47 +0,0 @@
import 'package:json_annotation/json_annotation.dart';
part 'check_for_patches_response.g.dart';
/// {@template check_for_patches_response}
/// The response body for POST /api/v1/patches/check
/// {@endtemplate}
@JsonSerializable(createFactory: false)
class CheckForPatchesResponse {
/// {@macro check_for_patches_response}
const CheckForPatchesResponse({required this.patchAvailable, this.patch});
/// Converts a [CheckForPatchesResponse] to a Map<String, dynamic>
Map<String, dynamic> toJson() => _$CheckForPatchesResponseToJson(this);
/// Whether a patch is available.
final bool patchAvailable;
/// The patch metadata.
final PatchMetadata? patch;
}
/// {@template patch_metadata}
/// Patch metadata represents the contents of an update (patch) for a specific
/// platform and architecture.
/// {@endtemplate}
@JsonSerializable(createFactory: false)
class PatchMetadata {
/// {@macro patch_metadata}
const PatchMetadata({
required this.number,
required this.downloadUrl,
required this.hash,
});
/// Converts an [PatchMetadata] to a Map<String, dynamic>
Map<String, dynamic> toJson() => _$PatchMetadataToJson(this);
/// The patch number associated with the artifact.
final int number;
/// The URL of the artifact.
final String downloadUrl;
/// The hash of the artifact.
final String hash;
}
@@ -1,23 +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 'check_for_patches_response.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
Map<String, dynamic> _$CheckForPatchesResponseToJson(
CheckForPatchesResponse instance) =>
<String, dynamic>{
'patch_available': instance.patchAvailable,
'patch': instance.patch?.toJson(),
};
Map<String, dynamic> _$PatchMetadataToJson(PatchMetadata instance) =>
<String, dynamic>{
'number': instance.number,
'download_url': instance.downloadUrl,
'hash': instance.hash,
};
@@ -1,4 +1,3 @@
export 'check_for_patches/check_for_patches.dart';
export 'create_app/create_app.dart';
export 'create_app_collaborator/create_app_collaborator.dart';
export 'create_channel/create_channel.dart';
@@ -1,22 +0,0 @@
import 'package:shorebird_code_push_protocol/shorebird_code_push_protocol.dart';
import 'package:test/test.dart';
void main() {
group(CheckForPatchesRequest, () {
test('can be (de)serialized', () {
const request = CheckForPatchesRequest(
releaseVersion: '1',
patchNumber: 2,
patchHash: '3',
platform: ReleasePlatform.android,
arch: 'arm64',
appId: 'app_123',
channel: 'channel_123',
);
expect(
CheckForPatchesRequest.fromJson(request.toJson()).toJson(),
equals(request.toJson()),
);
});
});
}
@@ -1,33 +0,0 @@
import 'package:shorebird_code_push_protocol/shorebird_code_push_protocol.dart';
import 'package:test/test.dart';
void main() {
group(CheckForPatchesRequest, () {
test('can be serialized to json without patch metadata', () {
const response = CheckForPatchesResponse(patchAvailable: true);
expect(response.toJson(), {'patch_available': true, 'patch': null});
});
test('can be serialized to json with patch metadata', () {
const response = CheckForPatchesResponse(
patchAvailable: true,
patch: PatchMetadata(
number: 1,
downloadUrl: 'https://download.com',
hash: '1234',
),
);
expect(
response.toJson(),
{
'patch_available': true,
'patch': {
'number': 1,
'download_url': 'https://download.com',
'hash': '1234',
},
},
);
});
});
}