park_info 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: dc828a45edca48d377b936afbaa9afed86203114b4791f0e516e562ffd8f216a
4
+ data.tar.gz: 48ecbcae8e7e5d3a9de74fde1c81641ea4ccb32cfc9bbb4b7380bb3e9a99a1fd
5
+ SHA512:
6
+ metadata.gz: 57d33e75ff3d763fb4b3b10efccb7f7eea1d4f7733039e51d3eed2b888a8c478b1ccb073e9ffda1e70b6b89b3ffa85b329a7021d69d5da6a6c6c96fafc68329d
7
+ data.tar.gz: b6f22370c32562cfdb30799166132f634dcc6c443c407175079c7fcf09d0f1df6ab9ac6964486f1a141c2a1591c1bf419784a68f5d2cd010b2520f7a78085f94
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 mnmlst-sftwr
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # Park Info
2
+
3
+ This is a *very* simple library to access information about theme parks.
4
+
5
+ Currently, it is only handling Disney parks, but I plan to add others quickly.
6
+
7
+ ## Installation
8
+ `gem install park_info`
9
+
10
+ ## Usage
11
+
12
+ ```
13
+ > require 'park_info'
14
+ => true
15
+
16
+ > mk = ParkInfo::DisneyWorld::MagicKingdom.new
17
+ => #<ParkInfo::DisneyWorld::MagicKingdom:0x007fefc7887f98>
18
+
19
+ > barnstormer = a.attractions[5]
20
+ => #<ParkInfo::DisneyAttraction:0x007fefc724bf30 @data=..."}>}>
21
+ > barnstormer.name
22
+ => "The Barnstormer"
23
+
24
+ > barnstormer.waitTime.keys
25
+ => ["fastPass", "status", "singleRider", "postedWaitMinutes", "rollUpStatus", "rollUpWaitTimeMessage"]
26
+
27
+ > barnstormer.waitTime.status
28
+ => "Operating"
29
+
30
+ > barnstormer.waitTime.postedWaitMinutes
31
+ => 20
32
+ ```
33
+
34
+ Currently, the data is cached locally for 5 minutes.
35
+
36
+ ## Supported Theme Parks
37
+
38
+ * Disney World Orlando
39
+ - Animal Kingdom (`ParkInfo::DisneyWorld::AnimalKingdom`)
40
+ - Epcot (`ParkInfo::DisneyWorld::Epcot`)
41
+ - Hollywood Studios (`ParkInfo::DisneyWorld::HollywoodStudios`)
42
+ - Magic Kingdom (`ParkInfo::DisneyWorld:MagicKingdom`)
43
+
@@ -0,0 +1,4 @@
1
+ require File.dirname(__FILE__) + '/disney_base'
2
+ require File.dirname(__FILE__) + '/disney_resort'
3
+ require File.dirname(__FILE__) + '/disney_attraction'
4
+ require File.dirname(__FILE__) + '/disney_world'
@@ -0,0 +1,22 @@
1
+ module ParkInfo
2
+ class DisneyAttraction < DisneyBase
3
+ attr_accessor :data
4
+
5
+ ID = nil
6
+
7
+ include ParkInfo::ActAsBag
8
+
9
+ def self.process(attractions)
10
+ attractions.map { |a| self.new(a) }
11
+ end
12
+
13
+ def initialize(data)
14
+ data.each do |key, val|
15
+ if val.is_a? Hash
16
+ data[key] = Bag.new(val)
17
+ end
18
+ end
19
+ @data = data
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,40 @@
1
+ module ParkInfo
2
+ class DisneyBase
3
+ TOKEN_URL = "https://authorization.go.com/token";
4
+ TOKEN_BODY = "grant_type=assertion&assertion_type=public&client_id=WDPRO-MOBILE.MDX.WDW.ANDROID-PROD";
5
+ APP_ID = "WDW-MDX-ANDROID-3.4.1";
6
+ BASE_URL = "https://api.wdpro.disney.go.com/";
7
+
8
+ REGION = nil
9
+
10
+ # How long to keep cached data, in seconds
11
+ CACHE_TIMEOUT = 5 * 60 # 5 minutes
12
+
13
+ def get_auth_token
14
+ resp = RestClient.post(TOKEN_URL, TOKEN_BODY)
15
+ data = JSON.parse(resp)
16
+ @auth_token = data['access_token']
17
+ end
18
+
19
+ def get(url_pattern, data={})
20
+ get_auth_token
21
+ headers = {
22
+ "Authorization" => "BEARER #{@auth_token}",
23
+ "Accept" => "application/json;apiversion=1",
24
+ "X-Conversation-Id" => "WDPRO-MOBILE.MDX.CLIENT-PROD",
25
+ "X-App-Id" => APP_ID,
26
+ "X-Correlation-ID" => Time.now(),
27
+ 'content_type' => 'json'
28
+ }
29
+ url = BASE_URL + url_pattern
30
+ data['region'] = region
31
+
32
+ resp = RestClient::Request.execute(method: :get, url: url, payload: data.to_json, headers: headers)
33
+ JSON.parse(resp)
34
+ end
35
+
36
+ def region
37
+ self.class::REGION
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,47 @@
1
+ module ParkInfo
2
+ class DisneyResort < DisneyBase
3
+ RESORT_ID = nil
4
+ PARK_ID = nil
5
+
6
+ include ParkInfo::ActAsBag
7
+
8
+ def wait_times
9
+ if wait_times_timed_out
10
+ url = "facility-service/theme-parks/#{park_id};destination=#{resort_id}/wait-times"
11
+ @data = get(url)
12
+ @wait_times_timeout = Time.now + CACHE_TIMEOUT
13
+ end
14
+ @data
15
+ end
16
+
17
+ def attractions
18
+ if wait_times_timed_out
19
+ wait_times
20
+ @attractions = ParkInfo::DisneyAttraction.process @data['entries']
21
+ end
22
+ @attractions
23
+ end
24
+
25
+ def facilities_info
26
+ url = "mobile-service/public/destinations/#{resort_id};entityType=destination/facilities?region=#{region}"
27
+ end
28
+
29
+ def resort_id
30
+ self.class::RESORT_ID
31
+ end
32
+
33
+ def park_id
34
+ self.class::PARK_ID
35
+ end
36
+
37
+ def region
38
+ self.class::REGION
39
+ end
40
+
41
+ protected
42
+
43
+ def wait_times_timed_out
44
+ @wait_times_timeout.nil? || Time.now > @wait_times_timeout
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,27 @@
1
+ module ParkInfo
2
+ class DisneyWorld
3
+ class AnimalKingdom < DisneyResort
4
+ RESORT_ID = "80007798"
5
+ PARK_ID = "80007823"
6
+ REGION = 'us'
7
+ end
8
+
9
+ class Epcot < DisneyResort
10
+ RESORT_ID = "80007798";
11
+ PARK_ID = "80007838";
12
+ REGION = "us";
13
+ end
14
+
15
+ class HollywoodStudios < DisneyResort
16
+ RESORT_ID = "80007798";
17
+ PARK_ID = "80007998";
18
+ REGION = "us";
19
+ end
20
+
21
+ class MagicKingdom < DisneyResort
22
+ RESORT_ID = "80007798";
23
+ PARK_ID = "80007944";
24
+ REGION = "us";
25
+ end
26
+ end
27
+ end
data/lib/park_info.rb ADDED
@@ -0,0 +1,36 @@
1
+ require 'json'
2
+ require 'rest-client'
3
+
4
+ require File.dirname(__FILE__) + '/version'
5
+
6
+ module ParkInfo
7
+ module ActAsBag
8
+ def method_missing(method_name, *args, &block)
9
+ if @data && @data.has_key?(method_name.to_s)
10
+ @data[method_name.to_s]
11
+ else
12
+ super
13
+ end
14
+ end
15
+
16
+ def keys
17
+ @data.nil? ? [] : @data.keys
18
+ end
19
+ end
20
+
21
+ class Bag
22
+ include ActAsBag
23
+
24
+ def initialize(data)
25
+ data.each do |key, val|
26
+ if val.is_a? Hash
27
+ data[key] = Bag.new(val)
28
+ end
29
+ end
30
+ @data = data
31
+ end
32
+ end
33
+
34
+ end
35
+
36
+ require File.dirname(__FILE__) + '/disney/disney'
data/lib/version.rb ADDED
@@ -0,0 +1,3 @@
1
+ module ParkInfo
2
+ VERSION = "0.5.1"
3
+ end
metadata ADDED
@@ -0,0 +1,55 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: park_info
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.1
5
+ platform: ruby
6
+ authors:
7
+ - Bryan Fordham
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-06-07 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: |2
14
+ <p>This is a *very* simple library to access information about theme parks.</p>
15
+
16
+ <p>Currently, it is only handling Disney parks, but I plan to add others quickly.</p>
17
+ email: bfordham@gmail.com
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - LICENSE
23
+ - README.md
24
+ - lib/disney/disney.rb
25
+ - lib/disney/disney_attraction.rb
26
+ - lib/disney/disney_base.rb
27
+ - lib/disney/disney_resort.rb
28
+ - lib/disney/disney_world.rb
29
+ - lib/park_info.rb
30
+ - lib/version.rb
31
+ homepage: https://github.com/mnmlst-sftwr/park-info
32
+ licenses:
33
+ - MIT
34
+ metadata: {}
35
+ post_install_message:
36
+ rdoc_options: []
37
+ require_paths:
38
+ - lib
39
+ required_ruby_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ required_rubygems_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ requirements: []
50
+ rubyforge_project:
51
+ rubygems_version: 2.7.7
52
+ signing_key:
53
+ specification_version: 4
54
+ summary: Simple library to get theme park information, including Disney.
55
+ test_files: []