# frozen_string_literal: true require "singleton" module Songstats module Api # Artist class for the Songstats API class Artist < Base include Singleton def initialize super @type = "artist" end def info(id) # https://docs.songstats.com/docs/api/3c84746369ec8-get-artist-info fetch path(id, "/artists/info") end 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 def stats(id, source = "all") # https://docs.songstats.com/docs/api/6cdcdbb1adaa5-get-artist-current-stats fetch path(id, "/artists/stats", source: source) end 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 def audience(id, source = "all") # https://docs.songstats.com/docs/api/d0486406cfe17-get-artist-audience fetch path(id, "/artists/audience", source: source) end 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 def catalog(id, options = {}) # https://docs.songstats.com/docs/api/b5b626840f42e-get-artist-catalog fetch path(id, "/artists/catalog", options) end 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 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 def search(id, query, options = {}) # https://docs.songstats.com/docs/api/d761545339f09-search-artist options[:q] = query fetch path(id, "/artists/search", options) end def add_link(id, link) # https://docs.songstats.com/docs/api/16f83e3f941f2-add-artist-link post path(id, "/artists/link_request", link: link) end def delete_link(id, link) # https://docs.songstats.com/docs/api/dc58c858fdbb6-delete-artist-link delete path(id, "/artists/link_request", link: link) end end end end