module Spotify::Charts

Constants

VERSION

Public Class Methods

available_countries() click to toggle source
# File lib/spotify/charts.rb, line 13
def available_countries
  client.request('/most_viral/')
end
available_dates(country, time_window_type) click to toggle source
# File lib/spotify/charts.rb, line 21
def available_dates(country, time_window_type)
  client.request("/most_viral/#{country}/#{time_window_type}/")
end
available_metrics() click to toggle source
# File lib/spotify/charts.rb, line 9
def available_metrics
  client.request('/')
end
available_time_window_types(country) click to toggle source
# File lib/spotify/charts.rb, line 17
def available_time_window_types(country)
  client.request("/most_viral/#{country}/")
end
most_streamed(country, time_window_type, date) click to toggle source
# File lib/spotify/charts.rb, line 29
def most_streamed(country, time_window_type, date)
  extract_tracks("/most_streamed/#{country}/#{time_window_type}/#{date}")
end
most_viral(country, time_window_type, date) click to toggle source
# File lib/spotify/charts.rb, line 25
def most_viral(country, time_window_type, date)
  extract_tracks("/most_viral/#{country}/#{time_window_type}/#{date}")
end

Private Class Methods

client() click to toggle source
# File lib/spotify/charts.rb, line 35
def client
  @client ||= Spotify::Charts::Client.new
end
extract_tracks(endpoint) click to toggle source
# File lib/spotify/charts.rb, line 39
def extract_tracks(endpoint)
  json = client.request(endpoint)['tracks']

  json.inject([]) do |tracks, item|
    tracks << TrackParser.new(item).track
  end
end