Class: WiMP::Configuration

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

Constant Summary collapse

P_USERNAME =
"wimpse"
P_PASSWORD =
"slbh4UUgH"
D_CLIENT_NAME =
"Android_WIMP-2.5.2.se"
D_CLIENT_ID =
"8263371084"
SECURE_LOGIN_URL =
"https://client.wimpmusic.com/clientapi/servicelogin"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#client_idObject

Returns the value of attribute client_id.



27
28
29
# File 'lib/wimp.rb', line 27

def client_id
  @client_id
end

#client_nameObject

Returns the value of attribute client_name.



27
28
29
# File 'lib/wimp.rb', line 27

def client_name
  @client_name
end

#passwordObject

Returns the value of attribute password.



27
28
29
# File 'lib/wimp.rb', line 27

def password
  @password
end

#usernameObject

Returns the value of attribute username.



27
28
29
# File 'lib/wimp.rb', line 27

def username
  @username
end

Instance Method Details

#logged_in?Boolean

Returns Boolean.

Returns:

  • (Boolean)

    Boolean



56
57
58
# File 'lib/wimp.rb', line 56

def logged_in?
  !! session
end

#logout!Object



60
61
62
# File 'lib/wimp.rb', line 60

def logout!
  @_session = nil
end

#sessionObject

Returns String.

Returns:

  • String



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/wimp.rb', line 32

def session
  @_session ||= begin
    transport = Thrift::HTTPClientTransport.new(SECURE_LOGIN_URL)
    protocol = Thrift::BinaryProtocol.new(transport)
    client = Gen::ClientApiLoginService::Client.new(protocol)
    transport.open
    result = client.simpleLogin(
      username,
      password,
      P_USERNAME,
      P_PASSWORD,
      client_name || D_CLIENT_NAME,
      client_id || D_CLIENT_ID
    )
    transport.close
    result.sessionId
  end
rescue Thrift::ApplicationException
  raise LoginFailed.new("Login failed, invalid credentials. Are you really a premium user?")
end