Class: Songstats::Api::Label

Inherits:
Base
  • Object
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

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Songstats::Api::Base

Instance Method Details

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



21
22
23
24
25
# File 'lib/songstats/api/label.rb', line 21

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


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

def add_link(id, link)
  # https://docs.songstats.com/docs/api/32ff3c7990342-add-label-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)
  # https://docs.songstats.com/docs/api/sf9lrzr189m48-add-label-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, "/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")
  # https://docs.songstats.com/docs/api/ba9cd0e9f62ab-get-label-audience
  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")
  # https://docs.songstats.com/docs/api/907amvb46s0ar-get-label-audience-details
  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 = {})
  # https://docs.songstats.com/docs/api/c05d4ce991ca9-get-label-catalog
  fetch path(id, "/labels/catalog", options)
end


77
78
79
80
# File 'lib/songstats/api/label.rb', line 77

def delete_link(id, link)
  # https://docs.songstats.com/docs/api/f684183faa3b9-delete-label-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)
  # https://docs.songstats.com/docs/api/l0xhrjijnktgf-remove-label-link
  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 = {})
  # https://docs.songstats.com/docs/api/e0ea5143330a4-get-label-historic-stats
  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)
  # https://docs.songstats.com/docs/api/3565af9c48648-get-label-info
  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 = {})
  # https://docs.songstats.com/docs/api/c934a2909ba0f-search-label
  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 = {})
  # https://docs.songstats.com/docs/api/5891964223175-get-label-current-stats
  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 = {})
  # https://docs.songstats.com/docs/api/f3dab6bf2e7de-get-label-top-playlists
  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 = {})
  # https://docs.songstats.com/docs/api/5c8071d20b59a-get-label-top-tracks
  options[:source] = "all" unless options.key? :source
  fetch path(id, "/labels/top_tracks", options)
end