Sha256: 20cf07eceff5983d42ef420b8af6a631b7707f78b8b659d40e35cf4899d50907

Contents?: true

Size: 919 Bytes

Versions: 2

Compression:

Stored size: 919 Bytes

Contents

module Parkwhiz
  class Event
    include Virtus.model
    
    attribute :event_name, String
    attribute :start, Integer
    attribute :end, Integer
    attribute :parkwhiz_url, String
    attribute :venue_name, String
    attribute :lat, Float
    attribute :lng, Float
    attribute :min_price, Float
    attribute :max_price, Float
    attribute :min_distance, Integer
    attribute :max_distance, Integer
    attribute :amenities, Hash
    attribute :parking_listings, Array[Location]

    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{|event_json| self.new(event_json)}
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
parkwhiz-0.4.0 lib/parkwhiz/event.rb
parkwhiz-0.3.0 lib/parkwhiz/event.rb