Skip to content

Create a new "PUT /v4/projects/:projectId(\\d+)/members/invites/:inviteId" endpoint  #422

@maxceem

Description

@maxceem

Overview

At the moment we use PUT /v4/projects/:projectId(\\d+)/members/invite endpoint to update the invites. This endpoint doesn't have the {id} and we post body with either userId or email mandatory to find the actual invite to update.

This kind of endpoint doesn't follow the RESTfull format and also, doesn't work if we have email masked, so when we want to cancel invitation but we know only masked email, we send request to it with masked email, but server cannot find the invite by masked email, see related issue in Connect App appirio-tech/connect-app#3413

In general, our current implementation of invite related endpoints doesn't follow the RESTfull style, and creating the current endpoint is a step towards moving to RESTfull format here.

Task

  • Implement a new endpoint which would update the invite by invite.id: PUT /v4/projects/:projectId(\\d+)/members/invites/:inviteId(\\d+) (with the s in the invites word).
  • This endpoint should work the same as existent one (copy code from the existent one) but the part for finding an invite to update should be different: https://github.com/topcoder-platform/tc-project-service/blob/dev/src/routes/projectMemberInvites/update.js#L39-L67
  • Instead of looking for invite by userId/email look for an invite by id with any invite status.
    • if no invite is found - return error 404: Invite with id {inviteId} for project id is not found.
    • if invite status is NOT INVITE_STATUS.PENDING or INVITE_STATUS.REQUESTED then return error 422: Invite in status "{invite.status}" cannot be updated.
  • continue the rest of the code as it is now.

General requirements

  • Copy and adjust unit tests for the new endpoint using existent endpoint unit test
  • Additionally, create unit tests to test the case when the invite is not found by id and when it cannot be updated as it's status doesn't allow it
  • Don't update Postman or Swagger files

Verfiication

Please, provide a demo video which shows 3 cases:

  • the server returns 404 for non-existent invite,
  • the server returns 422 for invite in the status which doesn't let us update invite
  • successful update of the invite

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions