class Epicmix::Client
Attributes
password[RW]
token[RW]
username[RW]
Public Class Methods
new(username, password)
click to toggle source
Initializes and logs in to Epicmix
# File lib/epicmix.rb, line 11 def initialize(username, password) @username, @password = username, password @token = login end
Public Instance Methods
headers(extra = {})
click to toggle source
Sets headers
# 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()
click to toggle source
Login to epic mix
# File lib/epicmix.rb, line 17 def login url = 'https://www.epicmix.com/vailresorts/sites/epicmix/api/mobile/authenticate.ashx' options = { :query => { :loginID => username, :password => password }} response = HTTParty.post(url, options) token_from(response) # if response.instance_of? Net::HTTPOK end
season_stats()
click to toggle source
Gets all your season stats
# File lib/epicmix.rb, line 27 def season_stats url = 'https://www.epicmix.com/vailresorts/sites/epicmix/api/mobile/userstats.ashx' options = { :timetype => 'season', :token => token } response = HTTParty.get(url, :query => options, :headers => headers) JSON.parse(response.body)['seasonStats'] end
session_id()
click to toggle source
Get the sesson id, to be inserted into the cookies in the header
# File lib/epicmix.rb, line 50 def session_id "ASP.NET_SessionId=#{token}" end
token_from(response)
click to toggle source
Gets token out of response cookies
# File lib/epicmix.rb, line 37 def token_from(response) response.headers['Set-Cookie'][%r{ASP.NET_SessionId=([^;]+);}, 1] end
website()
click to toggle source
# File lib/epicmix.rb, line 54 def website "website#sc_wede=1" end