Sha256: 758ab0f38bb5bb01a4ab6c91da8173cb0305535c8ba94d150a51ebb15d02a532

Contents?: true

Size: 764 Bytes

Versions: 3

Compression:

Stored size: 764 Bytes

Contents

module Parkwhiz
  class Venue
    include Virtus.model

    attribute :name, String
    attribute :address, String
    attribute :city, String
    attribute :state, String
    attribute :zip, String
    attribute :url_fragment, String
    attribute :distance, Integer
    attribute :relevancy, Integer

    SEARCH_PATH = "/venue/search/"

    def self.search(search_parameters)
      response = Parkwhiz.connection.get do |request|
        request.url SEARCH_PATH
        request.params['key'] = Parkwhiz.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.collect{|venue_json| self.new(venue_json)}
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
parkwhiz-0.4.0 lib/parkwhiz/venue.rb
parkwhiz-0.3.0 lib/parkwhiz/venue.rb
parkwhiz-0.2.0 lib/parkwhiz/venue.rb