parkwhiz 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: daf3fa24873048348de4cec14e569370581adaab
4
+ data.tar.gz: edc81c594b145791c5bef3c3ccc0bc23d792f901
5
+ SHA512:
6
+ metadata.gz: b6bf8d75505ee5774fe0ee0ce302cd7b3f38dea73f007332a0373323eb8c71abbd059c8a324ba2fd9fc31f8849d3c5a023cee343677a75f61d7ffce648a29959
7
+ data.tar.gz: d50f7b902666ee84b364230dd29322e37ed7332b88154df8a5f77983d45d720dd08a1804532fe0351be86b4f8b6c565627e282dd0949fd332173786cd5ee9b03
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,4 @@
1
+ --color
2
+ --format progress
3
+ --require spec_helper
4
+ --pattern "spec/**/*_spec.rb"
@@ -0,0 +1,2 @@
1
+ === 0.1.0
2
+ - Search API endpoint
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in parkwhiz.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Austin Fonacier
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,41 @@
1
+ # Parkwhiz
2
+
3
+ A gem wrapper to Parkwhiz API.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'parkwhiz'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install parkwhiz
18
+
19
+ ## Usage
20
+
21
+ ```ruby
22
+
23
+ # Set your api key
24
+ Parkwhiz.api_key = "my api key"
25
+
26
+ locations = Parkwhiz.search({destination: '1 World Way, Los Angeles, CA 90045'})
27
+ # Array of ParkwhizLocations
28
+ ```
29
+ ## Run Specs
30
+
31
+ ```
32
+ rake
33
+ ```
34
+
35
+ ## Contributing
36
+
37
+ 1. Fork it ( http://github.com/<my-github-username>/parkwhiz/fork )
38
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
39
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
40
+ 4. Push to the branch (`git push origin my-new-feature`)
41
+ 5. Create new Pull Request
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rspec/core/rake_task'
4
+ RSpec::Core::RakeTask.new('spec')
5
+ task :default => :spec
6
+ task :test => :spec
@@ -0,0 +1,13 @@
1
+ require 'parkwhiz/version'
2
+ require 'faraday'
3
+ require 'faraday_middleware'
4
+ require 'virtus'
5
+ require 'parkwhiz/errors'
6
+ require 'parkwhiz/configuration'
7
+ require 'parkwhiz/connection'
8
+ require 'parkwhiz/location'
9
+ require 'parkwhiz/search'
10
+
11
+ module Parkwhiz
12
+
13
+ end
@@ -0,0 +1,13 @@
1
+ module Parkwhiz
2
+ def self.configure
3
+ yield self
4
+ end
5
+
6
+ def self.api_key=(api_key)
7
+ @@api_key = api_key
8
+ end
9
+
10
+ def self.api_key
11
+ @@api_key
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ module Parkwhiz
2
+ def self.connection=(connection)
3
+ @connection = connection
4
+ end
5
+
6
+ def self.connection
7
+ @connection ||= Faraday.new(url: 'http://api.parkwhiz.com') do |faraday|
8
+ faraday.request :url_encoded # form-encode POST params
9
+ faraday.response :logger # log requests to STDOUT
10
+ faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
11
+ faraday.response :json
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,4 @@
1
+ module Parkwhiz
2
+ class SearchError < StandardError
3
+ end
4
+ end
@@ -0,0 +1,33 @@
1
+ module Parkwhiz
2
+ class Location
3
+ include Virtus.model
4
+ attribute :name, String
5
+ attribute :location_name, String
6
+ attribute :location_id, Integer
7
+ attribute :listing_id, Integer
8
+ attribute :parkwhiz_url, String
9
+ attribute :api_url, String
10
+ attribute :address, String
11
+ attribute :city, String
12
+ attribute :state, String
13
+ attribute :zip, String
14
+ attribute :lat, Float
15
+ attribute :lng, Float
16
+ attribute :distance, Integer
17
+ attribute :recommendations, Integer
18
+ attribute :reservation, Integer
19
+ attribute :eticket, Boolean
20
+ attribute :valet, Boolean
21
+ attribute :indoor, Boolean
22
+ attribute :shuttle, Boolean
23
+ attribute :tailgate, Boolean
24
+ attribute :security, Boolean
25
+ attribute :restroom, Boolean
26
+ attribute :attended, Boolean
27
+ attribute :rv, Boolean
28
+ attribute :available_spots, Integer
29
+ attribute :price, Float
30
+ attribute :www_reserve_url, String
31
+ attribute :api_reserve_url, String
32
+ end
33
+ end
@@ -0,0 +1,23 @@
1
+ module Parkwhiz
2
+
3
+ SEARCH_PATH = "/search/"
4
+
5
+ # Search
6
+ #
7
+ # Returns:
8
+ # Array of ParkWhiz::Location
9
+ #
10
+ # Endpoint: http://www.parkwhiz.com/developers/search/
11
+ #
12
+ def self.search(search_parameters)
13
+ response = connection.get do |request|
14
+ request.url SEARCH_PATH
15
+ request.params['key'] = api_key
16
+ request.params.merge!(search_parameters)
17
+ end
18
+
19
+ raise SearchError.new(response.body['error']) if response.body['error']
20
+
21
+ response.body['parking_listings'].collect{|parking_listing_json| Location.new(parking_listing_json)}
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ module Parkwhiz
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'parkwhiz/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "parkwhiz"
8
+ spec.version = Parkwhiz::VERSION
9
+ spec.authors = ["Austin Fonacier"]
10
+ spec.email = ["austinrf@gmail.com"]
11
+ spec.summary = "A Ruby gem wrapper to Parkwhiz.com's API"
12
+ spec.description = "A Ruby gem wrapper to Parkshiz.com's API. Information on the API can be found here: http://www.parkwhiz.com/developers/"
13
+ spec.homepage = "http://github.com/austinrfnd/parkwhiz"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.5"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency 'rspec', '~> 3.0.0'
24
+ spec.add_development_dependency 'json', '~> 1.8.1'
25
+ spec.add_dependency 'faraday'
26
+ spec.add_dependency 'virtus'
27
+ spec.add_dependency 'faraday_middleware'
28
+ end
@@ -0,0 +1,5 @@
1
+ describe "Location" do
2
+ it "should be kind of Parkwhiz::Location" do
3
+ expect(Parkwhiz::Location.new).to be_kind_of(Parkwhiz::Location)
4
+ end
5
+ end
@@ -0,0 +1 @@
1
+ {"error":"Key required. See documentation at http:\/\/www.parkwhiz.com\/developers\/"}
@@ -0,0 +1 @@
1
+ {"parkwhiz_url":"http:\/\/www.parkwhiz.com\/search\/?destination=Current+Location&start=1406161800&end=1406172600&pwa=ee51","lat":33.942809,"lng":-118.404706,"locations":2,"min_price":12,"max_price":13,"min_distance":4000,"max_distance":4750,"amenities":{"shuttle":2,"eticket":2,"perk":0,"valet":1,"indoor":0,"handicap":0,"restroom":0,"security":0,"tailgate":0,"rv":0,"unobstructed":1,"attended":2},"parking_listings":[{"location_name":"Sunrise Parking - LAX","location_id":4952,"listing_id":160981,"parkwhiz_url":"https:\/\/www.parkwhiz.com\/p\/los-angeles-parking\/6155-w-98th-st\/?start=1406161800&end=1406172600&pwa=ee51","api_url":"https:\/\/api.parkwhiz.com\/p\/los-angeles-parking\/6155-w-98th-st\/?start=1406161800&end=1406172600","address":"6155 W. 98th St.","city":"Los Angeles","state":"CA","zip":"90045","lat":33.947508845936,"lng":-118.39278131283,"distance":4000,"recommendations":0,"reservation":1,"eticket":1,"valet":0,"indoor":0,"shuttle":1,"tailgate":0,"security":0,"restroom":0,"attended":1,"rv":0,"available_spots":10,"price":12,"www_reserve_url":"https:\/\/www.parkwhiz.com\/reserve\/?id=160981&start=1406161800&end=1406172600&pwa=ee51","api_reserve_url":"https:\/\/api.parkwhiz.com\/reserve\/?id=160981&start=1406161800&end=1406172600&pwa=ee51"},{"location_name":"Crowne Plaza LAX","location_id":2409,"listing_id":4704,"parkwhiz_url":"https:\/\/www.parkwhiz.com\/p\/los-angeles-parking\/5985-w-century-blvd\/?start=1406161800&end=1406172600&pwa=ee51","api_url":"https:\/\/api.parkwhiz.com\/p\/los-angeles-parking\/5985-w-century-blvd\/?start=1406161800&end=1406172600","address":"5985 W. Century Blvd.","city":"Los Angeles","state":"CA","zip":"90045","lat":33.94644429732,"lng":-118.38965411178,"distance":4750,"recommendations":213,"reservation":1,"eticket":1,"valet":1,"indoor":0,"shuttle":1,"tailgate":0,"security":0,"restroom":0,"attended":1,"rv":0,"available_spots":10,"price":13,"www_reserve_url":"https:\/\/www.parkwhiz.com\/reserve\/?id=4704&start=1406161800&end=1406172600&pwa=ee51","api_reserve_url":"https:\/\/api.parkwhiz.com\/reserve\/?id=4704&start=1406161800&end=1406172600&pwa=ee51"}]}
@@ -0,0 +1,37 @@
1
+ describe "Search" do
2
+ let :connection do
3
+ double(:connection, get: nil)
4
+ end
5
+
6
+ let :la_search_response do
7
+ File.read(File.expand_path("spec/responses/la_search_response.json"))
8
+ end
9
+
10
+ let :invalid_search_response do
11
+ File.read(File.expand_path("spec/responses/invalid_key_response.json"))
12
+ end
13
+
14
+ before :each do
15
+ Parkwhiz.api_key = 'asdf1234'
16
+ end
17
+
18
+ context "on successful search" do
19
+ it "should return an array of Parkwhiz::Locations" do
20
+ expect(connection).to receive(:get) { double( body: JSON.parse(la_search_response) ) }
21
+ Parkwhiz.connection = connection
22
+ locations = Parkwhiz.search({})
23
+ expect(locations).to be_kind_of(Array)
24
+ expect(locations.first).to be_kind_of(Parkwhiz::Location)
25
+ end
26
+ end
27
+
28
+ context 'on error' do
29
+ it "should raise a Parkwhiz::SearchError" do
30
+ expect(connection).to receive(:get) { double( body: JSON.parse(invalid_search_response) ) }
31
+ Parkwhiz.connection = connection
32
+ expect do
33
+ Parkwhiz.search({})
34
+ end.to raise_error(Parkwhiz::SearchError)
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,2 @@
1
+ require 'parkwhiz'
2
+ require 'json'
metadata ADDED
@@ -0,0 +1,168 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: parkwhiz
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Austin Fonacier
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 3.0.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 3.0.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: json
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 1.8.1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 1.8.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: faraday
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: virtus
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: faraday_middleware
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: 'A Ruby gem wrapper to Parkshiz.com''s API. Information on the API can
112
+ be found here: http://www.parkwhiz.com/developers/'
113
+ email:
114
+ - austinrf@gmail.com
115
+ executables: []
116
+ extensions: []
117
+ extra_rdoc_files: []
118
+ files:
119
+ - ".gitignore"
120
+ - ".rspec"
121
+ - CHANGELOG.rdoc
122
+ - Gemfile
123
+ - LICENSE.txt
124
+ - README.md
125
+ - Rakefile
126
+ - lib/parkwhiz.rb
127
+ - lib/parkwhiz/configuration.rb
128
+ - lib/parkwhiz/connection.rb
129
+ - lib/parkwhiz/errors.rb
130
+ - lib/parkwhiz/location.rb
131
+ - lib/parkwhiz/search.rb
132
+ - lib/parkwhiz/version.rb
133
+ - parkwhiz.gemspec
134
+ - spec/location_spec.rb
135
+ - spec/responses/invalid_key_response.json
136
+ - spec/responses/la_search_response.json
137
+ - spec/search_spec.rb
138
+ - spec/spec_helper.rb
139
+ homepage: http://github.com/austinrfnd/parkwhiz
140
+ licenses:
141
+ - MIT
142
+ metadata: {}
143
+ post_install_message:
144
+ rdoc_options: []
145
+ require_paths:
146
+ - lib
147
+ required_ruby_version: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ required_rubygems_version: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ version: '0'
157
+ requirements: []
158
+ rubyforge_project:
159
+ rubygems_version: 2.2.2
160
+ signing_key:
161
+ specification_version: 4
162
+ summary: A Ruby gem wrapper to Parkwhiz.com's API
163
+ test_files:
164
+ - spec/location_spec.rb
165
+ - spec/responses/invalid_key_response.json
166
+ - spec/responses/la_search_response.json
167
+ - spec/search_spec.rb
168
+ - spec/spec_helper.rb