campgrounds 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +48 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +40 -0
- data/LICENSE.txt +22 -0
- data/README.md +64 -0
- data/Rakefile +7 -0
- data/campgrounds.gemspec +30 -0
- data/lib/campgrounds/base.rb +35 -0
- data/lib/campgrounds/campground_details.rb +26 -0
- data/lib/campgrounds/campground_search.rb +218 -0
- data/lib/campgrounds/campsite_search.rb +138 -0
- data/lib/campgrounds/version.rb +3 -0
- data/lib/campgrounds.rb +20 -0
- data/pkg/campgrounds-0.0.1.gem +0 -0
- data/spec/fixtures/campgrounds_cassettes/campground_details.yml +231 -0
- data/spec/fixtures/campgrounds_cassettes/campground_search.yml +1556 -0
- data/spec/fixtures/campgrounds_cassettes/campground_search_added.yml +1465 -0
- data/spec/fixtures/campgrounds_cassettes/campground_search_find.yml +87157 -0
- data/spec/fixtures/campgrounds_cassettes/campsite_search.yml +3930 -0
- data/spec/fixtures/campgrounds_cassettes/campsite_search_find.yml +3131 -0
- data/spec/lib/campgrounds/base_spec.rb +10 -0
- data/spec/lib/campgrounds/campground_details_spec.rb +47 -0
- data/spec/lib/campgrounds/campground_search_spec.rb +127 -0
- data/spec/lib/campgrounds/campsite_search_spec.rb +125 -0
- data/spec/spec_helper.rb +16 -0
- metadata +217 -0
data/.rvmrc
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# This is an RVM Project .rvmrc file, used to automatically load the ruby
|
4
|
+
# development environment upon cd'ing into the directory
|
5
|
+
|
6
|
+
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
|
7
|
+
# Only full ruby name is supported here, for short names use:
|
8
|
+
# echo "rvm use 1.9.3" > .rvmrc
|
9
|
+
environment_id="ruby-1.9.3-p194@campgrounds"
|
10
|
+
|
11
|
+
# Uncomment the following lines if you want to verify rvm version per project
|
12
|
+
# rvmrc_rvm_version="1.14.10 (stable)" # 1.10.1 seams as a safe start
|
13
|
+
# eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
|
14
|
+
# echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
|
15
|
+
# return 1
|
16
|
+
# }
|
17
|
+
|
18
|
+
# First we attempt to load the desired environment directly from the environment
|
19
|
+
# file. This is very fast and efficient compared to running through the entire
|
20
|
+
# CLI and selector. If you want feedback on which environment was used then
|
21
|
+
# insert the word 'use' after --create as this triggers verbose mode.
|
22
|
+
if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
|
23
|
+
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
|
24
|
+
then
|
25
|
+
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
26
|
+
[[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
|
27
|
+
\. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
|
28
|
+
else
|
29
|
+
# If the environment file has not yet been created, use the RVM CLI to select.
|
30
|
+
rvm --create "$environment_id" || {
|
31
|
+
echo "Failed to create RVM environment '${environment_id}'."
|
32
|
+
return 1
|
33
|
+
}
|
34
|
+
fi
|
35
|
+
|
36
|
+
# If you use bundler, this might be useful to you:
|
37
|
+
# if [[ -s Gemfile ]] && {
|
38
|
+
# ! builtin command -v bundle >/dev/null ||
|
39
|
+
# builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
|
40
|
+
# }
|
41
|
+
# then
|
42
|
+
# printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
|
43
|
+
# gem install bundler
|
44
|
+
# fi
|
45
|
+
# if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
|
46
|
+
# then
|
47
|
+
# bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
|
48
|
+
# fi
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
campgrounds (0.0.1)
|
5
|
+
geokit
|
6
|
+
hashie (~> 1)
|
7
|
+
rest-client
|
8
|
+
xml-simple
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
addressable (2.3.2)
|
14
|
+
ansi (1.4.3)
|
15
|
+
crack (0.3.1)
|
16
|
+
geokit (1.6.5)
|
17
|
+
multi_json
|
18
|
+
hashie (1.2.0)
|
19
|
+
mime-types (1.19)
|
20
|
+
multi_json (1.3.6)
|
21
|
+
rake (0.9.2.2)
|
22
|
+
rest-client (1.6.7)
|
23
|
+
mime-types (>= 1.16)
|
24
|
+
turn (0.9.6)
|
25
|
+
ansi
|
26
|
+
vcr (2.2.5)
|
27
|
+
webmock (1.8.11)
|
28
|
+
addressable (>= 2.2.7)
|
29
|
+
crack (>= 0.1.7)
|
30
|
+
xml-simple (1.1.1)
|
31
|
+
|
32
|
+
PLATFORMS
|
33
|
+
ruby
|
34
|
+
|
35
|
+
DEPENDENCIES
|
36
|
+
campgrounds!
|
37
|
+
rake
|
38
|
+
turn
|
39
|
+
vcr
|
40
|
+
webmock
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Tamera Mitchell
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# Campgrounds
|
2
|
+
|
3
|
+
This is a ruby wrapper for the Active Network [campground API](http://developer.active.com/docs/read/Campground_APIs).
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'campgrounds'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install campgrounds
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
If you haven't already, you'll need to [create an account](http://developer.active.com/member/register) with Active Network to get an API key.
|
22
|
+
|
23
|
+
For details on the various methods and parameters available, see the comments in the lib/campground files.
|
24
|
+
|
25
|
+
## Examples
|
26
|
+
|
27
|
+
campground = Campgrounds.client('yourkey')
|
28
|
+
|
29
|
+
#### Campground Search
|
30
|
+
Returns campgrounds matching a set of filters.
|
31
|
+
|
32
|
+
Get all campgrounds:
|
33
|
+
|
34
|
+
campground.campground_search.all()
|
35
|
+
|
36
|
+
Get campgrounds in Colorado with sites for trailers, water hookups, and fishing nearby:
|
37
|
+
|
38
|
+
campground.campground_search.find({:pstate => 'CO', :siteType => "trailer", :water => true, :amenity => 'fishing'})
|
39
|
+
|
40
|
+
Get campgrounds within 50 miles of Boulder, CO that allow pets:
|
41
|
+
|
42
|
+
campground.campground_search.find_by_address("boulder, co", 50, {:pets => true})
|
43
|
+
|
44
|
+
|
45
|
+
#### Campground Details
|
46
|
+
|
47
|
+
Get the details on a particular campground:
|
48
|
+
|
49
|
+
campground.campground_details.find({:contractCode => 'CO', :parkId => '50032'})
|
50
|
+
|
51
|
+
|
52
|
+
#### Campsite Search
|
53
|
+
|
54
|
+
Get any sites in a particular campground that are pull-through and offer amp hookups with 20 amps or more:
|
55
|
+
|
56
|
+
campground.campsite_search.find({:contractCode => 'CO', :parkId => '50032', :pull => true, :hookups => "20+"})
|
57
|
+
|
58
|
+
## Contributing
|
59
|
+
|
60
|
+
1. Fork it
|
61
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
62
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
63
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
64
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/campgrounds.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'campgrounds/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "campgrounds"
|
8
|
+
gem.version = Campgrounds::VERSION
|
9
|
+
gem.authors = ["Tami Mitchell"]
|
10
|
+
gem.email = ["mail@tamimitchell.com"]
|
11
|
+
gem.description = %q{Provide a wrapper for the Active Network campground API}
|
12
|
+
gem.summary = %q{Provide data on campgrounds in Reserve America's database via the Active Network campground API}
|
13
|
+
gem.homepage = ""
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_runtime_dependency 'hashie', '~> 1'
|
21
|
+
gem.add_runtime_dependency 'rest-client'
|
22
|
+
gem.add_runtime_dependency 'xml-simple'
|
23
|
+
gem.add_runtime_dependency 'geokit'
|
24
|
+
|
25
|
+
# testing
|
26
|
+
gem.add_development_dependency 'webmock'
|
27
|
+
gem.add_development_dependency 'vcr'
|
28
|
+
gem.add_development_dependency 'turn'
|
29
|
+
gem.add_development_dependency 'rake'
|
30
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Campgrounds
|
2
|
+
class Base
|
3
|
+
include GeoKit::Geocoders
|
4
|
+
|
5
|
+
attr_accessor :api_key
|
6
|
+
|
7
|
+
def initialize(api_key)
|
8
|
+
@api_key = api_key
|
9
|
+
end
|
10
|
+
|
11
|
+
def campground_search
|
12
|
+
@campground_search ||= Campgrounds::CampgroundSearch.new(@api_key)
|
13
|
+
end
|
14
|
+
|
15
|
+
def campground_details
|
16
|
+
@campground_details ||= Campgrounds::CampgroundDetails.new(@api_key)
|
17
|
+
end
|
18
|
+
|
19
|
+
def campsite_search
|
20
|
+
@campsite_search ||= Campgrounds::CampsiteSearch.new(@api_key)
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
# private
|
25
|
+
|
26
|
+
def query(path, options={})
|
27
|
+
base_uri = 'http://api.amp.active.com/camping'
|
28
|
+
options['api_key'] = @api_key
|
29
|
+
url = base_uri + path
|
30
|
+
xml = RestClient.get url, {:params => options}
|
31
|
+
data = XmlSimple.xml_in(xml.to_s, { 'KeyAttr' => 'name' })
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Campgrounds
|
2
|
+
class CampgroundDetails < Base
|
3
|
+
|
4
|
+
Path = '/campground/details'
|
5
|
+
|
6
|
+
# This find method is here only for consitency of method names at this point. May add more features later.
|
7
|
+
def find(options={})
|
8
|
+
query(Path, options)
|
9
|
+
end
|
10
|
+
|
11
|
+
# Call the Campground Details API, open to use it's default parameters.
|
12
|
+
#
|
13
|
+
# Required Parameters
|
14
|
+
# -------------------
|
15
|
+
#
|
16
|
+
# contractCode:
|
17
|
+
# "contractCode" is a syonym for contractID, which is what is returned by the Campground Search API. It specifies the jurisdiction for the campground. This parameter must be used in conjuction with parkId.
|
18
|
+
#
|
19
|
+
# parkId: Facility ID
|
20
|
+
# "parkId" is a synonym for "facilityID", which is returned by the Campground Search API. It is a unique identifier for the campground.
|
21
|
+
def request(options={})
|
22
|
+
query(Path, options)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,218 @@
|
|
1
|
+
module Campgrounds
|
2
|
+
class CampgroundSearch < Base
|
3
|
+
|
4
|
+
Path = '/campgrounds'
|
5
|
+
|
6
|
+
# Retrieve all campgrounds.
|
7
|
+
def all
|
8
|
+
query(Path)
|
9
|
+
end
|
10
|
+
|
11
|
+
# A cleaned up version of the request method below. Updated to use strings or boolean values instead of varius numbers.
|
12
|
+
#
|
13
|
+
# Optional Parameters
|
14
|
+
# -------------------
|
15
|
+
# landmarkLat:
|
16
|
+
# landmarkLong: These two parameters allow for campground searches around a fixed geo-point.
|
17
|
+
#
|
18
|
+
# siteType:
|
19
|
+
# If unspecified, all site types are returned.
|
20
|
+
# "rv": RV Sites
|
21
|
+
# "cabin": Cabins or Lodgings
|
22
|
+
# "tent": Tent
|
23
|
+
# "trailer": Trailer
|
24
|
+
# "group": Group Site
|
25
|
+
# "day": Day Use
|
26
|
+
# "horse": Horse Site
|
27
|
+
# "boat": Boat Site
|
28
|
+
#
|
29
|
+
# pstate: The two character abbreviation for US state, Canadian province or territory
|
30
|
+
# pname: Park Name
|
31
|
+
# arvDate: Arrival Date
|
32
|
+
# lengthOfStay: When combined with arvDate, this parameter determines how long the camper would like to reserve the campground.
|
33
|
+
#
|
34
|
+
# amenity:
|
35
|
+
# Campground Feature. Only one amenity can be specified per query. Specifying amenity=4004, for example, returns campgrounds with fishing.
|
36
|
+
# Biking 4001
|
37
|
+
# Boating 4002
|
38
|
+
# Equipment Rental 4003
|
39
|
+
# Fishing 4004
|
40
|
+
# Golf 4005
|
41
|
+
# Hiking 4006
|
42
|
+
# Horseback Riding 4007
|
43
|
+
# Hunting 4008
|
44
|
+
# Recreational Activities 4009
|
45
|
+
# Scenic Trails 4010
|
46
|
+
# Sports 4011
|
47
|
+
# Beach/Water Activities 4012
|
48
|
+
# Winter Activities 4013
|
49
|
+
#
|
50
|
+
# eqpLen: Equipment Length
|
51
|
+
# maxPeople: Number of campers
|
52
|
+
#
|
53
|
+
# The following params seem to search correctly, though the results such as 'sitesWithAmps' may not return the expected results. It looks like some people put this info in the description field rather than the various Y/N fields.
|
54
|
+
# hookup: Electric Hookup
|
55
|
+
# "15+": 15 Amps or More
|
56
|
+
# "20+": 20 Amps or More
|
57
|
+
# "30+": 30 Amps or More
|
58
|
+
# "50+": 50 Amps or More
|
59
|
+
#
|
60
|
+
# water: Water Hookup. Boolean.
|
61
|
+
# sewer: Sewer Hookup. Boolean.
|
62
|
+
# pull: Pull Through Driveway. Boolean.
|
63
|
+
# pets: Pets Allowed. Boolean.
|
64
|
+
# waterfront: Waterfront Sites. Boolean.
|
65
|
+
def find(options={})
|
66
|
+
case options[:siteType]
|
67
|
+
when "rv"
|
68
|
+
options[:siteType] = 2001
|
69
|
+
when "cabin"
|
70
|
+
options[:siteType] = 10001
|
71
|
+
when "tent"
|
72
|
+
options[:siteType] = 2003
|
73
|
+
when "trailer"
|
74
|
+
options[:siteType] = 2002
|
75
|
+
when "group"
|
76
|
+
options[:siteType] = 9002
|
77
|
+
when "day"
|
78
|
+
options[:siteType] = 9001
|
79
|
+
when "horse"
|
80
|
+
options[:siteType] = 3001
|
81
|
+
when "boat"
|
82
|
+
options[:siteType] = 2004
|
83
|
+
end
|
84
|
+
|
85
|
+
case options[:amenity]
|
86
|
+
when "biking"
|
87
|
+
options[:amenity] = 4001
|
88
|
+
when "boating"
|
89
|
+
options[:amenity] = 4002
|
90
|
+
when "equipment rental"
|
91
|
+
options[:amenity] = 4003
|
92
|
+
when "fishing"
|
93
|
+
options[:amenity] = 4004
|
94
|
+
when "golf"
|
95
|
+
options[:amenity] = 4005
|
96
|
+
when "hiking"
|
97
|
+
options[:amenity] = 4006
|
98
|
+
when "horseback riding"
|
99
|
+
options[:amenity] = 4007
|
100
|
+
when "hunting"
|
101
|
+
options[:amenity] = 4008
|
102
|
+
when "recreational activities"
|
103
|
+
options[:amenity] = 4009
|
104
|
+
when "scenic trails"
|
105
|
+
options[:amenity] = 4010
|
106
|
+
when "sports"
|
107
|
+
options[:amenity] = 4011
|
108
|
+
when "beach/water activities"
|
109
|
+
options[:amenity] = 4012
|
110
|
+
when "winter activities"
|
111
|
+
options[:amenity] = 4013
|
112
|
+
end
|
113
|
+
|
114
|
+
case options[:hookup]
|
115
|
+
when "15+"
|
116
|
+
options[:hookup] = 3002
|
117
|
+
when "20+"
|
118
|
+
options[:hookup] = 3003
|
119
|
+
when "30+"
|
120
|
+
options[:hookup] = 3004
|
121
|
+
when "50+"
|
122
|
+
options[:hookup] = 3005
|
123
|
+
end
|
124
|
+
|
125
|
+
options[:water] = 3006 if options[:water]
|
126
|
+
options[:sewer] = 3007 if options[:sewer]
|
127
|
+
options[:pull] = 3008 if options[:pull]
|
128
|
+
options[:pets] = 3010 if options[:pets]
|
129
|
+
options[:waterfront] = 3011 if options[:waterfront]
|
130
|
+
|
131
|
+
# Might return results array at some point, but returning the wrapper for now to keep results similar to default.
|
132
|
+
return query(Path, options)
|
133
|
+
end
|
134
|
+
|
135
|
+
# Search for campgrounds with an address string and optional range in miles. The address could be a street address, city and state, etc.
|
136
|
+
# Uses the find method so you can pass strings/booleans
|
137
|
+
def find_by_address(address, range=1000, options={})
|
138
|
+
coords = MultiGeocoder.geocode(address)
|
139
|
+
options[:landmarkName] = true
|
140
|
+
options[:landmarkLat] = coords.lat
|
141
|
+
options[:landmarkLong] = coords.lng
|
142
|
+
|
143
|
+
results = find(options)
|
144
|
+
|
145
|
+
results['result'].each do |c|
|
146
|
+
lat = c['latitude']
|
147
|
+
long = c['longitude']
|
148
|
+
c['distance'] = coords.distance_to([lat,long])
|
149
|
+
end
|
150
|
+
results['result'].delete_if {|k, v| k['distance'] >= range }
|
151
|
+
|
152
|
+
return results
|
153
|
+
end
|
154
|
+
|
155
|
+
# Call the Campground Search API, open to use it's default parameters.
|
156
|
+
#
|
157
|
+
# Optional Parameters
|
158
|
+
# -------------------
|
159
|
+
#
|
160
|
+
# landmarkLat:
|
161
|
+
# landmarkLong: These two parameters allow for campground searches around a fixed geo-point.
|
162
|
+
#
|
163
|
+
# siteType:
|
164
|
+
# If unspecified, all site types are returned.
|
165
|
+
# RV Sites 2001
|
166
|
+
# Cabins or Lodgings 10001
|
167
|
+
# Tent 2003
|
168
|
+
# Trailer 2002
|
169
|
+
# Group Site 9002
|
170
|
+
# Day Use 9001
|
171
|
+
# Horse Site 3001
|
172
|
+
# Boat Site 2004
|
173
|
+
#
|
174
|
+
# pstate: The two character abbreviation for US state, Canadian province or territory
|
175
|
+
# pname: Park Name
|
176
|
+
# arvdate: Arrival Date
|
177
|
+
# lengthOfStay: When combined with arvdate, this parameter determines how long the camper would like to reserve the campground.
|
178
|
+
#
|
179
|
+
# amenity:
|
180
|
+
# Campground Feature. Only one amenity can be specified per query. Specifying amenity=4004, for example, returns campgrounds with fishing.
|
181
|
+
# Biking 4001
|
182
|
+
# Boating 4002
|
183
|
+
# Equipment Rental 4003
|
184
|
+
# Fishing 4004
|
185
|
+
# Golf 4005
|
186
|
+
# Hiking 4006
|
187
|
+
# Horseback Riding 4007
|
188
|
+
# Hunting 4008
|
189
|
+
# Recreational Activities 4009
|
190
|
+
# Scenic Trails 4010
|
191
|
+
# Sports 4011
|
192
|
+
# Beach/Water Activities 4012
|
193
|
+
# Winter Activities 4013
|
194
|
+
#
|
195
|
+
# eqlen: Equipment Length
|
196
|
+
# Maxpeople: Number of campers
|
197
|
+
#
|
198
|
+
# hookup: Electric Hookup
|
199
|
+
# 15 Amps or More 3002
|
200
|
+
# 20 Amps or More 3003
|
201
|
+
# 30 Amps or More 3004
|
202
|
+
# 50 Amps or More 3005
|
203
|
+
#
|
204
|
+
# water: Water Hookup. Specify &water=3007 to search for campgrounds with water hookups.
|
205
|
+
# sewer: Sewer Hookup. Specify &sewer=3007 to search for campgrounds with sewer hookups.
|
206
|
+
# pull: Pull Through Driveway. Specify &pull=3008 to search for campgrounds with pull through driveways.
|
207
|
+
# pets: Pets Allowed. Specify &pets=3010 to search for campgrounds where pets are allowed.
|
208
|
+
# waterfront: Waterfront Sites. Specify &waterfront=3011 to search for campgrounds with waterfront campsites.
|
209
|
+
|
210
|
+
|
211
|
+
def request(options={})
|
212
|
+
query(Path, options)
|
213
|
+
end
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
end
|
218
|
+
end
|
@@ -0,0 +1,138 @@
|
|
1
|
+
module Campgrounds
|
2
|
+
class CampsiteSearch < Base
|
3
|
+
|
4
|
+
Path = '/campsites'
|
5
|
+
|
6
|
+
|
7
|
+
# A cleaned up version of the request method below. Updated to use strings or boolean values instead of varius numbers.
|
8
|
+
# Required Parameters
|
9
|
+
# -------------------
|
10
|
+
#
|
11
|
+
# contractCode:
|
12
|
+
# "contractCode" is a syonym for contractID, which is what is returned by the Campground Search API. It specifies the jurisdiction for the campground. This parameter must be used in conjuction with parkId.
|
13
|
+
#
|
14
|
+
# parkId: Facility ID
|
15
|
+
# "parkId" is a synonym for "facilityID", which is returned by the Campground Search API. It is a unique identifier for the campground.
|
16
|
+
#
|
17
|
+
#
|
18
|
+
# Optional Parameters
|
19
|
+
# -------------------
|
20
|
+
# siteType:
|
21
|
+
# If unspecified, all site types are returned.
|
22
|
+
# "rv": RV Sites
|
23
|
+
# "cabin": Cabins or Lodgings
|
24
|
+
# "tent": Tent
|
25
|
+
# "trailer": Trailer
|
26
|
+
# "group": Group Site
|
27
|
+
# "day": Day Use
|
28
|
+
# "horse": Horse Site
|
29
|
+
# "boat": Boat Site
|
30
|
+
#
|
31
|
+
# arvDate: Arrival Date
|
32
|
+
# lengthOfStay: When combined with arvDate, this parameter determines how long the camper would like to reserve the campground.
|
33
|
+
# eqpLen: Equipment Length
|
34
|
+
# maxPeople: Number of campers
|
35
|
+
#
|
36
|
+
# hookup: Electric Hookup
|
37
|
+
# "15+": 15 Amps or More
|
38
|
+
# "20+": 20 Amps or More
|
39
|
+
# "30+": 30 Amps or More
|
40
|
+
# "50+": 50 Amps or More
|
41
|
+
#
|
42
|
+
# water: Water Hookup. Boolean.
|
43
|
+
# sewer: Sewer Hookup. Boolean.
|
44
|
+
# pull: Pull Through Driveway. Boolean.
|
45
|
+
# pets: Pets Allowed. Boolean.
|
46
|
+
# waterfront: Waterfront Sites. Boolean.
|
47
|
+
def find(options={})
|
48
|
+
case options[:siteType]
|
49
|
+
when "rv"
|
50
|
+
options[:siteType] = 2001
|
51
|
+
when "cabin"
|
52
|
+
options[:siteType] = 10001
|
53
|
+
when "tent"
|
54
|
+
options[:siteType] = 2003
|
55
|
+
when "trailer"
|
56
|
+
options[:siteType] = 2002
|
57
|
+
when "group"
|
58
|
+
options[:siteType] = 9002
|
59
|
+
when "day"
|
60
|
+
options[:siteType] = 9001
|
61
|
+
when "horse"
|
62
|
+
options[:siteType] = 3001
|
63
|
+
when "boat"
|
64
|
+
options[:siteType] = 2004
|
65
|
+
end
|
66
|
+
|
67
|
+
case options[:hookup]
|
68
|
+
when "15+"
|
69
|
+
options[:hookup] = 3002
|
70
|
+
when "20+"
|
71
|
+
options[:hookup] = 3003
|
72
|
+
when "30+"
|
73
|
+
options[:hookup] = 3004
|
74
|
+
when "50+"
|
75
|
+
options[:hookup] = 3005
|
76
|
+
end
|
77
|
+
|
78
|
+
options[:water] = 3006 if options[:water]
|
79
|
+
options[:sewer] = 3007 if options[:sewer]
|
80
|
+
options[:pull] = 3008 if options[:pull]
|
81
|
+
options[:pets] = 3010 if options[:pets]
|
82
|
+
options[:waterfront] = 3011 if options[:waterfront]
|
83
|
+
|
84
|
+
# Might return results array at some point, but returning the wrapper for now to keep results similar to default.
|
85
|
+
return query(Path, options)
|
86
|
+
end
|
87
|
+
|
88
|
+
# Call the Campsite Search API, open to use it's default parameters.
|
89
|
+
#
|
90
|
+
# Required Parameters
|
91
|
+
# -------------------
|
92
|
+
#
|
93
|
+
# contractCode:
|
94
|
+
# "contractCode" is a syonym for contractID, which is what is returned by the Campground Search API. It specifies the jurisdiction for the campground. This parameter must be used in conjuction with parkId.
|
95
|
+
#
|
96
|
+
# parkId: Facility ID
|
97
|
+
# "parkId" is a synonym for "facilityID", which is returned by the Campground Search API. It is a unique identifier for the campground.
|
98
|
+
#
|
99
|
+
#
|
100
|
+
# Optional Parameters
|
101
|
+
# -------------------
|
102
|
+
# siteType:
|
103
|
+
# If unspecified, all site types are returned.
|
104
|
+
# RV Sites 2001
|
105
|
+
# Cabins or Lodgings 10001
|
106
|
+
# Tent 2003
|
107
|
+
# Trailer 2002
|
108
|
+
# Group Site 9002
|
109
|
+
# Day Use 9001
|
110
|
+
# Horse Site 3001
|
111
|
+
# Boat Site 2004
|
112
|
+
#
|
113
|
+
# arvDate: Arrival Date
|
114
|
+
# lengthOfStay: When combined with arvdate, this parameter determines how long the camper would like to reserve the campground.
|
115
|
+
# eqpLen: Equipment Length
|
116
|
+
# maxPeople: Number of campers
|
117
|
+
#
|
118
|
+
# hookup: Electric Hookup
|
119
|
+
# 15 Amps or More 3002
|
120
|
+
# 20 Amps or More 3003
|
121
|
+
# 30 Amps or More 3004
|
122
|
+
# 50 Amps or More 3005
|
123
|
+
#
|
124
|
+
# water: Water Hookup. Specify &water=3006 to search for campgrounds with water hookups.
|
125
|
+
# sewer: Sewer Hookup. Specify &sewer=3007 to search for campgrounds with sewer hookups.
|
126
|
+
# pull: Pull Through Driveway. Specify &pull=3008 to search for campgrounds with pull through driveways.
|
127
|
+
# pets: Pets Allowed. Specify &pets=3010 to search for campgrounds where pets are allowed.
|
128
|
+
# waterfront: Waterfront Sites. Specify &waterfront=3011 to search for campgrounds with waterfront campsites.
|
129
|
+
|
130
|
+
|
131
|
+
def request(options={})
|
132
|
+
query(Path, options)
|
133
|
+
end
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
end
|
138
|
+
end
|
data/lib/campgrounds.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require "campgrounds/version"
|
2
|
+
|
3
|
+
require 'hashie'
|
4
|
+
require 'xmlsimple'
|
5
|
+
require 'rest_client'
|
6
|
+
require 'geokit'
|
7
|
+
|
8
|
+
require_relative 'campgrounds/base.rb'
|
9
|
+
require_relative 'campgrounds/campground_search.rb'
|
10
|
+
require_relative 'campgrounds/campground_details.rb'
|
11
|
+
require_relative 'campgrounds/campsite_search'
|
12
|
+
|
13
|
+
module Campgrounds
|
14
|
+
|
15
|
+
class << self
|
16
|
+
def client(key)
|
17
|
+
Campgrounds::Base.new(key)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
Binary file
|