Class: Citywrapper::ApiBase
- Inherits:
-
Object
- Object
- Citywrapper::ApiBase
- Defined in:
- lib/citywrapper/api_base.rb
Direct Known Subclasses
Constant Summary collapse
- JSON_HEADERS =
{ 'Content-Type' => 'application/json', 'Accept' => 'application/json' }.freeze
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
-
#initialize ⇒ ApiBase
constructor
A new instance of ApiBase.
- #request(params: {}, method: :get) ⇒ Object
Constructor Details
#initialize ⇒ ApiBase
Returns a new instance of ApiBase.
10 11 12 |
# File 'lib/citywrapper/api_base.rb', line 10 def initialize @config = Citywrapper.configuration end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
3 4 5 |
# File 'lib/citywrapper/api_base.rb', line 3 def config @config end |
#response ⇒ Object
Returns the value of attribute response.
3 4 5 |
# File 'lib/citywrapper/api_base.rb', line 3 def response @response end |
Instance Method Details
#request(params: {}, method: :get) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/citywrapper/api_base.rb', line 14 def request(params: {}, method: :get) raise 'Please set your API key' unless config.api_key @method = method @params = params @query_uri = build_query run_request process_response end |