Class: Watcher

Inherits:
Services show all
Defined in:
lib/jirarest2/services/watcher.rb

Overview

Watchers do have their own calling

Instance Method Summary collapse

Methods inherited from Services

#delete, #get, #post, #put

Constructor Details

#initialize(connection, issueid) ⇒ Watcher

Set our uritail

Parameters:

  • connection (Connection)
  • issueid (String)

    The id or key of the issue in question



27
28
29
30
# File 'lib/jirarest2/services/watcher.rb', line 27

def initialize(connection, issueid)
  @uritail = "issue/#{issueid}/watchers"
  super(connection)
end

Instance Method Details

#add_watcher(username) ⇒ Boolean

Adds a new watcher for the issue

Parameters:

  • username (String)

    Username of the new watcher

Returns:

  • (Boolean)

    Success



48
49
50
51
52
53
54
55
56
# File 'lib/jirarest2/services/watcher.rb', line 48

def add_watcher(username)
  ret = post(username)
  case ret.code
  when "204"
    return true
  else
    return false
  end
end

#get_watchersString

Return all the watchers of the issue

Returns:

  • (String)

    Usernames of watching users



35
36
37
38
39
40
41
42
# File 'lib/jirarest2/services/watcher.rb', line 35

def get_watchers
  ret = get
  watchers = Array.new
  ret["watchers"].each { |entry|
    watchers << entry["name"]
  }
  return watchers
end

#remove_watcher(username) ⇒ Boolean

remove one watcher from the issue

Parameters:

  • username (String)

    Username of the watcher to delete

Returns:

  • (Boolean)

    Success



62
63
64
65
66
67
68
69
70
71
# File 'lib/jirarest2/services/watcher.rb', line 62

def remove_watcher(username)
  query = {"username" => username}
  ret = delete(query)
  case ret.code # Have to decide what to do here (Work with exceptions or with the case block)
  when "204"
    return true
  else
    false
  end
end