Skip to content
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

Added optional parameters for adding and editing resource members #45

Merged
merged 1 commit into from
Mar 19, 2018
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
3 changes: 2 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
],
"plugins": [
"@babel/plugin-proposal-export-default-from",
"@babel/plugin-proposal-export-namespace-from"
"@babel/plugin-proposal-export-namespace-from",
"@babel/plugin-proposal-object-rest-spread"
]
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"scripts": {
"build:clean": "rimraf -rf dist && mkdirp -p dist",
"build:es6": "babel src -d dist/latest",
"build:es5": "babel src -d dist/es5 --no-babelrc --presets=@babel/env --plugins=@babel/plugin-proposal-export-default-from,@babel/plugin-proposal-export-namespace-from",
"build:es5": "babel src -d dist/es5 --no-babelrc --presets=@babel/env --plugins=@babel/plugin-proposal-export-default-from,@babel/plugin-proposal-export-namespace-from,@babel/plugin-proposal-object-rest-spread",
"build": "npm run build:clean && npm run build:es6 && npm run build:es5",
"prepublishOnly": "npm run build"
},
Expand Down
6 changes: 4 additions & 2 deletions src/templates/ResourceMembers.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,25 @@ class ResourceMembers extends BaseService {
return RequestHelper.get(this, `${this.resourceType}/${rId}/members`);
}

add(resourceId, userId, accessLevel) {
add(resourceId, userId, accessLevel, options = {}) {
const [rId, uId] = [resourceId, userId].map(encodeURIComponent);

return RequestHelper.post(this, `${this.resourceType}/${rId}/members`, {
user_id: uId,
access_level: parseInt(accessLevel, 10),
...options,
});
}

edit(resourceId, userId, accessLevel) {
edit(resourceId, userId, accessLevel, options = {}) {
const [rId, uId] = [resourceId, userId].map(encodeURIComponent);

return RequestHelper.put(
this,
`${this.resourceType}/${rId}/members/${uId}`,
{
access_level: parseInt(accessLevel, 10),
...options,
},
);
}
Expand Down