touringplans 0.2.6 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 73b59b67226a12fe4d77223e9068c45928359062571a0c0571a769a6b22c3df2
4
- data.tar.gz: 40253a1085b837c4a99bec95d70ce9f79c75f189f3461acd463ad7edce8d9307
3
+ metadata.gz: 9a1f5173ae5122387ff736c9330ecdf98d29307d3839276179f74d25fe734d55
4
+ data.tar.gz: 832f6fc645e19986c3cced3e7b84695ecc7f7a68fb4d1ea84082811a0cde02b7
5
5
  SHA512:
6
- metadata.gz: 605df55c3dc98501e5892af6e9b3a6ec6d02a95048973fae82b66c80ba2626e93f4dd2253dd1f2a1db5388b84ed9785a5ca9270fb327f01adf728cd39c738921
7
- data.tar.gz: 86e2240776b188df0128d40cfc4ef9ddb108ea609bc91a0f4493fc4cfc0cd8ce09b7746ee9f3eb8e3d6bf3526163143bae2249412d5d94e15363f2142b3e1787
6
+ metadata.gz: 910c19291ef5eb840fa9d437c1d90ab39841d95b9ce4dd622c408ab39e10aa177f782820b97dabfbd19915cada6ddf6051d033a758150fe030cf1167d33f0803
7
+ data.tar.gz: d1ae5e6902c623fc6326901a9b23bf624914b33d467aded6dab9ae3824d7fd19539aee9503e3d9ca83db74d735ae45ea070f62c4590952bdcaa84de78af1900b
data/.version CHANGED
@@ -1 +1 @@
1
- 0.2.6
1
+ 0.3.5
data/lib/routes.yml CHANGED
@@ -419,6 +419,9 @@ epcot_attractions_mission_space_orange:
419
419
  epcot_attractions_reflections_of_china:
420
420
  method: get
421
421
  path: "/epcot/attractions/reflections-of-china.json"
422
+ epcot_attractions_remys_ratatouille_adventure:
423
+ method: get
424
+ path: "/epcot/attractions/remys-ratatouille-adventure.json"
422
425
  epcot_attractions_the_seas_main_tank_and_exhibits:
423
426
  method: get
424
427
  path: "/epcot/attractions/the-seas-main-tank-and-exhibits.json"
@@ -800,3 +803,117 @@ hollywood_studios_dining_roundup_rodeo_bbq:
800
803
  hollywood_studios_dining_scifi_dine_in_theater_restaurant:
801
804
  method: get
802
805
  path: "/hollywood-studios/dining/scifi-dine-in-theater-restaurant.json"
806
+ walt_disney_world_hotels_fort_wilderness_campsites:
807
+ method: get
808
+ path: "/walt-disney-world/hotels/fort-wilderness-campsites.json"
809
+ walt_disney_world_hotels_disneys_animal_kingdom_lodge:
810
+ method: get
811
+ path: "/walt-disney-world/hotels/disneys-animal-kingdom-lodge.json"
812
+ walt_disney_world_hotels_disneys_beach_club_resort:
813
+ method: get
814
+ path: "/walt-disney-world/hotels/disneys-beach-club-resort.json"
815
+ walt_disney_world_hotels_disneys_boardwalk_inn:
816
+ method: get
817
+ path: "/walt-disney-world/hotels/disneys-boardwalk-inn.json"
818
+ walt_disney_world_hotels_disneys_contemporary_resort:
819
+ method: get
820
+ path: "/walt-disney-world/hotels/disneys-contemporary-resort.json"
821
+ walt_disney_world_hotels_disneys_grand_floridian_resort:
822
+ method: get
823
+ path: "/walt-disney-world/hotels/disneys-grand-floridian-resort.json"
824
+ walt_disney_world_hotels_disneys_polynesian_resort:
825
+ method: get
826
+ path: "/walt-disney-world/hotels/disneys-polynesian-resort.json"
827
+ walt_disney_world_hotels_disneys_wilderness_lodge:
828
+ method: get
829
+ path: "/walt-disney-world/hotels/disneys-wilderness-lodge.json"
830
+ walt_disney_world_hotels_disneys_yacht_club_resort:
831
+ method: get
832
+ path: "/walt-disney-world/hotels/disneys-yacht-club-resort.json"
833
+ walt_disney_world_hotels_shades_of_green_at_walt_disney_world:
834
+ method: get
835
+ path: "/walt-disney-world/hotels/shades-of-green-at-walt-disney-world.json"
836
+ walt_disney_world_hotels_star_wars_galactic_starcruiser:
837
+ method: get
838
+ path: "/walt-disney-world/hotels/star-wars-galactic-starcruiser.json"
839
+ walt_disney_world_hotels_dolphin_at_walt_disney_world:
840
+ method: get
841
+ path: "/walt-disney-world/hotels/dolphin-at-walt-disney-world.json"
842
+ walt_disney_world_hotels_swan_at_walt_disney_world:
843
+ method: get
844
+ path: "/walt-disney-world/hotels/swan-at-walt-disney-world.json"
845
+ walt_disney_world_hotels_disney_world_swan_reserve:
846
+ method: get
847
+ path: "/walt-disney-world/hotels/disney-world-swan-reserve.json"
848
+ walt_disney_world_hotels_bay_lake_tower_at_disneys_contemporary_resort:
849
+ method: get
850
+ path: "/walt-disney-world/hotels/bay-lake-tower-at-disneys-contemporary-resort.json"
851
+ walt_disney_world_hotels_disneys_wilderness_lodge_villas:
852
+ method: get
853
+ path: "/walt-disney-world/hotels/disneys-wilderness-lodge-villas.json"
854
+ walt_disney_world_hotels_copper_creek_villas:
855
+ method: get
856
+ path: "/walt-disney-world/hotels/copper-creek-villas.json"
857
+ walt_disney_world_hotels_animal_kingdom_villas_jambo:
858
+ method: get
859
+ path: "/walt-disney-world/hotels/animal-kingdom-villas-jambo.json"
860
+ walt_disney_world_hotels_disneys_animal_kingdom_villas:
861
+ method: get
862
+ path: "/walt-disney-world/hotels/disneys-animal-kingdom-villas.json"
863
+ walt_disney_world_hotels_disneys_beach_club_villas:
864
+ method: get
865
+ path: "/walt-disney-world/hotels/disneys-beach-club-villas.json"
866
+ walt_disney_world_hotels_disneys_boardwalk_villas:
867
+ method: get
868
+ path: "/walt-disney-world/hotels/disneys-boardwalk-villas.json"
869
+ walt_disney_world_hotels_disneys_old_key_west_resort:
870
+ method: get
871
+ path: "/walt-disney-world/hotels/disneys-old-key-west-resort.json"
872
+ walt_disney_world_hotels_disneys_polynesian_villas_bungalows:
873
+ method: get
874
+ path: "/walt-disney-world/hotels/disneys-polynesian-villas-bungalows.json"
875
+ walt_disney_world_hotels_disneys_riviera_resort:
876
+ method: get
877
+ path: "/walt-disney-world/hotels/disneys-riviera-resort.json"
878
+ walt_disney_world_hotels_disneys_saratoga_springs_resort_spa:
879
+ method: get
880
+ path: "/walt-disney-world/hotels/disneys-saratoga-springs-resort-spa.json"
881
+ walt_disney_world_hotels_disney_reflections:
882
+ method: get
883
+ path: "/walt-disney-world/hotels/disney-reflections.json"
884
+ walt_disney_world_hotels_the_villas_at_disneys_grand_floridian_resort_and_spa:
885
+ method: get
886
+ path: "/walt-disney-world/hotels/the-villas-at-disneys-grand-floridian-resort-and-spa.json"
887
+ walt_disney_world_hotels_treehouse_villas_at_disneys_saratoga_springs_resort:
888
+ method: get
889
+ path: "/walt-disney-world/hotels/treehouse-villas-at-disneys-saratoga-springs-resort.json"
890
+ walt_disney_world_hotels_disneys_caribbean_beach_resort:
891
+ method: get
892
+ path: "/walt-disney-world/hotels/disneys-caribbean-beach-resort.json"
893
+ walt_disney_world_hotels_disneys_coronado_springs_resort:
894
+ method: get
895
+ path: "/walt-disney-world/hotels/disneys-coronado-springs-resort.json"
896
+ walt_disney_world_hotels_disneys_port_orleans_resort_french_quarter:
897
+ method: get
898
+ path: "/walt-disney-world/hotels/disneys-port-orleans-resort-french-quarter.json"
899
+ walt_disney_world_hotels_disneys_port_orleans_resort_riverside:
900
+ method: get
901
+ path: "/walt-disney-world/hotels/disneys-port-orleans-resort-riverside.json"
902
+ walt_disney_world_hotels_fort_wilderness_resort_cabins:
903
+ method: get
904
+ path: "/walt-disney-world/hotels/fort-wilderness-resort-cabins.json"
905
+ walt_disney_world_hotels_disneys_all_star_movies_resort:
906
+ method: get
907
+ path: "/walt-disney-world/hotels/disneys-all-star-movies-resort.json"
908
+ walt_disney_world_hotels_disneys_all_star_music_resort:
909
+ method: get
910
+ path: "/walt-disney-world/hotels/disneys-all-star-music-resort.json"
911
+ walt_disney_world_hotels_disneys_all_star_sports_resort:
912
+ method: get
913
+ path: "/walt-disney-world/hotels/disneys-all-star-sports-resort.json"
914
+ walt_disney_world_hotels_disneys_art_of_animation_resort:
915
+ method: get
916
+ path: "/walt-disney-world/hotels/disneys-art-of-animation-resort.json"
917
+ walt_disney_world_hotels_disneys_pop_century_resort:
918
+ method: get
919
+ path: "/walt-disney-world/hotels/disneys-pop-century-resort.json"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Touringplans
4
- VERSION = "0.2.6"
4
+ VERSION = "0.3.5"
5
5
  end
data/lib/touringplans.rb CHANGED
@@ -12,14 +12,6 @@ module Touringplans
12
12
  include Dry.Types()
13
13
  end
14
14
 
15
- include HTTParty
16
- # currently Touring Plans has no verision in its API
17
- DEFAULT_API_VERSION = "1"
18
- DEFAULT_BASE_URI = "https://touringplans.com/"
19
- DEFAULT_QUERY = {}
20
-
21
- base_uri DEFAULT_BASE_URI
22
-
23
15
  ROUTES = {
24
16
  magic_kingdom_dining: {
25
17
  method: "get",
@@ -80,13 +72,13 @@ module Touringplans
80
72
  walt_disney_world_disney_springs_resorts: {
81
73
  method: "get",
82
74
  path: "/walt-disney-world/hotels.json"
83
- },
84
- }
75
+ }
76
+ }.freeze
85
77
 
86
78
  def self.routes
87
79
  ROUTES
88
80
  end
89
-
81
+
90
82
  # deals solely with how to create access to the resource, the lock of "lock & key"
91
83
  class Connection
92
84
  # concerned only on where it gets the info it needs
@@ -96,6 +88,7 @@ module Touringplans
96
88
  # currently Touring Plans has no verision in its API
97
89
  DEFAULT_API_VERSION = "1"
98
90
  DEFAULT_BASE_URI = "https://touringplans.com/"
91
+ # do not freeze DEFAULT_QUERY
99
92
  DEFAULT_QUERY = {}
100
93
 
101
94
  base_uri DEFAULT_BASE_URI
@@ -158,12 +151,13 @@ module Touringplans
158
151
  end
159
152
  end
160
153
 
154
+ # Generates and updates routes for all types of venues in a YAML document.
161
155
  class RoutesTable
162
- require 'fileutils'
163
- def initialize(filename: "routes_table.yml")
164
- @filename = filename
156
+ require "fileutils"
157
+ def initialize(filename: "routes_table.yml")
158
+ @filename = filename
165
159
  end
166
-
160
+
167
161
  def self.original_routes
168
162
  # this method exists so that we can create a yaml file of routes
169
163
  tpr = Touringplans.routes
@@ -177,9 +171,9 @@ module Touringplans
177
171
  # # create new hash with string keys
178
172
  # string_keys.zip(rt_values).to_h
179
173
  end
180
-
174
+
181
175
  def self.symbolize_keys(hash)
182
- hash.inject({}){|result, (key, value)|
176
+ hash.each_with_object({}) do |(key, value), result|
183
177
  new_key = case key
184
178
  when String then key.to_sym
185
179
  else key
@@ -189,13 +183,12 @@ module Touringplans
189
183
  else value
190
184
  end
191
185
  result[new_key] = new_value
192
- result
193
- }
186
+ end
194
187
  end
195
188
 
196
189
  def self.stringify_keys(hash)
197
190
  # inspired by https://avdi.codes/recursively-symbolize-keys/
198
- hash.inject({}){|result, (key, value)|
191
+ hash.each_with_object({}) do |(key, value), result|
199
192
  new_key = case key
200
193
  when Symbol then key.to_s
201
194
  else key
@@ -205,21 +198,20 @@ module Touringplans
205
198
  else value
206
199
  end
207
200
  result[new_key] = new_value
208
- result
209
- }
210
- end
201
+ end
202
+ end
211
203
 
212
- def self.load_routes_file(relative_file_path: "/lib/routes.yml")
213
- routes_file = FileUtils.getwd() + relative_file_path
214
- YAML.load(File.read(routes_file))
204
+ def self.load_routes_file(routes_relative_file_path: "/routes.yml")
205
+ tp_path = $LOAD_PATH.grep(/touringplans/).last
206
+ routes_file = "#{tp_path}#{routes_relative_file_path}"
207
+ YAML.safe_load(File.read(routes_file))
215
208
  end
216
-
217
-
209
+
218
210
  def self.update_file
219
211
  # gather info into hashes
220
212
  attractions_routes = _generate_interest_routes_hash("attractions")
221
213
  dining_routes = _generate_interest_routes_hash("dining")
222
- hotels_routes = {} #_generate_interest_routes_hash("hotels")
214
+ hotels_routes = _generate_interest_routes_hash("hotels")
223
215
  updated_routes = original_routes.merge(attractions_routes, dining_routes, hotels_routes)
224
216
 
225
217
  updated_routes_yaml = _convert_hash_to_yaml(updated_routes)
@@ -230,12 +222,13 @@ module Touringplans
230
222
 
231
223
  def self._initialize_file
232
224
  # delete old file if it exits
233
- lib_dir = FileUtils.getwd() + "/lib"
225
+ lib_dir = FileUtils.getwd + "/lib"
234
226
  routes_file = "#{lib_dir}/routes.yml"
235
227
 
236
228
  # ensure the file exists
237
229
  touched_routes_file_array = FileUtils.touch(routes_file)
238
- touched_routes_file = touched_routes_file_array.first
230
+ # we want the first string value
231
+ touched_routes_file_array.first
239
232
  end
240
233
 
241
234
  def self._generate_interest_routes_hash(interest)
@@ -243,7 +236,7 @@ module Touringplans
243
236
  interest_routes = {}
244
237
 
245
238
  interest_venues.each do |iv|
246
- new_route = self._generate_interest_route(iv.venue_permalink, interest, iv.permalink)
239
+ new_route = _generate_interest_route(iv.venue_permalink, interest, iv.permalink)
247
240
  key = new_route.keys.first
248
241
  values = new_route[key]
249
242
  interest_routes[key] = values
@@ -251,7 +244,7 @@ module Touringplans
251
244
 
252
245
  interest_routes
253
246
  end
254
-
247
+
255
248
  def self._generate_interest_route(venue_permalink, interest_permalink, place_permalink)
256
249
  # {magic_kingdom_attractions_haunted_mansion: {
257
250
  # method: "get",
@@ -264,12 +257,8 @@ module Touringplans
264
257
  method = "get"
265
258
  format = "json"
266
259
 
267
- hash = { key => { "method".to_s => "get",
268
- "path".to_s => "#{path}.#{format}"
269
- }
270
- }
271
-
272
- hash
260
+ { key => { "method".to_s => method,
261
+ "path".to_s => "#{path}.#{format}" } }
273
262
  end
274
263
 
275
264
  def self._convert_hash_to_yaml(hash)
@@ -281,13 +270,13 @@ module Touringplans
281
270
  new_file.write(content)
282
271
  new_file.close
283
272
  end
284
-
273
+
285
274
  def self._read_file_to_terminal(file)
286
275
  new_file = File.open(file, "r")
287
276
  new_file.close
288
277
  end
289
-
290
278
  end
279
+
291
280
  # model with the attributes
292
281
  class CounterServiceLocation < Dry::Struct
293
282
  transform_keys(&:to_sym)
@@ -347,7 +336,7 @@ module Touringplans
347
336
  attribute :kosher_available, Types::Params::Bool
348
337
  attribute :dinable_id, Types::Params::Integer
349
338
  attribute :dinable_type, Types::String.optional
350
- attribute :venue_permalink, Types::String.optional
339
+ attribute :venue_permalink, Types::String.optional
351
340
  end
352
341
 
353
342
  # model with the attributes
@@ -380,11 +369,11 @@ module Touringplans
380
369
  attribute :house_specialties, Types::String.optional
381
370
  attribute :counter_quality_rating, Types::String.optional
382
371
  attribute :counter_value_rating, Types::String.optional
383
- attribute :table_quality_rating, Types::Params::Decimal.optional
384
- attribute :table_value_rating, Types::Params::Decimal.optional
385
- attribute :overall_rating, Types::Params::Decimal.optional
386
- attribute :service_rating, Types::Params::Decimal.optional
387
- attribute :friendliness_rating, Types::Params::Decimal.optional
372
+ attribute :table_quality_rating, Types::Params::Float.optional
373
+ attribute :table_value_rating, Types::Params::Float.optional
374
+ attribute :overall_rating, Types::Params::Float.optional
375
+ attribute :service_rating, Types::Params::Float.optional
376
+ attribute :friendliness_rating, Types::Params::Float.optional
388
377
  attribute :adult_breakfast_menu_url, Types::String.optional
389
378
  attribute :adult_lunch_menu_url, Types::String.optional
390
379
  attribute :adult_dinner_menu_url, Types::String.optional
@@ -412,6 +401,69 @@ module Touringplans
412
401
  attribute :venue_permalink, Types::String.optional
413
402
  end
414
403
 
404
+ # model with the attributes
405
+ class DiningVenueFull < Dry::Struct
406
+ transform_keys(&:to_sym)
407
+
408
+ attribute :name, Types::String
409
+ attribute :permalink, Types::String
410
+ attribute :category_code, Types::String
411
+ attribute :portion_size, Types::String.optional
412
+ attribute :cost_code, Types::String.optional
413
+ attribute :cuisine, Types::String
414
+ attribute :phone_number, Types::String.optional
415
+ attribute :entree_range, Types::String.optional
416
+ attribute :when_to_go, Types::String.optional
417
+ attribute :parking, Types::String.optional
418
+ attribute :bar, Types::String.optional
419
+ attribute :wine_list, Types::String.optional
420
+ attribute :dress, Types::String.optional
421
+ attribute :awards, Types::String.optional
422
+ attribute :breakfast_hours, Types::String.optional
423
+ attribute :lunch_hours, Types::String.optional
424
+ attribute :dinner_hours, Types::String.optional
425
+ attribute :house_specialties, Types::String.optional
426
+ attribute :counter_quality_rating, Types::String.optional
427
+ attribute :counter_value_rating, Types::String.optional
428
+ attribute :table_quality_rating, Types::Float.optional
429
+ attribute :table_value_rating, Types::Float.optional
430
+ attribute :overall_rating, Types::Float.optional
431
+ attribute :service_rating, Types::Float.optional
432
+ attribute :friendliness_rating, Types::Float.optional
433
+ attribute :adult_breakfast_menu_url, Types::String.optional
434
+ attribute :adult_lunch_menu_url, Types::String.optional
435
+ attribute :adult_dinner_menu_url, Types::String.optional
436
+ attribute :child_breakfast_menu_url, Types::String.optional
437
+ attribute :child_lunch_menu_url, Types::String.optional
438
+ attribute :child_dinner_menu_url, Types::String.optional
439
+ attribute :requires_credit_card, Types::Params::Bool
440
+ attribute :requires_pre_payment, Types::Params::Bool
441
+ attribute :created_at, Types::Params::DateTime
442
+ attribute :updated_at, Types::Params::DateTime
443
+ attribute :extinct_on, Types::Params::DateTime.optional
444
+ attribute :opened_on, Types::Params::DateTime.optional
445
+ attribute :disney_permalink, Types::String.optional
446
+ attribute :code, Types::String.optional
447
+ attribute :short_name, Types::String.optional
448
+ attribute :accepts_reservations, Types::Params::Bool
449
+ attribute :kosher_available, Types::Params::Bool
450
+ attribute :operator_id, Types::Coercible::Integer.optional
451
+ attribute :operator_url, Types::String.optional
452
+ attribute :operator_type, Types::String.optional
453
+ attribute :walking_time_proxy_id, Types::Integer.optional
454
+ attribute :sort_name, Types::String.optional
455
+ attribute :mobile_ordering, Types::Bool.optional
456
+ attribute :extinct_on_uncertain, Types::String.optional
457
+ attribute :opened_on_uncertain, Types::String.optional
458
+ attribute :opened_on_known, Types::String.optional
459
+ attribute :operational_notes, Types::String.optional
460
+ attribute :latitude, Types::String.optional
461
+ attribute :longitude, Types::String.optional
462
+ attribute :summary_at_top, Types::Bool.optional
463
+
464
+ end
465
+
466
+
415
467
  # model with the attributes
416
468
  class ParkAttraction < Dry::Struct
417
469
  transform_keys(&:to_sym)
@@ -420,7 +472,91 @@ module Touringplans
420
472
  attribute :short_name, Types::String
421
473
  attribute :permalink, Types::String
422
474
  attribute :venue_permalink, Types::String
423
-
475
+ end
476
+
477
+ # model with the attributes
478
+ class ParkAttractionFull < Dry::Struct
479
+ transform_keys(&:to_sym)
480
+
481
+ attribute :name, Types::String
482
+ attribute :fastpass_booth, Types::Bool
483
+ attribute :short_name, Types::String.optional
484
+ attribute :created_at, Types::Params::DateTime
485
+ attribute :updated_at, Types::Params::DateTime
486
+ attribute :open_emh_morning, Types::Bool
487
+ attribute :open_emh_evening, Types::Bool
488
+ attribute :single_rider, Types::Bool
489
+ attribute :time_zone, Types::String.optional
490
+ attribute :seasonal, Types::Bool
491
+ attribute :open_very_merry, Types::Bool
492
+ attribute :open_not_so_scary, Types::Bool
493
+ attribute :category_code, Types::String.optional
494
+ attribute :duration, Types::Float.optional
495
+ attribute :scheduled_code, Types::String.optional
496
+ attribute :what_it_is, Types::String.optional
497
+ attribute :scope_and_scale_code, Types::String.optional
498
+ attribute :when_to_go, Types::String.optional
499
+ attribute :average_wait_per_hundred, Types::Float.optional
500
+ attribute :average_wait_assumes, Types::String.optional
501
+ attribute :loading_speed, Types::String.optional
502
+ attribute :probable_wait_time, Types::String.optional
503
+ attribute :special_needs, Types::String.optional
504
+ attribute :height_restriction, Types::Coercible::Integer.optional
505
+ attribute :intense, Types::Bool
506
+ attribute :extinct_on, Types::Params::DateTime.optional
507
+ attribute :opened_on, Types::Params::DateTime.optional
508
+ attribute :frightening, Types::Bool
509
+ attribute :physical_considerations, Types::Bool
510
+ attribute :handheld_captioning, Types::Bool
511
+ attribute :video_captioning, Types::Bool
512
+ attribute :reflective_captioning, Types::Bool
513
+ attribute :assistive_listening, Types::Bool
514
+ attribute :audio_description, Types::Bool
515
+ attribute :wheelchair_transfer_code, Types::String.optional
516
+ attribute :no_service_animals, Types::Bool
517
+ attribute :sign_language, Types::Bool
518
+ attribute :service_animal_check, Types::Bool
519
+ attribute :not_to_be_missed, Types::Bool
520
+ attribute :rider_swap, Types::Bool
521
+ attribute :ultimate_code, Types::String.optional
522
+ attribute :ultimate_task, Types::String.optional
523
+ attribute :park_entrance, Types::Bool
524
+ # attribute :relative_open, Types::Float.optional
525
+ # attribute :relative_close, Types::Bool.optional
526
+ attribute :close_at_dusk, Types::Bool.optional
527
+ attribute :crowd_calendar_version, Types::Integer
528
+ attribute :match_name, Types::String.optional
529
+ attribute :crazy_threshold, Types::Integer.optional
530
+ attribute :fastpass_only, Types::Bool
531
+ attribute :allow_showtimes_after_close, Types::Bool
532
+ attribute :disconnected_fastpass_booth, Types::Bool
533
+ attribute :arrive_before, Types::Integer.optional
534
+ attribute :arrive_before_fp, Types::Integer.optional
535
+ attribute :allow_time_restriction, Types::Bool
536
+ attribute :relative_open_to_sunset, Types::Integer.optional
537
+ attribute :relative_close_to_sunset, Types::Integer.optional
538
+ attribute :closing_round_code, Types::String.optional
539
+ attribute :walking_time_proxy_id, Types::Integer.optional
540
+ # attribute :flexible_duration, Types::Bool
541
+ attribute :operator_id, Types::Coercible::Integer.optional
542
+ attribute :operator_type, Types::String.optional
543
+ attribute :hide_app, Types::Bool
544
+ attribute :showtime_proxy_id, Types::Integer.optional
545
+ attribute :sort_name, Types::String
546
+ attribute :extinct_on_uncertain, Types::Bool.optional
547
+ attribute :opened_on_uncertain, Types::Bool.optional
548
+ attribute :ignore_scrapes, Types::Bool.optional
549
+ attribute :extra_cost, Types::Bool
550
+ attribute :climate_controlled, Types::Bool
551
+ attribute :wet, Types::Bool.optional
552
+ attribute :operational_notes, Types::String.optional
553
+ # attribute :masthead_circle_x, Types::Integer
554
+ # attribute :masthead_circle_y, Types::Integer
555
+ attribute :latitude, Types::String.optional
556
+ attribute :longitude, Types::String.optional
557
+ attribute :open_early, Types::Bool
558
+ attribute :themeparks_entity_id, Types::String.optional
559
+ attribute :has_virtual_queue, Types::Bool
424
560
  end
425
561
 
426
562
  # model with the attributes
@@ -434,49 +570,78 @@ module Touringplans
434
570
  attribute :venue_permalink, Types::String.optional
435
571
  end
436
572
 
437
- PLACE_KEYS = %i[magic_kingdom
438
- animal_kingdom
439
- epcot
440
- hollywood_studios
441
- walt_disney_world
442
- ].freeze
443
- # {interest:"interest_type"}
444
- INTERESTS = %i[counter_services
445
- table_services
446
- attractions
447
- hotels
448
- campground
449
- deluxe_hotels
450
- deluxe_villas
451
- moderate_hotels
452
- value_hotels
453
- disney_springs_resorts
454
- ].freeze
455
- HOTEL_CATEGORIES = %i[campground
456
- deluxe_hotels
457
- deluxe_villas
458
- moderate_hotels
459
- value_hotels
460
- disney_springs_resorts]
573
+ # model with the attributes
574
+ class HotelFull < Dry::Struct
575
+ transform_keys(&:to_sym)
576
+
577
+ attribute :name, Types::Coercible::String
578
+ attribute :address, Types::Coercible::String.optional
579
+ attribute :city, Types::Coercible::String.optional
580
+ attribute :state_code, Types::Coercible::String.optional
581
+ attribute :zip_code, Types::Coercible::String.optional
582
+ attribute :phone_number, Types::Coercible::String.optional
583
+ attribute :url, Types::Coercible::String.optional
584
+ attribute :off_site, Types::Bool
585
+ attribute :water_sports, Types::Bool
586
+ attribute :marina, Types::Bool
587
+ attribute :beach, Types::Bool
588
+ attribute :tennis, Types::Bool
589
+ attribute :biking, Types::Bool
590
+ attribute :suites, Types::Bool
591
+ attribute :concierge_floor, Types::Bool
592
+ attribute :room_service, Types::Bool
593
+ attribute :wired_internet, Types::Bool
594
+ attribute :wireless_internet, Types::Bool
595
+ attribute :num_rooms, Types::Coercible::Integer
596
+ attribute :theme, Types::Coercible::String.optional
597
+ attribute :cost_range, Types::Coercible::String.optional
598
+ attribute :shuttle_to_parks, Types::Bool
599
+ attribute :cost_estimate, Types::Coercible::String.optional
600
+ attribute :lodging_area_code, Types::Coercible::String.optional
601
+ attribute :category_code, Types::Coercible::String.optional
602
+ end
603
+
604
+ PLACE_KEYS = %i[magic_kingdom
605
+ animal_kingdom
606
+ epcot
607
+ hollywood_studios
608
+ walt_disney_world].freeze
609
+ # {interest:"interest_type"}
610
+ INTERESTS = %i[counter_services
611
+ table_services
612
+ dining
613
+ attractions
614
+ hotels
615
+ campground
616
+ deluxe_hotels
617
+ deluxe_villas
618
+ moderate_hotels
619
+ value_hotels
620
+ disney_springs_resorts].freeze
621
+ HOTEL_CATEGORIES = %i[campground
622
+ deluxe_hotels
623
+ deluxe_villas
624
+ moderate_hotels
625
+ value_hotels
626
+ disney_springs_resorts].freeze
461
627
 
462
628
  # list interest at location
463
629
  # current interest are "counter service" "table service", and "attractions"
464
630
  # current locations are the four parks
465
631
  def self.list(interest, location)
466
632
  return "The location is not on Disney property" unless PLACE_KEYS.include? _symbolize(location)
467
- return "The interest is not valid" unless INTERESTS.include? _symbolize(interest)
633
+ return "The interest is not valid" unless INTERESTS.include? _symbolize(interest)
468
634
 
469
635
  client = _setup_client
470
636
  listings = []
471
637
  interest_type = _determine_interest_type(interest)
472
- route = _assemble_route(location, interest_type)
638
+ route = _assemble_route(location, interest_type, "list")
473
639
  response = client.send(route).parsed_response
474
640
  listing_hashes = _collect_listing_hashes_from_response(interest, response)
475
641
  listing_hashes.each do |item|
476
- item["venue_permalink"] = location.to_s.downcase.gsub(" ", "-")
642
+ item["venue_permalink"] = location.to_s.downcase.gsub(" ", "-").gsub("_", "-")
477
643
  end
478
644
 
479
- listing_hashes
480
645
  listing_hashes.each do |hash|
481
646
  listing = _set_model_from_hash(interest, hash)
482
647
  listings << listing
@@ -519,22 +684,22 @@ module Touringplans
519
684
  places.flatten
520
685
  end
521
686
 
522
- def self.show(interest_type, short_name)
523
- return "The interest_type is not valid" unless %i[dining attractions hotels].include? _symbolize(interest_type)
524
-
525
- # get a list of every model of one kind of interest_type (dining, attractions, hotels)
526
- places = list_all(interest_type)
687
+ def self.show(place, interest_type, permalink)
688
+ # see specs for examples
689
+ return "The location is not on Disney property" unless PLACE_KEYS.include? _symbolize(place)
690
+ return "The interest_type is not valid" unless INTERESTS.include? _symbolize(interest_type)
527
691
 
528
- # filter by short_name
529
- places.find { |place| place.short_name == short_name }
692
+ client = _setup_client
693
+ route = _assemble_route(place, interest_type, permalink)
694
+ response = client.send(route).parsed_response
695
+ _set_model_from_hash(interest_type, response)
530
696
  end
531
697
 
532
698
  def self._setup_client
533
699
  connection = Connection.new
534
700
  connection.query(key: "HowdyLen")
535
- routes = Touringplans::RoutesTable.symbolize_keys(Touringplans::RoutesTable.load_routes_file)
701
+ routes = Touringplans::RoutesTable.symbolize_keys(Touringplans::RoutesTable.load_routes_file)
536
702
  Client.new(connection: connection, routes: routes)
537
-
538
703
  end
539
704
 
540
705
  def self._format_location_name(location_name)
@@ -546,8 +711,7 @@ module Touringplans
546
711
 
547
712
  interest_type = "dining" if interest == "counter services"
548
713
  interest_type = "dining" if interest == "table services"
549
- interest_type = "hotels" if %i[campground deluxe_hotels deluxe_villas moderate_hotels value_hotels disney_springs_resorts
550
- ].include? _symbolize(interest)
714
+ interest_type = "hotels" if %i[campground deluxe_hotels deluxe_villas moderate_hotels value_hotels disney_springs_resorts].include? _symbolize(interest)
551
715
 
552
716
  interest_type
553
717
  end
@@ -561,11 +725,16 @@ module Touringplans
561
725
  str.to_sym
562
726
  end
563
727
 
564
-
565
- def self._assemble_route(location, interest_type)
566
- formatted_location = location.to_s.downcase.gsub(" ", "_")
567
- formatted_interest_type = interest_type.to_s.downcase.gsub(" ", "_")
568
- "#{formatted_location}_#{formatted_interest_type}"
728
+ def self._assemble_route(collection, interest_type, venue)
729
+ # format route
730
+ collection = collection.to_s.downcase.gsub(" ", "_").gsub("-", "_")
731
+ interest_type = interest_type.to_s.downcase.gsub(" ", "_").gsub("-", "_")
732
+ venue = venue.to_s.downcase.gsub(" ", "_").gsub("-", "_")
733
+
734
+ route = [collection, interest_type, venue].join("_")
735
+ route = [collection, interest_type].join("_") if venue == "list"
736
+
737
+ route
569
738
  end
570
739
 
571
740
  def self._collect_listing_hashes_from_response(interest, response)
@@ -581,15 +750,13 @@ module Touringplans
581
750
 
582
751
  listing_hashes
583
752
  end
584
-
753
+
585
754
  def self.list_all_hotels(response_from_touringplans_hotels_url)
586
755
  listing_hashes = []
587
756
 
588
757
  response_from_touringplans_hotels_url.each do |child|
589
758
  child.each do |grandchild|
590
- if "#{grandchild.class}" == "Array"
591
- listing_hashes << grandchild
592
- end
759
+ listing_hashes << grandchild if grandchild.class.to_s == "Array"
593
760
  end
594
761
  end
595
762
 
@@ -597,39 +764,43 @@ module Touringplans
597
764
  end
598
765
 
599
766
  # search for hotels of a category_code
600
- def self.list_hotels_of_a_category(hotels, interest)
601
- hotel_categories = {campground:"campground", deluxe_hotels:"deluxe",
602
- deluxe_villas:"deluxe_villa", moderate_hotels:"moderate",
603
- value_hotels:"value", disney_springs_resorts: NilClass}
767
+ def self.list_hotels_of_a_category(hotels, interest)
768
+ hotel_categories = { campground: "campground", deluxe_hotels: "deluxe",
769
+ deluxe_villas: "deluxe_villa", moderate_hotels: "moderate",
770
+ value_hotels: "value", disney_springs_resorts: NilClass }
604
771
  # get a list of every hotel model
605
772
 
606
773
  # filter by category_code
607
- # disney springs category code is null. We need to find a rule for finding those that don't have any of the values of
774
+ # disney springs category code is null. We need to find a rule for finding those that don't have any of the values of
608
775
  # hotel categories
609
776
  if interest == "disney springs resorts"
610
- target_hotels = hotels.find_all { |hotel| hotel.category_code.class == NilClass }
611
-
777
+ hotels.find_all { |hotel| hotel.category_code.instance_of?(NilClass) }
778
+
612
779
  else
613
- target_hotels = hotels.find_all { |hotel| hotel.category_code == hotel_categories[_symbolize(interest)] }
614
-
615
- end
780
+ hotels.find_all { |hotel| hotel.category_code == hotel_categories[_symbolize(interest)] }
616
781
 
617
- target_hotels
782
+ end
618
783
  end
619
-
784
+
620
785
  def generate_route_table
621
786
  # initial_routes = ROUTES
622
-
623
787
  end
624
-
625
-
788
+
626
789
  def self._set_model_from_hash(interest, hash)
627
790
  hotel_categories = %i[campground deluxe_hotels deluxe_villas moderate_hotels value_hotels disney_springs_resorts hotels]
628
791
 
629
- listing = CounterServiceLocation.new(hash) if interest == "counter services"
630
- listing = TableServiceLocation.new(hash) if interest == "table services"
631
- listing = ParkAttraction.new(hash) if interest == "attractions"
632
- listing = Hotel.new(hash) if hotel_categories.include? _symbolize(interest)
792
+ if hash["permalink"].to_s.length > 1
793
+ listing = CounterServiceLocation.new(hash) if interest == "counter services"
794
+ listing = TableServiceLocation.new(hash) if interest == "table services"
795
+ listing = ParkAttraction.new(hash) if interest == "attractions"
796
+ listing = DiningVenueFull.new(hash) if interest == "dining"
797
+ listing = Hotel.new(hash) if hotel_categories.include? _symbolize(interest)
798
+ else
799
+ listing = DiningVenueFull.new(hash) if interest == "dining"
800
+ listing = ParkAttractionFull.new(hash) if interest == "attractions"
801
+ listing = HotelFull.new(hash) if hotel_categories.include? _symbolize(interest)
802
+ end
803
+
633
804
  listing
634
805
  end
635
806
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: touringplans
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - captproton
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-13 00:00:00.000000000 Z
11
+ date: 2021-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_print