# frozen_string_literal: true module Songstats module Api # Track class for the Songstats API class Track < Base include Singleton def initialize super @type = "track" end def info(id) # https://docs.songstats.com/docs/api/3c84746369ec8-get-artist-info fetch path(id, "/tracks/info") end def activities(id, options = {}) # https://docs.songstats.com/docs/api/auzfvt1sw074a-get-track-activities options[:source] = "all" unless options.key? :source fetch path(id, "/tracks/activities", options) end def stats(id, options = {}) # https://docs.songstats.com/docs/api/6659134e76415-get-track-current-stats options[:source] = "all" unless options.key? :source fetch path(id, "/tracks/stats", options) end def historic_stats(id, options = {}) # https://docs.songstats.com/docs/api/b1071d94ab5fa-get-track-historic-stats options[:source] = "all" unless options.key? :source fetch path(id, "/tracks/historic_stats", options) end def search(query, options = {}) # https://docs.songstats.com/docs/api/1f2e4f9b3b1d1-search-track options[:q] = query fetch path("", "/tracks/search", options) end def add_link(id, link) # https://docs.songstats.com/docs/api/731976e6c48b1-add-track-link post path(id, "/tracks/link_request", link: link) end def delete_link(id, link) # https://docs.songstats.com/docs/api/a5432922893c6-delete-track-link delete path(id, "/tracks/link_request", link: link) end end end end