Module: CityGrid::API::Base::ClassMethods

Defined in:
lib/citygrid/api/base.rb

Instance Method Summary collapse

Instance Method Details

#endpointObject



18
19
20
# File 'lib/citygrid/api/base.rb', line 18

def endpoint
  # Specified for each API
end

#publisherObject



22
23
24
# File 'lib/citygrid/api/base.rb', line 22

def publisher
  CityGrid.publisher
end

#request(options = {}) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/citygrid/api/base.rb', line 26

def request options = {}
  query = options.merge :publisher => publisher, :format => "json"
  response = get endpoint, :query => query

  if !response["errors"] || response["errors"].empty?
    CityGrid::API::Response.new response
  else
    raise Error.new response["errors"], response
  end
end