Class: AppleMusic::StoreClient

Inherits:
Client
  • Object
show all
Defined in:
lib/storeClient.rb

Instance Method Summary collapse

Methods inherited from Client

#get, #headers, #initialize, #post

Constructor Details

This class inherits a constructor from AppleMusic::Client

Instance Method Details

#find_artist(artist_name:) ⇒ Object



10
11
12
13
# File 'lib/storeClient.rb', line 10

def find_artist(artist_name:)
  response = get_catalog("search?term=#{escape(artist_name)}&types=artists")
  parse(response.dig("results", "artists", "data"))[0]
end

#get_albums(artist:) ⇒ Object



20
21
22
23
# File 'lib/storeClient.rb', line 20

def get_albums(artist:)
  response = PaginatedResponse.new(self, get("/v1/catalog/us/artists/#{artist.id}/albums?limit=100"))
  parse(response).sort_by { |album| album.releaseDate }.reverse
end

#get_artist(artist_id:) ⇒ Object



15
16
17
18
# File 'lib/storeClient.rb', line 15

def get_artist(artist_id:)
  response = get_catalog("artists/#{artist_id}")
  parse(response["data"])[0]
end