Class: Songstats::Api::Artist

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

Overview

Artist 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

#initializeArtist

Returns a new instance of Artist.



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

def initialize
  super
  @type = "artist"
end

Instance Method Details

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



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

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


67
68
69
70
# File 'lib/songstats/api/artist.rb', line 67

def add_link(id, link)
  # https://docs.songstats.com/docs/api/16f83e3f941f2-add-artist-link
  post path(id, "/artists/link_request", link: link)
end

#add_track(id, track_id) ⇒ Object



77
78
79
80
81
82
83
84
# File 'lib/songstats/api/artist.rb', line 77

def add_track(id, track_id)
  # https://docs.songstats.com/docs/api/aux8fvg3g9sv7-add-artist-track
  options = {}
  options[:isrc] = track_id if track_id.size == ISRC_LENGTH
  options[:spotify_track_id] = track_id if track_id.size > ISRC_LENGTH && !url?(track_id)
  options[:link] = track_id if url? track_id
  post path(id, "/artists/track_request", options)
end

#audience(id, source = "all") ⇒ Object



34
35
36
37
# File 'lib/songstats/api/artist.rb', line 34

def audience(id, source = "all")
  # https://docs.songstats.com/docs/api/d0486406cfe17-get-artist-audience
  fetch path(id, "/artists/audience", source: source)
end

#audience_details(id, source = "all", country_code = "US") ⇒ Object



39
40
41
42
# File 'lib/songstats/api/artist.rb', line 39

def audience_details(id, source = "all", country_code = "US")
  # https://docs.songstats.com/docs/api/956j6623vtyd4-get-artist-audience-details
  fetch path(id, "/artists/audience/details", { source: source, country_code: country_code })
end

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



44
45
46
47
# File 'lib/songstats/api/artist.rb', line 44

def catalog(id, options = {})
  # https://docs.songstats.com/docs/api/b5b626840f42e-get-artist-catalog
  fetch path(id, "/artists/catalog", options)
end


72
73
74
75
# File 'lib/songstats/api/artist.rb', line 72

def delete_link(id, link)
  # https://docs.songstats.com/docs/api/dc58c858fdbb6-delete-artist-link
  delete path(id, "/artists/link_request", link: link)
end

#delete_track(id, track_id) ⇒ Object



86
87
88
89
90
91
92
93
# File 'lib/songstats/api/artist.rb', line 86

def delete_track(id, track_id)
  # https://docs.songstats.com/docs/api/sijd2vkvgwpdj-remove-artist-track
  options = {}
  options[:isrc] = track_id if track_id.size == ISRC_LENGTH
  options[:songstats_track_id] = track_id if track_id.size == SONG_STATS_ID_LENGTH
  options[:spotify_track_id] = track_id if track_id.size > ISRC_LENGTH
  delete path(id, "/artists/track_request", options)
end

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



28
29
30
31
32
# File 'lib/songstats/api/artist.rb', line 28

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

#info(id) ⇒ Object



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

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

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



61
62
63
64
65
# File 'lib/songstats/api/artist.rb', line 61

def search(query, options = {})
  # https://docs.songstats.com/docs/api/d761545339f09-search-artist
  options[:q] = query
  fetch path("", "/artists/search", options)
end

#stats(id, source = "all") ⇒ Object



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

def stats(id, source = "all")
  # https://docs.songstats.com/docs/api/6cdcdbb1adaa5-get-artist-current-stats
  fetch path(id, "/artists/stats", source: source)
end

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



55
56
57
58
59
# File 'lib/songstats/api/artist.rb', line 55

def top_playlists(id, options = {})
  # https://docs.songstats.com/docs/api/87fcd0051843e-get-artist-top-playlists
  options[:source] = "all" unless options.key? :source
  fetch path(id, "/artists/top_playlists", options)
end

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



49
50
51
52
53
# File 'lib/songstats/api/artist.rb', line 49

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