Class: ListenBrainz::ArtistMap

Inherits:
Base
  • Object
show all
Defined in:
lib/listenbrainz/models/artist_map.rb

Overview

Model class for artist maps.

Defined Under Namespace

Classes: Payload

Instance Attribute Summary collapse

Class Method Summary collapse

Methods inherited from Base

#as_json

Instance Attribute Details

#artist_countInteger (readonly)

Returns:

  • (Integer)


64
# File 'lib/listenbrainz/models/artist_map.rb', line 64

attribute :artist_count, Types::Integer

#artistsArray<Artist> (readonly)

Returns:



79
# File 'lib/listenbrainz/models/artist_map.rb', line 79

attribute :artists, Types::Array.of(Artist)

#countryString (readonly)

ISO-3166-1 alpha-3 code of the country



70
# File 'lib/listenbrainz/models/artist_map.rb', line 70

attribute :country, Types::String

#listen_countInteger (readonly)

Returns:

  • (Integer)


74
# File 'lib/listenbrainz/models/artist_map.rb', line 74

attribute :listen_count, Types::Integer

Class Method Details

.get(username = ListenBrainz.client.username, range: nil) ⇒ Payload

Retrieves the artist map for the given user.

Parameters:

  • username (String) (defaults to: ListenBrainz.client.username)
  • range (Symbol, nil) (defaults to: nil)

Returns:

See Also:



16
17
18
19
20
21
22
# File 'lib/listenbrainz/models/artist_map.rb', line 16

def self.get(username = ListenBrainz.client.username, range: nil)
  params = { range: }.compact

  ListenBrainz.client.query(
    :get, "1/stats/user/#{username}/artist-map", params:
  ).fetch(:payload).then { Payload.new(_1) }
end

.sitewide(range: nil) ⇒ Payload

Retrieves the site-wide artist map.

Parameters:

  • range (Symbol, nil) (defaults to: nil)

Returns:

See Also:



32
33
34
35
36
37
# File 'lib/listenbrainz/models/artist_map.rb', line 32

def self.sitewide(range: nil)
  params = { range: }.compact
  ListenBrainz.client.query(
    :get, '1/stats/sitewide/artist-map', params:
  ).fetch(:payload).then { Payload.new(_1) }
end