feat(code_push_protocol): add Collaborator model (#500)
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'collaborator.g.dart';
|
||||
|
||||
/// {@template collaborator}
|
||||
/// A user who has permission to collaborate on an app.
|
||||
/// {@endtemplate}
|
||||
@JsonSerializable()
|
||||
class Collaborator {
|
||||
/// {@macro collaborator}
|
||||
const Collaborator({required this.userId, required this.email});
|
||||
|
||||
/// Converts a Map<String, dynamic> to an [Collaborator]
|
||||
factory Collaborator.fromJson(Map<String, dynamic> json) =>
|
||||
_$CollaboratorFromJson(json);
|
||||
|
||||
/// Converts a [Collaborator] to a Map<String, dynamic>
|
||||
Map<String, dynamic> toJson() => _$CollaboratorToJson(this);
|
||||
|
||||
/// The unique identifier for the user.
|
||||
final int userId;
|
||||
|
||||
/// The email address of the user.
|
||||
final String email;
|
||||
}
|
||||
@@ -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 'collaborator.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
Collaborator _$CollaboratorFromJson(Map<String, dynamic> json) =>
|
||||
$checkedCreate(
|
||||
'Collaborator',
|
||||
json,
|
||||
($checkedConvert) {
|
||||
final val = Collaborator(
|
||||
userId: $checkedConvert('user_id', (v) => v as int),
|
||||
email: $checkedConvert('email', (v) => v as String),
|
||||
);
|
||||
return val;
|
||||
},
|
||||
fieldKeyMap: const {'userId': 'user_id'},
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$CollaboratorToJson(Collaborator instance) =>
|
||||
<String, dynamic>{
|
||||
'user_id': instance.userId,
|
||||
'email': instance.email,
|
||||
};
|
||||
@@ -1,6 +1,7 @@
|
||||
export 'app.dart';
|
||||
export 'app_metadata.dart';
|
||||
export 'channel.dart';
|
||||
export 'collaborator.dart';
|
||||
export 'error_response.dart';
|
||||
export 'patch.dart';
|
||||
export 'patch_artifact.dart';
|
||||
|
||||
@@ -2,7 +2,7 @@ import 'package:shorebird_code_push_protocol/shorebird_code_push_protocol.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
group('AppMetadata', () {
|
||||
group(AppMetadata, () {
|
||||
test('can be (de)serialized', () {
|
||||
const appMetadata = AppMetadata(
|
||||
appId: '30370f27-dbf1-4673-8b20-fb096e38dffa',
|
||||
|
||||
@@ -2,7 +2,7 @@ import 'package:shorebird_code_push_protocol/shorebird_code_push_protocol.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
group('App', () {
|
||||
group(App, () {
|
||||
test('can be (de)serialized', () {
|
||||
const app = App(
|
||||
id: '30370f27-dbf1-4673-8b20-fb096e38dffa',
|
||||
|
||||
@@ -2,7 +2,7 @@ import 'package:shorebird_code_push_protocol/shorebird_code_push_protocol.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
group('Channel', () {
|
||||
group(Channel, () {
|
||||
test('can be (de)serialized', () {
|
||||
const channel = Channel(
|
||||
id: 1,
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import 'package:shorebird_code_push_protocol/shorebird_code_push_protocol.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
group(Collaborator, () {
|
||||
test('can be (de)serialized', () {
|
||||
const collaborator = Collaborator(
|
||||
userId: 1,
|
||||
email: 'jane.doe@shorebird.dev',
|
||||
);
|
||||
expect(
|
||||
Collaborator.fromJson(collaborator.toJson()).toJson(),
|
||||
equals(collaborator.toJson()),
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import 'package:shorebird_code_push_protocol/shorebird_code_push_protocol.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
group('ErrorResponse', () {
|
||||
group(ErrorResponse, () {
|
||||
test('can be (de)serialized', () {
|
||||
const response = ErrorResponse(
|
||||
code: 'code',
|
||||
|
||||
@@ -2,7 +2,7 @@ import 'package:shorebird_code_push_protocol/shorebird_code_push_protocol.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
group('PatchArtifact', () {
|
||||
group(PatchArtifact, () {
|
||||
test('can be (de)serialized', () {
|
||||
const artifact = PatchArtifact(
|
||||
id: 1,
|
||||
|
||||
@@ -2,7 +2,7 @@ import 'package:shorebird_code_push_protocol/shorebird_code_push_protocol.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
group('Patch', () {
|
||||
group(Patch, () {
|
||||
test('can be (de)serialized', () {
|
||||
const patch = Patch(id: 1, number: 2);
|
||||
expect(
|
||||
|
||||
@@ -2,7 +2,7 @@ import 'package:shorebird_code_push_protocol/shorebird_code_push_protocol.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
group('ReleaseArtifact', () {
|
||||
group(ReleaseArtifact, () {
|
||||
test('can be (de)serialized', () {
|
||||
const artifact = ReleaseArtifact(
|
||||
id: 1,
|
||||
|
||||
@@ -2,7 +2,7 @@ import 'package:shorebird_code_push_protocol/shorebird_code_push_protocol.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
group('Release', () {
|
||||
group(Release, () {
|
||||
test('can be (de)serialized', () {
|
||||
const release = Release(
|
||||
id: 1,
|
||||
|
||||
@@ -2,7 +2,7 @@ import 'package:shorebird_code_push_protocol/shorebird_code_push_protocol.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
group('User', () {
|
||||
group(User, () {
|
||||
test('can be (de)serialized', () {
|
||||
const user = User(
|
||||
id: 1,
|
||||
|
||||
Reference in New Issue
Block a user