Class: Terjira::Client::Issue

Inherits:
Base
  • Object
show all
Defined in:
lib/terjira/client/issue.rb

Constant Summary collapse

ISSUE_JQL_KEYS =
[:sprint, :assignee, :reporter, :project, :issuetype, :priority, :status, :statusCategory]

Constants inherited from Base

Base::AGILE_API_PATH, Base::DEFAULT_API_PATH, Base::DEFAULT_CACHE_SEC

Constants included from JQLQueryBuilder

JQLQueryBuilder::JQL_KEYS

Constants included from AuthOptionBuilder

AuthOptionBuilder::AUTH_CACHE_KEY

Class Method Summary collapse

Methods inherited from Base

cache, class_name, client, parse_body, resource, username

Methods included from JQLQueryBuilder

#build_jql_query

Methods included from AuthOptionBuilder

#auth_file_cache, #build_auth_options, #build_auth_options_by_cached, #build_auth_options_by_tty, #expire_auth_options

Class Method Details

.all(options = {}) ⇒ Object



10
11
12
13
14
15
# File 'lib/terjira/client/issue.rb', line 10

def all(options = {})
  opts = options.slice(*ISSUE_JQL_KEYS)
  return resource.all if options.blank?
  max_results = options.delete(:max_results) || 500
  resource.jql(build_jql_query(opts), max_results: max_results)
end

.assign(issue, assignee) ⇒ Object



26
27
28
29
# File 'lib/terjira/client/issue.rb', line 26

def assign(issue, assignee)
  body = { name: assignee.key_value }.to_json
  api_put("issue/#{issue.key_value}/assignee", body)
end

.create(options = {}) ⇒ Object



36
37
38
39
40
41
42
43
44
45
# File 'lib/terjira/client/issue.rb', line 36

def create(options = {})
  params = extract_to_fields_params(options)
  if transition_param = extract_to_transition_param(options)
    params.merge!(transition_param)
  end

  resp = api_post "issue", params.to_json
  result_id = resp["id"]
  find(result_id)
end

.current_my_issuesObject



22
23
24
# File 'lib/terjira/client/issue.rb', line 22

def current_my_issues
  jql("assignee = #{self.key_value} AND statusCategory != 'Done'")
end

.find(issue, options = {}) ⇒ Object



17
18
19
20
# File 'lib/terjira/client/issue.rb', line 17

def find(issue, options = {})
  resp = api_get("issue/#{issue.key_value}", options)
  build(resp)
end

.trans(issue, options = {}) ⇒ Object



53
54
55
56
57
58
59
# File 'lib/terjira/client/issue.rb', line 53

def trans(issue, options = {})
  params = extract_to_transition_param(options)
  params.merge!(extract_to_update_params(options))
  params.merge!(extract_to_fields_params(options))
  api_post "issue/#{issue.key_value}/transitions", params.to_json
  find(issue)
end

.update(issue, options = {}) ⇒ Object



47
48
49
50
51
# File 'lib/terjira/client/issue.rb', line 47

def update(issue, options = {})
  params = extract_to_fields_params(options)
  api_put "issue/#{issue.key_value}", params.to_json
  find(issue)
end

.write_comment(issue, message) ⇒ Object



31
32
33
34
# File 'lib/terjira/client/issue.rb', line 31

def write_comment(issue, message)
  resp = api_post("issue/#{issue.key_value}/comment", { body: message }.to_json)
  find(issue)
end