Skip to content

Create 3 proxy endpoints for project members/invites #158

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ app.use((err, req, res, next) => {

if (err.response) {
// extract error message from V3/V5 API
errorResponse.message = _.get(err, 'response.body.result.content') || _.get(err, 'response.body.message')
errorResponse.message = _.get(err, 'response.body.result.content.message') || _.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.

Extract v3 error message from the correct position in the response body.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, it looks good.

}

if (_.isUndefined(errorResponse.message)) {
Expand Down
131 changes: 130 additions & 1 deletion docs/Topcoder-bookings-api.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -4527,7 +4527,136 @@
}
},
"response": []
}
},
{
"name": "GET /taas-teams/:id/members",
"request": {
"method": "GET",
"header": [
{
"key": "Authorization",
"type": "text",
"value": "Bearer {{token_bookingManager}}"
},
{
"key": "Content-Type",
"type": "text",
"value": "application/json"
}
],
"url": {
"raw": "{{URL}}/taas-teams/:id/members?role=customer&fields=id,userId,role,createdAt,updatedAt,createdBy,updatedBy,handle,photoURL,workingHourStart,workingHourEnd,timeZone,email",
"host": [
"{{URL}}"
],
"path": [
"taas-teams",
":id",
"members"
],
"query": [
{
"key": "role",
"value": "customer"
},
{
"key": "fields",
"value": "id,userId,role,createdAt,updatedAt,createdBy,updatedBy,handle,photoURL,workingHourStart,workingHourEnd,timeZone,email"
}
],
"variable": [
{
"key": "id",
"value": "16705"
}
]
}
},
"response": []
},
{
"name": "GET /taas-teams/:id/invites",
"request": {
"method": "GET",
"header": [
{
"key": "Authorization",
"type": "text",
"value": "Bearer {{token_bookingManager}}"
},
{
"key": "Content-Type",
"type": "text",
"value": "application/json"
}
],
"url": {
"raw": "{{URL}}/taas-teams/:id/invites?fields=createdAt,deletedAt,role,updatedBy,createdBy,id,projectId,userId,email,deletedBy,updatedAt,status",
"host": [
"{{URL}}"
],
"path": [
"taas-teams",
":id",
"invites"
],
"query": [
{
"key": "fields",
"value": "createdAt,deletedAt,role,updatedBy,createdBy,id,projectId,userId,email,deletedBy,updatedAt,status"
}
],
"variable": [
{
"key": "id",
"value": "16705"
}
]
}
},
"response": []
},
{
"name": "DELETE /taas-teams/:id/members/:projectMemberId",
"request": {
"method": "DELETE",
"header": [
{
"key": "Authorization",
"type": "text",
"value": "Bearer {{token_bookingManager}}"
},
{
"key": "Content-Type",
"type": "text",
"value": "application/json"
}
],
"url": {
"raw": "{{URL}}/taas-teams/:id/members/:projectMemberId",
"host": [
"{{URL}}"
],
"path": [
"taas-teams",
":id",
"members",
":projectMemberId"
],
"variable": [
{
"key": "id",
"value": "16705"
},
{
"key": "projectMemberId",
"value": "14327"
}
]
}
},
"response": []
}
]
},
{
Expand Down
182 changes: 179 additions & 3 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1580,6 +1580,177 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Error'
get:
tags:
- Teams
description: |
Search members in a team.
Serves as a proxy endpoint for `GET /projects/{projectId}/members`.
security:
- bearerAuth: []
parameters:
- in: path
name: id
required: true
schema:
type: integer
description: The team/project id.
- in: query
name: fields
required: false
schema:
type: string
description: Fields to be returned.
- in: query
name: role
required: false
schema:
type: string
description: Filtered by a specific role.
responses:
'200':
description: OK
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/ProjectMember'
'400':
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: Not authenticated
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'403':
description: Not authorized
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal Server Error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'

/taas-teams/{id}/invites:
get:
tags:
- Teams
description: |
Search member invites for a team.
Serves as a proxy endpoint for `GET /projects/{projectId}/invites`.
security:
- bearerAuth: []
parameters:
- in: path
name: id
required: true
schema:
type: integer
description: The team/project id.
- in: query
name: fields
required: false
schema:
type: string
description: Fields to be returned.
responses:
'200':
description: OK
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/ProjectMemberInvite'
'400':
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: Not authenticated
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'403':
description: Not authorized
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal Server Error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/taas-teams/{id}/members/{projectMemberId}:
delete:
tags:
- Teams
description: |
Remove a member from a team.
Serves as a proxy endpoint for `DELETE /projects/{projectId}/members/{id}`.
security:
- bearerAuth: []
parameters:
- in: path
name: id
required: true
schema:
type: integer
description: The team/project id.
- in: path
name: projectMemberId
required: true
schema:
type: integer
description: The id of the project member.
responses:
'204':
description: OK
'400':
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: Not authenticated
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'403':
description: Forbidden
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: Not Found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: Internal Server Error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/taas-teams/skills:
get:
tags:
Expand Down Expand Up @@ -2496,10 +2667,9 @@ components:
properties:
success:
type: array
description: "The handles."
description: "The members created."
items:
type: object
example: {"createdAt": "2021-02-18T19:58:50.610Z", "createdBy": -101, "email": "email@domain.com", "handle": "Scud", "id": 14155, "photoURL": "https://topcoder-dev-media.s3.amazonaws.com/member/profile/Scud-1450982908556.png", "role": "customer", "timeZone": null, "updatedAt": "2021-02-18T19:58:50.611Z", "updatedBy": -101, "userId": 1800091, "workingHourEnd": null, "workingHourStart": null}
$ref: '#/components/schemas/ProjectMember'
failed:
type: array
description: "The emails."
Expand All @@ -2525,6 +2695,12 @@ components:
type: string
description: "the email of a member"
example: 'xxx@xxx.com'
ProjectMember:
type: object
example: {"id": 14329, "userId": 40159097, "role": "customer", "createdAt": "2021-02-24T12:34:45.074Z", "updatedAt": "2021-02-24T12:34:45.075Z", "createdBy": -101, "updatedBy": -101, "handle": "tester1234", "photoURL": null, "workingHourStart": "9:00", "workingHourEnd": "17:00", "timeZone": "Asia/Kolkata", "email": "sathya.jayabal@gmail.com"}
ProjectMemberInvite:
type: object
example: {"createdAt": "2021-02-24T11:02:12.673Z", "deletedAt": null, "role": "customer", "updatedBy": -101, "createdBy": -101, "id": 3686, "projectId": 16705, "userId": 23008602, "email": null, "deletedBy": null, "updatedAt": "2021-02-24T11:02:12.674Z", "status": "pending"}
Error:
required:
- message
Expand Down
Loading