1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
module JIRA
module Resource
class WatcherFactory < JIRA::BaseFactory # :nodoc:
end
class Watcher < JIRA::Base
belongs_to :issue
nested_collections true
def self.endpoint_name
'watchers'
end
def self.all(client, options = {})
issue = options[:issue]
raise ArgumentError, 'parent issue is required' unless issue
path = "#{issue.self}/#{endpoint_name}"
response = client.get(path)
json = parse_json(response.body)
json['watchers'].map do |watcher|
issue.watchers.build(watcher)
end
end
def save!(user_id, path = nil)
path ||= new_record? ? url : patched_url
response = client.post(path, user_id.to_json)
true
end
end
end
end
|