Class: Matchstick::Campfire
- Inherits:
-
Object
- Object
- Matchstick::Campfire
- Defined in:
- lib/matchstick/campfire.rb
Direct Known Subclasses
Constant Summary collapse
- HOST =
"campfirenow.com"
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#subdomain ⇒ Object
readonly
Returns the value of attribute subdomain.
-
#use_ssl ⇒ Object
readonly
Returns the value of attribute use_ssl.
Instance Method Summary collapse
- #get(action) ⇒ Object
-
#initialize(subdomain, api_key, use_ssl = false) ⇒ Campfire
constructor
A new instance of Campfire.
- #post(action, body = {}) ⇒ Object
- #rooms ⇒ Object
Constructor Details
#initialize(subdomain, api_key, use_ssl = false) ⇒ Campfire
Returns a new instance of Campfire.
8 9 10 11 12 13 14 15 |
# File 'lib/matchstick/campfire.rb', line 8 def initialize(subdomain, api_key, use_ssl=false) @subdomain = subdomain @api_key = api_key @use_ssl = use_ssl @connection = build_connection self end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
6 7 8 |
# File 'lib/matchstick/campfire.rb', line 6 def api_key @api_key end |
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
6 7 8 |
# File 'lib/matchstick/campfire.rb', line 6 def connection @connection end |
#subdomain ⇒ Object (readonly)
Returns the value of attribute subdomain.
6 7 8 |
# File 'lib/matchstick/campfire.rb', line 6 def subdomain @subdomain end |
#use_ssl ⇒ Object (readonly)
Returns the value of attribute use_ssl.
6 7 8 |
# File 'lib/matchstick/campfire.rb', line 6 def use_ssl @use_ssl end |
Instance Method Details
#get(action) ⇒ Object
21 22 23 24 |
# File 'lib/matchstick/campfire.rb', line 21 def get(action) response = RestClient.get "#{connection}/#{action}", :content_type => :json, :accept => :json response.body.strip.empty? ? true : JSON.parse(response.body) end |
#post(action, body = {}) ⇒ Object
26 27 28 29 |
# File 'lib/matchstick/campfire.rb', line 26 def post(action, body = {}) response = RestClient.post "#{connection}/#{action}", body.to_json, :content_type => :json, :accept => :json response.body.strip.empty? ? true : JSON.parse(response.body) end |