Class: Echelon::UniversalStudiosOrlando::Park

Inherits:
Park
  • Object
show all
Defined in:
lib/echelon/parks/universal_studios_orlando.rb

Direct Known Subclasses

IslandsOfAdventure, UniversalStudios

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Park

#find_by_id, #find_by_name, #rides

Constructor Details

#initialize(access_token, park_id) ⇒ Park

Returns a new instance of Park.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/echelon/parks/universal_studios_orlando.rb', line 66

def initialize(access_token, park_id)
  @park_id = park_id
  uri = URI.parse('https://services.universalorlando.com/api/pointsOfInterest')
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE

  headers = {
    'X-UNIWebService-ApiKey' => 'AndroidMobileApp',
    'X-UNIWebService-Token'  => access_token
  }.merge(SHARED_HEADERS)

  resp = http.get(uri.request_uri, headers)
  @json_data = JSON.parse(resp.body)
end

Instance Attribute Details

#json_dataObject (readonly)

Returns the value of attribute json_data.



59
60
61
# File 'lib/echelon/parks/universal_studios_orlando.rb', line 59

def json_data
  @json_data
end

#park_idObject (readonly)

Returns the value of attribute park_id.



59
60
61
# File 'lib/echelon/parks/universal_studios_orlando.rb', line 59

def park_id
  @park_id
end

Instance Method Details

#ride_listObject



61
62
63
64
# File 'lib/echelon/parks/universal_studios_orlando.rb', line 61

def ride_list
  park_rides = json_data['Rides'].keep_if { |r| r['VenueId'] == park_id }
  park_rides.inject({}) { |a, e| a[e['Id'].to_i] = e['MblDisplayName']; a }
end