Sha256: b0f0c8e867cd06c5ed5702880a63d3144c77441e0830763fe5a7b67056c813ec

Contents?: true

Size: 603 Bytes

Versions: 1

Compression:

Stored size: 603 Bytes

Contents

module Parkwhiz

  SEARCH_PATH = "/search/"

  # Search
  #
  # Returns:
  # Array of ParkWhiz::Location
  #
  # Endpoint: http://www.parkwhiz.com/developers/search/
  #
  def self.search(search_parameters)
    response = connection.get do |request|
      request.url SEARCH_PATH
      request.params['key'] = api_key
      request.params.merge!(search_parameters)
    end

    raise SearchError.new(response.body['error']) if response.body.kind_of?(Hash) && response.body['error']

    (response.body['parking_listings']||[]).collect{|parking_listing_json| Location.new(parking_listing_json)}
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
parkwhiz-0.4.0 lib/parkwhiz/search.rb