Description
Each Team in TaaS API is the same as Project in Projects API. In Projects API we already have the ability to invite members. So when users are invited they have to accept invites to become members.
In TaaS App we would like to skip the invitation process and be able to add members directly without invitation. Projects API already has an endpoint POST /projects/{projectId}/members
to add members directly but it has several restrictions that don't allow us directly use it:
- it only allows adding members for Topcoder Admins or M2M token
- it only supports adding members by
handle
- it only supports adding one member at a time
We have to create an endpoint POST /taas-teams/:teamId/members
in TaaS API which would allow us to add members to the team:
- it should allow adding members to the Team to any user who has access to the Team
- it should support adding members by
handle
and byemail
- it should support adding multiple members at a time
- unlike Projects API endpoint, this endpoint should always add members with
role=customer
- so role cannot be chosen in the request
For the implementation, we can check how POST /projects/{projectId}/invites
is implemented in Projects API it supports most of these requirements, but for invites.
Suggested body request for POST /taas-teams/:teamId/members
is same like for invites in Projects API
[
handles: { "user_hanlde", "user_hanlde_2" }, // invite multiple handles
emails: { "user_email@test.com", "user_email_4@test.com" }, // invite multiple emails
]
The response can be an object of the next shape same like we do for invites in Projects API. It would return which handles/emails were invited successfully and which failed:
{
success: [ // this list should containt member objects created
{
id: 123123,
handle: "user_hanlde"
// ... other fields of created member object
},
{
id: 234235,
email: "user_email@test.com",
// ... other fields of created member object
}
],
failed: [
{
handle: "user_hanlde_2",
error: "User doesn't exist",
},
{
email: "user_email_4@test.com"
error: "User doesn't exist",
},
]
}
-
NOTE: Projects API
POST /projects/{projectId}/members
endpoint doesn't always returnemail
andhandle
when creating members. So you would have to add this into the response manually, to match requested members with created ones. For example,email
,firstName
andlastName
are only returned to admin users. While endpoint in TaaS Api should work for any user (who has access to the team). -
Please, keep error messages without mentioning the user handle/email. This would help us to group errors in UI, so we could show an error in UI like this:
user_hanlde_2, user_email_4@test.com: User doesn't exist
. -
When calling
POST /projects/{projectId}/members
also pass?fields=id,userId,role,createdAt,updatedAt,createdBy,updatedBy,handle,photoURL,workingHourStart,workingHourEnd,timeZone,email
so we would get additional details about the created member. We would need them for TaaS API UI: https://marvelapp.com/prototype/921gg0f/screen/75360461/handoff -
NOTE: When inviting by email we would have to find their hadles in the Identity Service. This service sometimes works not good, so we've implemented various workarounds to make it more reliable https://github.com/topcoder-platform/tc-project-service/blob/develop/src/routes/projectMemberInvites/create.js#L111-L118 like:
- making several attempts to find users in case request fails (as it did sometimes)
- we are filtering returned data, and remove all the users we didn't ask for, as I guess Identity Service uses some fuzzy searching and might return users we didn't search for
- please, take these thing into account: implement the same logic in TaaS API or apply another workarounds if you know better ways.
-
Update Swagger and Postman
Test Cases:
failed
array. The request itself should only fail if the user doesn't have access to call it, or there is some unexpected error happen, or there is a validation error of the request.
- Successfully add one member by "handle".
- Successfully add one member by "email".
- Successfully add 2+ members by "handles".
- Successfully add 2+ members by "email".
- Successfully add 2+ members by combining "handles" and "emails".
- Failed if we are adding a member by "handle" for an already added user.
- Failed if we are adding a member by "email" for an already added user.
- Failed if we are adding a member by "handle" for non-existent user.
- Failed if we are adding a member by "email" for non-existent user.
- If we add 6 members:
- 1 good members by "handle"
- 1 good member by "email"
- 1 non-existent member by "handle"
- 1 non-existent member by "email"
- 1 already added member by "handle"
- 1 already added member by "email"
Then 2 correct ones should be added successfully and 4 should be returned in thefailed
array with the corresponding errors