Class: JiraCommand::Jira::Transition

Inherits:
Base
  • Object
show all
Defined in:
lib/jira_command/jira/transition.rb

Instance Attribute Summary

Attributes inherited from Base

#config, #conn

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from JiraCommand::Jira::Base

Instance Method Details

#list(issue_key:) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/jira_command/jira/transition.rb', line 10

def list(issue_key:)
  request_url = "rest/api/2/issue/#{issue_key}/transitions"
  res = @conn.get(request_url)

  body = JSON.parse(res.body)

  body['transitions'].map { |item| { id: item['id'].to_i, name: item['name'] } }
end

#transite(issue_key:, target_transition_id:) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/jira_command/jira/transition.rb', line 19

def transite(issue_key:, target_transition_id:)
  request_url = "rest/api/2/issue/#{issue_key}/transitions"

  @conn.post do |req|
    req.url request_url
    req.body = { transition: { id: target_transition_id } }.to_json
  end
end