class Napster::Me
Authenticated endpoints under /me namespace
Constants
- MODELS_LIST
Attributes
client[RW]
Public Class Methods
new(client)
click to toggle source
# File lib/napster/me.rb, line 7 def initialize(client) validate_access_token(client) @client = client set_models end
Public Instance Methods
following()
click to toggle source
# File lib/napster/me.rb, line 35 def following Napster::Models::Following.new(client: @client) end
library()
click to toggle source
# File lib/napster/me.rb, line 27 def library Napster::Models::Library.new(client: @client) end
listening_history(params)
click to toggle source
# 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
profile()
click to toggle source
# File lib/napster/me.rb, line 31 def profile Napster::Models::Profile.new(client: @client) end
Private Instance Methods
model_class_name(model)
click to toggle source
# File lib/napster/me.rb, line 54 def model_class_name(model) "Napster::Models::#{model.capitalize}" end
set_models()
click to toggle source
# File lib/napster/me.rb, line 45 def set_models MODELS_LIST.each do |model| define_singleton_method("#{model}s") do Object.const_get(model_class_name(model)).new(client: @client) end end self end
validate_access_token(client)
click to toggle source
# File lib/napster/me.rb, line 41 def validate_access_token(client) raise 'The client is missing access_token' unless client.access_token end