Skip to content

Create member endpoint should return member details #628 #629

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
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
49 changes: 49 additions & 0 deletions docs/Project API.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,55 @@
},
"response": []
},
{
"name": "Create project member with no payload and return member details",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 201\", function () {",
" pm.response.to.have.status(201);",
" pm.environment.set(\"memberId\", pm.response.json().id);",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "Bearer {{jwt-token}}"
},
{
"key": "Content-Type",
"value": "application/json"
}
],
"url": {
"raw": "{{api-url}}/projects/{{projectId}}/members?fields=id,userId,role,isPrimary,deletedAt,createdAt,updatedAt,deletedBy,createdBy,updatedBy,handle,photoURL,workingHourStart,workingHourEnd,timeZone,email",
"host": [
"{{api-url}}"
],
"path": [
"projects",
"{{projectId}}",
"members"
],
"query": [
{
"key": "fields",
"value": "id,userId,role,isPrimary,deletedAt,createdAt,updatedAt,deletedBy,createdBy,updatedBy,handle,photoURL,workingHourStart,workingHourEnd,timeZone,email"
}
]
},
"description": "If the request payload is valid, than project customer should be added. This should sync with the direct project is project is associated with direct project."
},
"response": []
},
{
"name": "Update project member",
"request": {
Expand Down
7 changes: 7 additions & 0 deletions src/routes/projectMembers/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ module.exports = [
newMember = await util.addUserToProject(req, member, transaction);
});

try {
const fields = req.query.fields ? req.query.fields.split(',') : null;
[newMember] = await util.getObjectsWithMemberDetails([newMember], fields, req);
} catch (err) {
req.log.error('Cannot get user details for member.');
req.log.debug('Error during getting user details for member.', err);
}
return res.status(201).json(newMember);
} catch (err) {
return next(err);
Expand Down