Class: Rhapsody::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Client

Returns a new instance of Client.



10
11
12
13
14
15
# File 'lib/rhapsody/client.rb', line 10

def initialize(options)
  # TODO: verify options
  options.each do |name, value|
    instance_variable_set("@#{name}", value)
  end
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



2
3
4
# File 'lib/rhapsody/client.rb', line 2

def api_key
  @api_key
end

#api_secretObject

Returns the value of attribute api_secret.



2
3
4
# File 'lib/rhapsody/client.rb', line 2

def api_secret
  @api_secret
end

#auth_codeObject

Returns the value of attribute auth_code.



2
3
4
# File 'lib/rhapsody/client.rb', line 2

def auth_code
  @auth_code
end

#authenticationObject

Returns the value of attribute authentication.



2
3
4
# File 'lib/rhapsody/client.rb', line 2

def authentication
  @authentication
end

#passwordObject

Returns the value of attribute password.



2
3
4
# File 'lib/rhapsody/client.rb', line 2

def password
  @password
end

#redirect_uriObject

Returns the value of attribute redirect_uri.



2
3
4
# File 'lib/rhapsody/client.rb', line 2

def redirect_uri
  @redirect_uri
end

#usernameObject

Returns the value of attribute username.



2
3
4
# File 'lib/rhapsody/client.rb', line 2

def username
  @username
end

Instance Method Details

#authorization_urlObject



22
23
24
# File 'lib/rhapsody/client.rb', line 22

def authorization_url
  Rhapsody::Request::HOST_URL + "/oauth/authorize?client_id=#{@api_key}&redirect_uri=#{@redirect_uri}&response_type=code"
end

#connectObject



26
27
28
29
# File 'lib/rhapsody/client.rb', line 26

def connect
  @authentication = Rhapsody::Authentication.new({ client: self })
  @authentication.connect
end

#password_grantObject



17
18
19
20
# File 'lib/rhapsody/client.rb', line 17

def password_grant
  @authentication = Rhapsody::Authentication.new({ client: self })
  @authentication.password_grant
end

#renewObject



31
32
33
34
35
36
# File 'lib/rhapsody/client.rb', line 31

def renew
  if @authentication
    @authentication.renew
  end
  # TODO Need to handle, authentication
end