Class: Epicmix::Client
- Inherits:
-
Object
- Object
- Epicmix::Client
- Defined in:
- lib/epicmix.rb
Instance Attribute Summary collapse
-
#password ⇒ Object
Returns the value of attribute password.
-
#token ⇒ Object
Returns the value of attribute token.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
-
#headers(extra = {}) ⇒ Object
Sets headers.
-
#initialize(username, password) ⇒ Client
constructor
Initializes and logs in to Epicmix.
-
#login ⇒ Object
Login to epic mix.
-
#season_stats ⇒ Object
Gets all your season stats.
-
#session_id ⇒ Object
Get the sesson id, to be inserted into the cookies in the header.
-
#token_from(response) ⇒ Object
Gets token out of response cookies.
- #website ⇒ Object
Constructor Details
#initialize(username, password) ⇒ Client
Initializes and logs in to Epicmix
11 12 13 14 |
# File 'lib/epicmix.rb', line 11 def initialize(username, password) @username, @password = username, password @token = login end |
Instance Attribute Details
#password ⇒ Object
Returns the value of attribute password.
8 9 10 |
# File 'lib/epicmix.rb', line 8 def password @password end |
#token ⇒ Object
Returns the value of attribute token.
8 9 10 |
# File 'lib/epicmix.rb', line 8 def token @token end |
#username ⇒ Object
Returns the value of attribute username.
8 9 10 |
# File 'lib/epicmix.rb', line 8 def username @username end |
Instance Method Details
#headers(extra = {}) ⇒ Object
Sets headers
42 43 44 45 46 47 |
# File 'lib/epicmix.rb', line 42 def headers(extra = {}) extra.merge 'Cookie' => [session_id, website, session_id].join('; '), 'Accept-Encoding' => 'gzip', 'User-Agent' => 'EpicMix 15880 rv:2.1 (iPhone; iPhone OS 5.0.1; en_US)', 'Host' => 'www.epicmix.com' end |
#login ⇒ Object
Login to epic mix
17 18 19 20 21 22 23 24 |
# File 'lib/epicmix.rb', line 17 def login url = 'https://www.epicmix.com/vailresorts/sites/epicmix/api/mobile/authenticate.ashx' = { :query => { :loginID => username, :password => password }} response = HTTParty.post(url, ) token_from(response) # if response.instance_of? Net::HTTPOK end |
#season_stats ⇒ Object
Gets all your season stats
27 28 29 30 31 32 33 34 |
# File 'lib/epicmix.rb', line 27 def season_stats url = 'https://www.epicmix.com/vailresorts/sites/epicmix/api/mobile/userstats.ashx' = { :timetype => 'season', :token => token } response = HTTParty.get(url, :query => , :headers => headers) JSON.parse(response.body)['seasonStats'] end |
#session_id ⇒ Object
Get the sesson id, to be inserted into the cookies in the header
50 51 52 |
# File 'lib/epicmix.rb', line 50 def session_id "ASP.NET_SessionId=#{token}" end |
#token_from(response) ⇒ Object
Gets token out of response cookies
37 38 39 |
# File 'lib/epicmix.rb', line 37 def token_from(response) response.headers['Set-Cookie'][%r{ASP.NET_SessionId=([^;]+);}, 1] end |
#website ⇒ Object
54 55 56 |
# File 'lib/epicmix.rb', line 54 def website "website#sc_wede=1" end |