Class: TenderSummary::TenderApi
- Inherits:
-
Object
- Object
- TenderSummary::TenderApi
- Includes:
- HTTParty
- Defined in:
- lib/tender_summary/tender_api.rb
Class Attribute Summary collapse
-
.password ⇒ Object
Returns the value of attribute password.
-
.subdomain ⇒ Object
Returns the value of attribute subdomain.
-
.username ⇒ Object
Returns the value of attribute username.
Class Method Summary collapse
-
.add_json_helpers(data) ⇒ Object
Make the JSON a litte bit more fun to work with.
- .authenticate(subdomain = nil, username = nil, password = nil) ⇒ Object
- .base ⇒ Object
- .discussions(options = {}) ⇒ Object
- .site ⇒ Object
- .site_href ⇒ Object
Class Attribute Details
.password ⇒ Object
Returns the value of attribute password.
10 11 12 |
# File 'lib/tender_summary/tender_api.rb', line 10 def password @password end |
.subdomain ⇒ Object
Returns the value of attribute subdomain.
10 11 12 |
# File 'lib/tender_summary/tender_api.rb', line 10 def subdomain @subdomain end |
.username ⇒ Object
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 |
.base ⇒ Object
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( = {}) get(site.href(:discussions, )) end |
.site ⇒ Object
26 27 28 |
# File 'lib/tender_summary/tender_api.rb', line 26 def self.site @site ||= get(site_href) end |
.site_href ⇒ Object
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 |