Class: Songstats::Api::Track

Inherits:
Base
  • Object
show all
Defined in:
lib/songstats/api/track.rb

Overview

Track 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

#initializeTrack

Returns a new instance of Track.



7
8
9
10
# File 'lib/songstats/api/track.rb', line 7

def initialize
  super
  @type = "track"
end

Instance Method Details

#activities(id, options = {}) ⇒ Object



17
18
19
20
21
# File 'lib/songstats/api/track.rb', line 17

def activities(id, options = {})
  # https://docs.songstats.com/docs/api/auzfvt1sw074a-get-track-activities
  options[:source] = "all" unless options.key? :source
  fetch path(id, "/tracks/activities", options)
end


41
42
43
44
# File 'lib/songstats/api/track.rb', line 41

def add_link(id, link)
  # https://docs.songstats.com/docs/api/731976e6c48b1-add-track-link
  post path(id, "/tracks/link_request", link: link)
end


46
47
48
49
# File 'lib/songstats/api/track.rb', line 46

def delete_link(id, link)
  # https://docs.songstats.com/docs/api/a5432922893c6-delete-track-link
  delete path(id, "/tracks/link_request", link: link)
end

#historic_stats(id, options = {}) ⇒ Object



29
30
31
32
33
# File 'lib/songstats/api/track.rb', line 29

def historic_stats(id, options = {})
  # https://docs.songstats.com/docs/api/b1071d94ab5fa-get-track-historic-stats
  options[:source] = "all" unless options.key? :source
  fetch path(id, "/tracks/historic_stats", options)
end

#info(id) ⇒ Object



12
13
14
15
# File 'lib/songstats/api/track.rb', line 12

def info(id)
  # https://docs.songstats.com/docs/api/3c84746369ec8-get-artist-info
  fetch path(id, "/tracks/info")
end

#search(query, options = {}) ⇒ Object



35
36
37
38
39
# File 'lib/songstats/api/track.rb', line 35

def search(query, options = {})
  # https://docs.songstats.com/docs/api/1f2e4f9b3b1d1-search-track
  options[:q] = query
  fetch path("", "/tracks/search", options)
end

#stats(id, options = {}) ⇒ Object



23
24
25
26
27
# File 'lib/songstats/api/track.rb', line 23

def stats(id, options = {})
  # https://docs.songstats.com/docs/api/6659134e76415-get-track-current-stats
  options[:source] = "all" unless options.key? :source
  fetch path(id, "/tracks/stats", options)
end