Class: Citywrapper::ApiBase

Inherits:
Object
  • Object
show all
Defined in:
lib/citywrapper/api_base.rb

Direct Known Subclasses

Coverage, SinglePointCoverage, TravelTime

Constant Summary collapse

JSON_HEADERS =
{
  'Content-Type' => 'application/json',
  'Accept' => 'application/json'
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeApiBase

Returns a new instance of ApiBase.



12
13
14
15
# File 'lib/citywrapper/api_base.rb', line 12

def initialize
  @config = Citywrapper.configuration
  warn "NOTE: #{self.class} is deprecated and will likely not work in the future"
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



5
6
7
# File 'lib/citywrapper/api_base.rb', line 5

def config
  @config
end

#responseObject

Returns the value of attribute response.



5
6
7
# File 'lib/citywrapper/api_base.rb', line 5

def response
  @response
end

Instance Method Details

#request(params: {}, method: :get) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/citywrapper/api_base.rb', line 17

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