Class: Songstats::Api::Chart

Inherits:
Base
  • Object
show all
Includes:
HTTParty
Defined in:
lib/songstats/api/chart.rb

Overview

Chart class for the Songstats API

Constant Summary

Constants inherited from Base

Base::ISRC_LENGTH, Base::SONG_STATS_ID_LENGTH

Instance Method Summary collapse

Constructor Details

#initializeChart

Returns a new instance of Chart.



13
14
15
16
17
# File 'lib/songstats/api/chart.rb', line 13

def initialize
  @api_key = ENV.fetch "SONGSTATS_CHARTS_API_KEY", nil

  raise Songstats::Api::Error, "Missing SongStats Charts API key" if @api_key.nil?
end

Instance Method Details

#tracks(options = {}) ⇒ Object



19
20
21
22
23
24
# File 'lib/songstats/api/chart.rb', line 19

def tracks(options = {})
  options[:source] = "all" unless options.key? :source
  options[:country_code] = "US" unless options.key? :country_code

  fetch path("/charts/tracks", options)
end