Class: HOALife::Client::Base
- Inherits:
-
Object
- Object
- HOALife::Client::Base
- Defined in:
- lib/hoalife/client/base.rb
Overview
Base class for all HTTP requests Handles the implementation specific code of the API
Instance Method Summary collapse
-
#initialize(url, body = nil) ⇒ Base
constructor
A new instance of Base.
- #json ⇒ Object
- #response ⇒ Object
- #status ⇒ Object
- #uri ⇒ Object
Constructor Details
#initialize(url, body = nil) ⇒ Base
Returns a new instance of Base.
10 11 12 13 |
# File 'lib/hoalife/client/base.rb', line 10 def initialize(url, body = nil) @url = url @body = body end |
Instance Method Details
#json ⇒ Object
19 20 21 |
# File 'lib/hoalife/client/base.rb', line 19 def json @json ||= JSON.parse(response.body) end |
#response ⇒ Object
23 24 25 |
# File 'lib/hoalife/client/base.rb', line 23 def response @response ||= validate_response! end |
#status ⇒ Object
15 16 17 |
# File 'lib/hoalife/client/base.rb', line 15 def status @status ||= response.code.to_i end |
#uri ⇒ Object
27 28 29 |
# File 'lib/hoalife/client/base.rb', line 27 def uri @uri ||= URI::HTTPS.build(host: base_uri.host, path: request_uri.path, query: request_uri.query) end |