Class: Songstats::Api::Label
- Inherits:
-
Base
- Object
- Base
- Songstats::Api::Label
show all
- Defined in:
- lib/songstats/api/label.rb
Overview
Label class for the Songstats API
Constant Summary
Constants inherited
from Base
Base::ISRC_LENGTH, Base::SONG_STATS_ID_LENGTH
Instance Method Summary
collapse
-
#activites(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
-
#query_string(id) ⇒ Object
override because the label id is either songstats_label_id or beatport_label_id.
-
#search(query, options = {}) ⇒ Object
-
#stats(id, options = {}) ⇒ Object
-
#top_playlists(id, options = {}) ⇒ Object
-
#top_tracks(id, options = {}) ⇒ Object
Methods inherited from Base
#initialize
Instance Method Details
#activites(id, options = {}) ⇒ Object
21
22
23
24
25
|
# File 'lib/songstats/api/label.rb', line 21
def activites(id, options = {})
options[:source] = "all" unless options.key? :source
fetch path(id, "/labels/activities", options)
end
|
#add_link(id, link) ⇒ Object
72
73
74
75
|
# File 'lib/songstats/api/label.rb', line 72
def add_link(id, link)
post path(id, "/labels/link_request", link: link)
end
|
#add_track(id, track_id) ⇒ Object
82
83
84
85
86
87
88
89
|
# File 'lib/songstats/api/label.rb', line 82
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, "/labels/track_request", options)
end
|
#audience(id, source = "all") ⇒ Object
39
40
41
42
|
# File 'lib/songstats/api/label.rb', line 39
def audience(id, source = "all")
fetch path(id, "/labels/audience", source: source)
end
|
#audience_details(id, source = "all", country_code = "US") ⇒ Object
44
45
46
47
|
# File 'lib/songstats/api/label.rb', line 44
def audience_details(id, source = "all", country_code = "US")
fetch path(id, "/labels/audience/details", { source: source, country_code: country_code })
end
|
#catalog(id, options = {}) ⇒ Object
49
50
51
52
|
# File 'lib/songstats/api/label.rb', line 49
def catalog(id, options = {})
fetch path(id, "/labels/catalog", options)
end
|
#delete_link(id, link) ⇒ Object
77
78
79
80
|
# File 'lib/songstats/api/label.rb', line 77
def delete_link(id, link)
delete path(id, "/labels/link_request", link: link)
end
|
#delete_track(id, track_id) ⇒ Object
91
92
93
94
95
96
97
98
|
# File 'lib/songstats/api/label.rb', line 91
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, "/labels/track_request", options)
end
|
#historic_stats(id, options = {}) ⇒ Object
33
34
35
36
37
|
# File 'lib/songstats/api/label.rb', line 33
def historic_stats(id, options = {})
options[:source] = "all" unless options.key? :source
fetch path(id, "/labels/historic_stats", options)
end
|
#info(id) ⇒ Object
16
17
18
19
|
# File 'lib/songstats/api/label.rb', line 16
def info(id)
fetch path(id, "/labels/info")
end
|
#query_string(id) ⇒ Object
override because the label id is either songstats_label_id or beatport_label_id
8
9
10
11
12
13
14
|
# File 'lib/songstats/api/label.rb', line 8
def query_string(id)
return "songstats_label_id=#{id}" if id.size == SONG_STATS_ID_LENGTH
return "" if id.size.zero?
"beatport_label_id=#{id}"
end
|
#search(query, options = {}) ⇒ Object
66
67
68
69
70
|
# File 'lib/songstats/api/label.rb', line 66
def search(query, options = {})
options[:q] = query
fetch path("", "/labels/search", options)
end
|
#stats(id, options = {}) ⇒ Object
27
28
29
30
31
|
# File 'lib/songstats/api/label.rb', line 27
def stats(id, options = {})
options[:source] = "all" unless options.key? :source
fetch path(id, "/labels/stats", options)
end
|
#top_playlists(id, options = {}) ⇒ Object
60
61
62
63
64
|
# File 'lib/songstats/api/label.rb', line 60
def top_playlists(id, options = {})
options[:source] = "all" unless options.key? :source
fetch path(id, "/labels/top_playlists", options)
end
|
#top_tracks(id, options = {}) ⇒ Object
54
55
56
57
58
|
# File 'lib/songstats/api/label.rb', line 54
def top_tracks(id, options = {})
options[:source] = "all" unless options.key? :source
fetch path(id, "/labels/top_tracks", options)
end
|