feat(code_push_protocol): add CreateAppCollaboratorRequest (#491)

This commit is contained in:
Felix Angelov
2023-05-15 08:29:44 -07:00
committed by GitHub
parent db51a4e5f7
commit c31c0300ca
5 changed files with 67 additions and 0 deletions
@@ -0,0 +1 @@
export 'create_app_collaborator_request.dart';
@@ -0,0 +1,22 @@
import 'package:json_annotation/json_annotation.dart';
part 'create_app_collaborator_request.g.dart';
/// {@template create_app_collaborator_request}
/// The request body for POST /api/v1/apps/<id>/collaborators
/// {@endtemplate}
@JsonSerializable()
class CreateAppCollaboratorRequest {
/// {@macro create_app_collaborator_request}
const CreateAppCollaboratorRequest({required this.userId});
/// Converts a Map<String, dynamic> to a [CreateAppCollaboratorRequest]
factory CreateAppCollaboratorRequest.fromJson(Map<String, dynamic> json) =>
_$CreateAppCollaboratorRequestFromJson(json);
/// Converts a [CreateAppCollaboratorRequest] to a Map<String, dynamic>
Map<String, dynamic> toJson() => _$CreateAppCollaboratorRequestToJson(this);
/// The unique identifier of the collaborator to add.
final int userId;
}
@@ -0,0 +1,29 @@
// 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 'create_app_collaborator_request.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
CreateAppCollaboratorRequest _$CreateAppCollaboratorRequestFromJson(
Map<String, dynamic> json) =>
$checkedCreate(
'CreateAppCollaboratorRequest',
json,
($checkedConvert) {
final val = CreateAppCollaboratorRequest(
userId: $checkedConvert('user_id', (v) => v as int),
);
return val;
},
fieldKeyMap: const {'userId': 'user_id'},
);
Map<String, dynamic> _$CreateAppCollaboratorRequestToJson(
CreateAppCollaboratorRequest instance) =>
<String, dynamic>{
'user_id': instance.userId,
};
@@ -1,6 +1,7 @@
export 'cancel_subscription/cancel_subscription_response.dart';
export 'check_for_patches/check_for_patches.dart';
export 'create_app/create_app.dart';
export 'create_app_collaborator/create_app_collaborator.dart';
export 'create_artifact/create_artifact.dart';
export 'create_channel/create_channel.dart';
export 'create_patch/create_patch.dart';
@@ -0,0 +1,14 @@
import 'package:shorebird_code_push_protocol/shorebird_code_push_protocol.dart';
import 'package:test/test.dart';
void main() {
group(CreateAppCollaboratorRequest, () {
test('can be (de)serialized', () {
const request = CreateAppCollaboratorRequest(userId: 42);
expect(
CreateAppCollaboratorRequest.fromJson(request.toJson()).toJson(),
equals(request.toJson()),
);
});
});
}