Class: ParkInfo::DisneyBase

Inherits:
Object
  • Object
show all
Defined in:
lib/disney/disney_base.rb

Direct Known Subclasses

DisneyAttraction, DisneyResort

Constant Summary collapse

TOKEN_URL =
"https://authorization.go.com/token"
TOKEN_BODY =
"grant_type=assertion&assertion_type=public&client_id=WDPRO-MOBILE.MDX.WDW.ANDROID-PROD"
APP_ID =
"WDW-MDX-ANDROID-3.4.1"
BASE_URL =
"https://api.wdpro.disney.go.com/"
REGION =
nil
CACHE_TIMEOUT =

How long to keep cached data, in seconds

5 * 60

Instance Method Summary collapse

Instance Method Details

#get(url_pattern, data = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/disney/disney_base.rb', line 19

def get(url_pattern, data={})
    get_auth_token
    headers = {
        "Authorization" => "BEARER #{@auth_token}",
        "Accept" => "application/json;apiversion=1",
        "X-Conversation-Id" => "WDPRO-MOBILE.MDX.CLIENT-PROD",
        "X-App-Id" => APP_ID,
        "X-Correlation-ID" => Time.now(),
        'content_type' => 'json'
    }
    url = BASE_URL + url_pattern
    data['region'] = region

    resp = RestClient::Request.execute(method: :get, url: url, payload: data.to_json, headers: headers)
    JSON.parse(resp)
end

#get_auth_tokenObject

5 minutes



13
14
15
16
17
# File 'lib/disney/disney_base.rb', line 13

def get_auth_token
    resp = RestClient.post(TOKEN_URL, TOKEN_BODY)
    data = JSON.parse(resp)
    @auth_token = data['access_token']
end

#regionObject



36
37
38
# File 'lib/disney/disney_base.rb', line 36

def region
    self.class::REGION
end