Class: Songstats::Api::Artist
- Inherits:
-
Base
- Object
- Base
- Songstats::Api::Artist
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
-
#activities(id, options = {}) ⇒ Object
-
#add_link(id, link) ⇒ Object
-
#add_track(id, track_id) ⇒ Object
-
#audience(id, source = "all") ⇒ Object
-
#audience_details(id, source = "all", country_code = "US") ⇒ Object
-
#catalog(id, options = {}) ⇒ Object
-
#delete_link(id, link) ⇒ Object
-
#delete_track(id, track_id) ⇒ Object
-
#historic_stats(id, options = {}) ⇒ Object
-
#info(id) ⇒ Object
-
#initialize ⇒ Artist
constructor
A new instance of Artist.
-
#search(query, options = {}) ⇒ Object
-
#stats(id, source = "all") ⇒ Object
-
#top_playlists(id, options = {}) ⇒ Object
-
#top_tracks(id, options = {}) ⇒ Object
Constructor Details
#initialize ⇒ Artist
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 = {})
options[:source] = "all" unless options.key? :source
fetch path(id, "/artists/activities", options)
end
|
#add_link(id, link) ⇒ Object
67
68
69
70
|
# File 'lib/songstats/api/artist.rb', line 67
def add_link(id, 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)
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")
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")
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 = {})
fetch path(id, "/artists/catalog", options)
end
|
#delete_link(id, link) ⇒ Object
72
73
74
75
|
# File 'lib/songstats/api/artist.rb', line 72
def delete_link(id, 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)
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 = {})
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)
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 = {})
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")
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 = {})
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 = {})
options[:source] = "all" unless options.key? :source
fetch path(id, "/artists/top_tracks", options)
end
|