Class: TenderSummary::TenderApi

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/tender_summary/tender_api.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.passwordObject

Returns the value of attribute password.



10
11
12
# File 'lib/tender_summary/tender_api.rb', line 10

def password
  @password
end

.subdomainObject

Returns the value of attribute subdomain.



10
11
12
# File 'lib/tender_summary/tender_api.rb', line 10

def subdomain
  @subdomain
end

.usernameObject

Returns the value of attribute username.



10
11
12
# File 'lib/tender_summary/tender_api.rb', line 10

def username
  @username
end

Class Method Details

.add_json_helpers(data) ⇒ Object

Make the JSON a litte bit more fun to work with



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/tender_summary/tender_api.rb', line 39

def self.add_json_helpers(data)
  case data
  when Hash
    data.send(:extend, TenderSummary::JsonHelpers)
    data.each { |_, value| add_json_helpers(value) }
  when Array
    data.each { |elem| add_json_helpers(elem) }
  end

  data
end

.authenticate(subdomain = nil, username = nil, password = nil) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/tender_summary/tender_api.rb', line 13

def self.authenticate(subdomain = nil, username = nil, password = nil)
  self.subdomain ||= subdomain
  self.username  ||= username
  self.password  ||= password

  basic_auth(self.username, self.password)
  base_uri(HTTParty.normalize_base_uri(site_href))
end

.baseObject



30
31
32
# File 'lib/tender_summary/tender_api.rb', line 30

def self.base
  @base ||= get('https://api.tenderapp.com/')
end

.discussions(options = {}) ⇒ Object



22
23
24
# File 'lib/tender_summary/tender_api.rb', line 22

def self.discussions(options = {})
  get(site.href(:discussions, options))
end

.siteObject



26
27
28
# File 'lib/tender_summary/tender_api.rb', line 26

def self.site
  @site ||= get(site_href)
end

.site_hrefObject



34
35
36
# File 'lib/tender_summary/tender_api.rb', line 34

def self.site_href
  @site_href ||= base.href('site', :site_permalink => subdomain)
end