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.



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

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

#stateObject

Returns the value of attribute state.



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

def state
  @state
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



23
24
25
26
27
28
29
30
31
# File 'lib/rhapsody/client.rb', line 23

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

  if @state
    default + "&state=#{@state}"
  else
    default
  end
end

#connectObject



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

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

#password_grantObject



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

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

#renewObject



38
39
40
41
42
43
# File 'lib/rhapsody/client.rb', line 38

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