class Echelon::UniversalStudiosOrlando

Constants

KEY
SECRET
SHARED_HEADERS

Attributes

access_token[R]
expires_at[R]

Public Class Methods

new() click to toggle source
# File lib/echelon/parks/universal_studios_orlando.rb, line 27
def initialize
  uri = URI.parse('https://services.universalorlando.com/api')
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE

  # time is UTC, but their server expects to be told it's GMT
  date = Time.now.utc.strftime("%a, %d %b %Y %H:%M:%S GMT")
  digest = OpenSSL::HMAC.digest('sha256', SECRET, "#{KEY}\n#{date}\n")
  signature = Base64.encode64(digest).strip.gsub(/\=$/, "\u003d")
  params = { apikey: 'AndroidMobileApp', signature: signature }.to_json

  headers = {
    'Date'         => date,
    'Content-Type' => 'application/json; charset=UTF-8'
  }.merge(SHARED_HEADERS)

  resp = http.post(uri.path, params, headers)
  gzip = Zlib::GzipReader.new(StringIO.new(resp.body))
  data = JSON.parse(gzip.read)
  @access_token = data['Token']
  @expires_at = DateTime.parse(data['TokenExpirationString']).to_time
end

Public Instance Methods

islands_of_adventure() click to toggle source
# File lib/echelon/parks/universal_studios_orlando.rb, line 51
def islands_of_adventure
  @islands_of_adventure ||= UniversalStudiosOrlando::IslandsOfAdventure.new(access_token)
end
universal_studios() click to toggle source
# File lib/echelon/parks/universal_studios_orlando.rb, line 55
def universal_studios
  @universal_studios ||= UniversalStudiosOrlando::UniversalStudios.new(access_token)
end