Skip to content
This repository has been archived by the owner on Jul 23, 2020. It is now read-only.

Commit

Permalink
gelAllProjects version choosing added (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
MrRefactoring authored Aug 7, 2019
1 parent d33c88e commit 94ac5f2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
10 changes: 9 additions & 1 deletion api/project.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
export declare class Project {
getAllProjects(opts?: any, callback?: (err: any, data: any) => void): Promise<any>;
getAllProjects(
opts?: {
expand?: string;
recent?: number;
properties?: string[];
apiVersion?: string | number | 2 | 3;
},
callback?: (err: any, data: any) => void
): Promise<any>;

updateProject(
opts: {
Expand Down
26 changes: 16 additions & 10 deletions api/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,26 @@ function ProjectClient(jiraClient) {
*
* @method getAllProjects
* @memberOf ProjectClient#
* @param [opts] The request options sent to the Jira API.
* @param [callback] Called when the projects have been retrieved.
* @param {Object} [opts] The request options sent to the Jira API.
* @param {string} [opts.expand]
* @param {number} [opts.recent]
* @param {Array<string>} [opts.properties]
* @param {callback} [callback] Called when the projects have been retrieved.
* @return {Promise} Resolved when the projects have been retrieved.
*/
this.getAllProjects = function (opts, callback) {
opts = opts || {};
var options = this.buildRequestOptions(opts, '', 'GET');

if (!Object.keys(options.body).length) {
delete options.body;
}
if (!Object.keys(options.qs).length) {
delete options.qs;
}
var options = {
uri: this.jiraClient.buildURL('/project', opts.apiVersion),
method: 'GET',
followAllRedirects: true,
json: true,
qs: {
expand: opts.expand,
recent: opts.recent,
properties: opts.properties && opts.properties.join(',')
}
};

return this.jiraClient.makeRequest(options, callback);
};
Expand Down

0 comments on commit 94ac5f2

Please sign in to comment.