class Napster::Models::Profile

Profile model

Constants

ATTRIBUTES

Attributes

client[RW]

Public Class Methods

collection(arg) click to toggle source
# File lib/napster/models/profile.rb, line 45
def self.collection(arg)
  arg[:data].map do |profile|
    Profile.new(data: profile, client: @client)
  end
end
new(arg) click to toggle source
# File lib/napster/models/profile.rb, line 37
def initialize(arg)
  @client = arg[:client] if arg[:client]
  return unless arg[:data]
  ATTRIBUTES.each do |attribute|
    send("#{attribute}=", arg[:data][attribute.to_s.camel_case_lower])
  end
end

Public Instance Methods

get() click to toggle source
# File lib/napster/models/profile.rb, line 51
def get
  get_options = {
    headers: {
      Authorization: 'Bearer ' + @client.access_token,
      'Content-Type' => 'application/json',
      'Accept-Version' => '2.0.0'
    }
  }
  response = @client.get('/me', get_options)
  Profile.new(data: response['me'], client: @client)
end
update(body) click to toggle source
# File lib/napster/models/profile.rb, line 63
def update(body)
  put_options = {
    headers: {
      Authorization: 'Bearer ' + @client.access_token,
      'Content-Type' => 'application/json',
      'Accept-Version' => '2.0.0'
    }
  }
  @client.put('/me', Oj.dump(body), put_options)
end