Class: YouTrack::Client::ApplyIssueCommand

Inherits:
Request
  • Object
show all
Defined in:
lib/you_track/client/requests/apply_issue_command.rb

Instance Method Summary collapse

Methods inherited from Request

#find, #require_parameters

Instance Method Details

#mock(params = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/you_track/client/requests/apply_issue_command.rb', line 12

def mock(params={})
  id         = params.delete("id")
  issue      = find(:issues, id)
  comment_id = "#{Cistern::Mock.random_numbers(2)}-#{Cistern::Mock.random_numbers(5)}"

  if params["comment"]
    comment = {
      "id"             => comment_id,
      "author"         => service.username,
      "deleted"        => false,
      "text"           => params["comment"],
      "shownForIssuer" => false,
      "created"        => Time.now.to_i * 1000,
      "issueId"        => id,
    }
    service.data[:comments][comment_id] = comment
  end

  if params["command"]
    commands = params["command"].split.each_slice(2).map { |a| [a[0], a[1]] }
    commands.each do |command|
      issue["custom_fields"].detect { |f| f[0] == command[0] }[1] = command[1]
    end
  end

  service.response
end

#real(params = {}) ⇒ Object



2
3
4
5
6
7
8
9
10
# File 'lib/you_track/client/requests/apply_issue_command.rb', line 2

def real(params={})
  id = params.delete("id")

  service.request(
    :path   => "/issue/#{id}/execute",
    :query  => params,
    :method => :post,
  )
end