Class: Napster::Me

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

Overview

Authenticated endpoints under /me namespace

Constant Summary collapse

MODELS_LIST =
%w(favorite playlist follower tag).freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Me

Returns a new instance of Me.



7
8
9
10
11
# File 'lib/napster/me.rb', line 7

def initialize(client)
  validate_access_token(client)
  @client = client
  set_models
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



5
6
7
# File 'lib/napster/me.rb', line 5

def client
  @client
end

Instance Method Details

#followingObject



35
36
37
# File 'lib/napster/me.rb', line 35

def following
  Napster::Models::Following.new(client: @client)
end

#libraryObject



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

def library
  Napster::Models::Library.new(client: @client)
end

#listening_history(params) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/napster/me.rb', line 13

def listening_history(params)
  get_options = {
    params: params,
    headers: {
      Authorization: 'Bearer ' + @client.access_token,
      'Content-Type' => 'application/json',
      'Accept-Version' => '2.0.0'
    }
  }
  response = @client.get('/me/listens', get_options)
  Napster::Models::Track
    .collection(data: response['tracks'], client: @client)
end

#profileObject



31
32
33
# File 'lib/napster/me.rb', line 31

def profile
  Napster::Models::Profile.new(client: @client)
end