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.8"

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)



20
21
22
23
24
25
# File 'lib/r3c/rest_helper.rb', line 20

def self.add_watcher(issue_id, user_id, format="xml")
  #POST /issues/[id]/watchers.[format]
  response = execute(method: :post, url: "#{R3c::BaseEntity.site}/issues/#{issue_id}/watchers.#{format}", headers: {params: {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”)



38
39
40
41
42
43
# File 'lib/r3c/rest_helper.rb', line 38

def self.enumerations(enumeration, format="xml")
  #GET /enumerations/<enumeration>.[format]   #enumeration= "issue_priorities" OR  "time_entry_activities"
  response =  self.execute(method: :get, url: "#{R3c::BaseEntity.site}/enumerations/#{enumeration}.#{format}")   
  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)



29
30
31
32
33
34
# File 'lib/r3c/rest_helper.rb', line 29

def self.remove_watcher(issue_id, user_id, format="xml")
 #DELETE /issues/[id]/watchers/[user_id].[format]
  response =  execute(method: :delete, url: "#{R3c::BaseEntity.site}/issues/#{issue_id}/watchers/#{user_id}.#{format}")
  return JSON.parse(response) if format == "json"
  response
end

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

Example: R3c.search(“sometext”)



49
50
51
52
53
54
# File 'lib/r3c/rest_helper.rb', line 49

def self.search(q, format = "xml")
# GET  '/search.xml', :q => 'recipe subproject commit', :all_words => ''
response = execute(method: :get, url: "#{R3c::BaseEntity.site}/search.#{format}",  headers: {params: {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

.ssl(ssl_options) ⇒ Object



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

def self.ssl ssl_options
  if R3c::BaseEntity.include?("https") 
   return R3c::BaseEntity.set_ssl ssl_options
  end
end

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



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

def self.upload(file, format="xml")
  response = execute(method: :post, url: "#{R3c::BaseEntity.site}/uploads.#{format}", file: file, :multipart => true, :content_type => 'application/octet-stream')
  token = JSON.parse(response)['upload']['token']
end

.verify_ssl?Boolean

Returns:

  • (Boolean)


31
32
33
34
35
36
37
# File 'lib/r3c.rb', line 31

def self.verify_ssl?
   if R3c::BaseEntity.self.ssl_options[:verify_mode] == OpenSSL::SSL::VERIFY_NONE
	return false
   else 
	return true
   end
end