Class: Rhapsody::MembersController

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

Constant Summary collapse

PARENT_PATH =
'/v1/me'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ MembersController

Returns a new instance of MembersController.



10
11
12
# File 'lib/rhapsody/controllers/members_controller.rb', line 10

def initialize(options)
  @access_token = options[:access_token]
end

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



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

def access_token
  @access_token
end

#json_responseObject

Returns the value of attribute json_response.



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

def json_response
  @json_response
end

#pathObject

Returns the value of attribute path.



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

def path
  @path
end

#raw_reponseObject

Returns the value of attribute raw_reponse.



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

def raw_reponse
  @raw_reponse
end

#response_statusObject

Returns the value of attribute response_status.



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

def response_status
  @response_status
end

Instance Method Details

#accountObject

/me/account



15
16
17
18
19
20
21
22
# File 'lib/rhapsody/controllers/members_controller.rb', line 15

def 
  @path = PARENT_PATH + '/account'
  connection = Rhapsody::FaradayConnection.prepare_authorization(access_token)
  @raw_response = connection.get(@path)
  @json_response = JSON.parse(@raw_response.env[:body])
  @response_status = @raw_response.env[:status]
  member = Rhapsody::Member.new(@json_response)
end