Skip to content

add new endpoint POST /taas-teams/:id/members #150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 20, 2021

Conversation

imcaizheng
Copy link
Contributor

Verification

  • Run taas-apis locally.

  • Fire the POST /taas-teams/:id/members request in Postman. The response would look like:

    {
        "success": [
            {
                "id": 14159,
                "userId": 40159097,
                "role": "customer",
                "createdAt": "2021-02-19T08:06:20.392Z",
                "updatedAt": "2021-02-19T08:06:20.392Z",
                "createdBy": -101,
                "updatedBy": -101,
                "handle": "tester1234",
                "photoURL": null,
                "workingHourStart": "9:00",
                "workingHourEnd": "17:00",
                "timeZone": "Asia/Kolkata",
                "email": "sathya.jayabal@gmail.com"
            },
            {
                "id": 14160,
                "userId": 1800091,
                "role": "customer",
                "createdAt": "2021-02-19T08:06:20.526Z",
                "updatedAt": "2021-02-19T08:06:20.526Z",
                "createdBy": -101,
                "updatedBy": -101,
                "handle": "Scud",
                "photoURL": "https://topcoder-dev-media.s3.amazonaws.com/member/profile/Scud-1450982908556.png",
                "email": "email@domain.com",
                "workingHourStart": null,
                "workingHourEnd": null,
                "timeZone": null
            }
        ],
        "failed": [
            {
                "error": "User doesn't exist",
                "handle": "non-existing"
            },
            {
                "error": "User doesn't exist",
                "email": "non-existing@domain.com"
            }
        ]
    }

    Notice that two members are added to the project.

  • Repeat the request once. The response would look like:

    {
        "success": [],
        "failed": [
            {
                "error": "User doesn't exist",
                "handle": "non-existing"
            },
            {
                "error": "User doesn't exist",
                "email": "non-existing@domain.com"
            },
            {
                "error": "User is already added",
                "handle": "tester1234"
            },
            {
                "error": "User is already added",
                "email": "email@domain.com"
            }
        ]
    }

    Notice that the two members previously added to the project failed to be added to the project again.

Copy link
Contributor

@maxceem maxceem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @imcaizheng works great.

Only one thing, we should allow calling this endpoint to any user who has access to the team, not only to the team members.

In other words, anyone who can GET /taas-teams/:id should be able to POST /taas-teams/:id/members.

@imcaizheng imcaizheng requested a review from maxceem February 19, 2021 14:54
// extract error message from V3 API
errorResponse.message = _.get(err, 'response.body.result.content')
// extract error message from V3/V5 API
errorResponse.message = _.get(err, 'response.body.result.content') || _.get(err, 'response.body.message')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a slight improvement here by the way.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, this change looks good

Copy link
Contributor

@maxceem maxceem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @imcaizheng works perfectly now.

@maxceem maxceem merged commit a1a2a52 into topcoder-platform:dev Feb 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants