Module: R3c

Defined in:
lib/r3c.rb,
lib/r3c/r3c.rb,
lib/r3c/version.rb,
lib/r3c/rest_helper.rb

Defined Under Namespace

Classes: Attachment, BaseEntity, CustomField, Group, Issue, IssueStatus, Membership, Project, Query, Role, TimeEntry, Tracker, User, Version, WikiPage

Constant Summary collapse

VERSION =
"0.0.7"

Class Method Summary collapse

Class Method Details

.add_watcher(issue_id, user_id, format = "xml") ⇒ Object

Note: see r3c.rb for example about how to retrieve watchers on an issue Example: R3c.add_watcher(1, 1)



15
16
17
18
19
20
# File 'lib/r3c/rest_helper.rb', line 15

def self.add_watcher(issue_id, user_id, format="xml")
  #POST /issues/[id]/watchers.[format]
  response = RestClient.post("#{R3c::BaseEntity.site}/issues/#{issue_id}/watchers.#{format}?key=#{R3c::BaseEntity.headers['X-Redmine-API-Key']}", {user_id: user_id})
  return JSON.parse(response) if format == "json"
  response
end

.auth(auth) ⇒ Object



21
22
23
# File 'lib/r3c.rb', line 21

def self.auth auth
  R3c::BaseEntity.auth auth
end

.enumerations(enumeration, format = "xml") ⇒ Object

Example: R3c.enumerations(“issue_priorities”)



33
34
35
36
37
38
# File 'lib/r3c/rest_helper.rb', line 33

def self.enumerations(enumeration, format="xml")
  #GET /enumerations/<enumeration>.[format]   #enumeration= "issue_priorities" OR  "time_entry_activities"
  response = RestClient.get("#{R3c::BaseEntity.site}/enumerations/#{enumeration}.#{format}?key=#{R3c::BaseEntity.headers['X-Redmine-API-Key']}")   
  return JSON.parse(response) if format == "json"
  response
end

.format(format) ⇒ Object



17
18
19
# File 'lib/r3c.rb', line 17

def self.format format
  R3c::BaseEntity.set_format(format)
end

.r3c_versionObject



9
10
11
# File 'lib/r3c.rb', line 9

def self.r3c_version
  VERSION
end

.remove_watcher(issue_id, user_id, format = "xml") ⇒ Object

Example: R3c.remove_watcher(1, 1)



24
25
26
27
28
29
# File 'lib/r3c/rest_helper.rb', line 24

def self.remove_watcher(issue_id, user_id, format="xml")
 #DELETE /issues/[id]/watchers/[user_id].[format]
  response = RestClient.delete("#{R3c::BaseEntity.site}/issues/#{issue_id}/watchers/#{user_id}.#{format}?key=#{R3c::BaseEntity.headers['X-Redmine-API-Key']}")
  return JSON.parse(response) if format == "json"
  response
end

.search(q, format = "xml") ⇒ Object

Example: R3c.search(“sometext”)



42
43
44
45
46
47
# File 'lib/r3c/rest_helper.rb', line 42

def self.search(q, format = "xml")
# GET  '/search.xml', :q => 'recipe subproject commit', :all_words => ''
response = RestClient.get("#{R3c::BaseEntity.site}/search.#{format}/?key=#{R3c::BaseEntity.headers['X-Redmine-API-Key']}", {all_words: '', q: q})   
return JSON.parse(response) if format == "json"
response
end

.site(site) ⇒ Object



13
14
15
# File 'lib/r3c.rb', line 13

def self.site site
  R3c::BaseEntity.set_site(site)
end

.upload(file, format = "xml") ⇒ Object



6
7
8
9
# File 'lib/r3c/rest_helper.rb', line 6

def self.upload(file, format="xml")
  response = RestClient.post("#{R3c::BaseEntity.site}/uploads.#{format}?key=#{R3c::BaseEntity.headers['X-Redmine-API-Key']}", file, {:multipart => true, :content_type => 'application/octet-stream'})
  token = JSON.parse(response)['upload']['token']
end