diff --git a/packages/shorebird_code_push_client/lib/src/code_push_client.dart b/packages/shorebird_code_push_client/lib/src/code_push_client.dart index a0a49498f..2bbb664f8 100644 --- a/packages/shorebird_code_push_client/lib/src/code_push_client.dart +++ b/packages/shorebird_code_push_client/lib/src/code_push_client.dart @@ -46,11 +46,11 @@ class CodePushClient { /// Collaborators can manage the app including its releases and patches. Future createAppCollaborator({ required String appId, - required int userId, + required String email, }) async { final response = await _httpClient.post( Uri.parse('$_v1/apps/$appId/collaborators'), - body: json.encode(CreateAppCollaboratorRequest(userId: userId).toJson()), + body: json.encode(CreateAppCollaboratorRequest(email: email).toJson()), ); if (response.statusCode != HttpStatus.created) { diff --git a/packages/shorebird_code_push_client/test/src/code_push_client_test.dart b/packages/shorebird_code_push_client/test/src/code_push_client_test.dart index 0369f9153..3a92f0b6e 100644 --- a/packages/shorebird_code_push_client/test/src/code_push_client_test.dart +++ b/packages/shorebird_code_push_client/test/src/code_push_client_test.dart @@ -55,7 +55,7 @@ void main() { group('createAppCollaborator', () { const appId = 'test-app-id'; - const userId = 42; + const email = 'jane.doe@shorebird.dev'; test('throws an exception if the http request fails (unknown)', () async { when( @@ -69,7 +69,7 @@ void main() { ); expect( - codePushClient.createAppCollaborator(appId: appId, userId: userId), + codePushClient.createAppCollaborator(appId: appId, email: email), throwsA( isA().having( (e) => e.message, @@ -95,7 +95,7 @@ void main() { ); expect( - codePushClient.createAppCollaborator(appId: appId, userId: userId), + codePushClient.createAppCollaborator(appId: appId, email: email), throwsA( isA().having( (e) => e.message, @@ -115,10 +115,7 @@ void main() { ), ).thenAnswer((_) async => http.Response('', HttpStatus.created)); - await codePushClient.createAppCollaborator( - appId: appId, - userId: userId, - ); + await codePushClient.createAppCollaborator(appId: appId, email: email); final uri = verify( () => httpClient.post( diff --git a/packages/shorebird_code_push_protocol/lib/src/messages/create_app_collaborator/create_app_collaborator_request.dart b/packages/shorebird_code_push_protocol/lib/src/messages/create_app_collaborator/create_app_collaborator_request.dart index 065fcfa44..adc67ae49 100644 --- a/packages/shorebird_code_push_protocol/lib/src/messages/create_app_collaborator/create_app_collaborator_request.dart +++ b/packages/shorebird_code_push_protocol/lib/src/messages/create_app_collaborator/create_app_collaborator_request.dart @@ -8,7 +8,7 @@ part 'create_app_collaborator_request.g.dart'; @JsonSerializable() class CreateAppCollaboratorRequest { /// {@macro create_app_collaborator_request} - const CreateAppCollaboratorRequest({required this.userId}); + const CreateAppCollaboratorRequest({required this.email}); /// Converts a Map to a [CreateAppCollaboratorRequest] factory CreateAppCollaboratorRequest.fromJson(Map json) => @@ -17,6 +17,6 @@ class CreateAppCollaboratorRequest { /// Converts a [CreateAppCollaboratorRequest] to a Map Map toJson() => _$CreateAppCollaboratorRequestToJson(this); - /// The unique identifier of the collaborator to add. - final int userId; + /// The email of the collaborator to add. + final String email; } diff --git a/packages/shorebird_code_push_protocol/lib/src/messages/create_app_collaborator/create_app_collaborator_request.g.dart b/packages/shorebird_code_push_protocol/lib/src/messages/create_app_collaborator/create_app_collaborator_request.g.dart index e060cb950..e8d828322 100644 --- a/packages/shorebird_code_push_protocol/lib/src/messages/create_app_collaborator/create_app_collaborator_request.g.dart +++ b/packages/shorebird_code_push_protocol/lib/src/messages/create_app_collaborator/create_app_collaborator_request.g.dart @@ -15,15 +15,14 @@ CreateAppCollaboratorRequest _$CreateAppCollaboratorRequestFromJson( json, ($checkedConvert) { final val = CreateAppCollaboratorRequest( - userId: $checkedConvert('user_id', (v) => v as int), + email: $checkedConvert('email', (v) => v as String), ); return val; }, - fieldKeyMap: const {'userId': 'user_id'}, ); Map _$CreateAppCollaboratorRequestToJson( CreateAppCollaboratorRequest instance) => { - 'user_id': instance.userId, + 'email': instance.email, }; diff --git a/packages/shorebird_code_push_protocol/test/src/messages/create_app_collaborator/create_app_collaborator_request_test.dart b/packages/shorebird_code_push_protocol/test/src/messages/create_app_collaborator/create_app_collaborator_request_test.dart index d3a985699..269aa9937 100644 --- a/packages/shorebird_code_push_protocol/test/src/messages/create_app_collaborator/create_app_collaborator_request_test.dart +++ b/packages/shorebird_code_push_protocol/test/src/messages/create_app_collaborator/create_app_collaborator_request_test.dart @@ -4,7 +4,9 @@ import 'package:test/test.dart'; void main() { group(CreateAppCollaboratorRequest, () { test('can be (de)serialized', () { - const request = CreateAppCollaboratorRequest(userId: 42); + const request = CreateAppCollaboratorRequest( + email: 'jane.doe@shorebird.dev', + ); expect( CreateAppCollaboratorRequest.fromJson(request.toJson()).toJson(), equals(request.toJson()),