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

Add new parameter for detailed company information #77

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
10 changes: 8 additions & 2 deletions lib/services/companies.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,14 @@
this.createCall('GET', 'companies::(' + query + '):(' + fields.join(',') + ')', {strict: true},cb)(this.config);
};

this.asAdmin = function(cb) {
this.createCall('GET', 'companies', {"is-company-admin": true}, cb)(this.config);
// if withDetail parameter is passed in function call, then detail of company will be fetched for which user is administrator.
// so that extra call won't be needed.
this.asAdmin = function(withDetail, cb) {
if(withDetail){
Copy link
Owner

Choose a reason for hiding this comment

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

You are changing a signature of a function which is already in used.

In order to make it smooth, please put a check something like this:

if (arguments.length === 1) {
  cb = withDetail;
  withDetail = false;
}

Otherwise, it will break for existing projects.

this.createCall('GET', "companies:(" + fields.join(",") + ")", {"is-company-admin": true, strict: true}, cb)(this.config);
} else {
this.createCall('GET', 'companies', {"is-company-admin": true}, cb)(this.config);
}
};

this.getUpdate = function (id, updateId, options, cb) {
Expand Down