Source: api/workflow.js

  1. "use strict";
  2. module.exports = WorkflowClient;
  3. /**
  4. * Used to access Jira REST endpoints in '/rest/api/2/workflow'
  5. *
  6. * @param {JiraClient} jiraClient
  7. * @constructor WorkflowClient
  8. */
  9. function WorkflowClient(jiraClient) {
  10. this.jiraClient = jiraClient;
  11. /**
  12. * Returns all workflows.
  13. *
  14. * @method getWorkflows
  15. * @memberOf WorkflowClient#
  16. * @param {Object} opts The request options sent to the Jira API
  17. * @param {string} [opts.workflowName] The name of the workflow to retrieve.
  18. * @param [callback] Called when the workflow(s) have been retrieved.
  19. * @return {Promise} Resolved when the workflow(s) have been retrieved.
  20. */
  21. this.getWorkflows = function (opts, callback) {
  22. var qs = {};
  23. if (opts && typeof opts === 'object' && opts.hasOwnProperty('workflowName')) {
  24. qs.workflowName = opts.workflowName;
  25. }
  26. var options = {
  27. uri: this.jiraClient.buildURL('/workflow'),
  28. method: 'GET',
  29. json: true,
  30. followAllRedirects: true,
  31. qs: qs
  32. };
  33. return this.jiraClient.makeRequest(options, callback);
  34. };
  35. }