Class: Spotify::SpAPI

Inherits:
Object
  • Object
show all
Defined in:
lib/spotifysearch/spotify_api.rb

Overview

Service for all Spotify API calls

Constant Summary collapse

SP_URL =
'https://api.spotify.com'.freeze
API_VER =
'v1'.freeze
SP_API_URL =
URI.join(SP_URL, "#{API_VER}/")
SEARCH_TYPE =
'track'.freeze

Class Method Summary collapse

Class Method Details

.search_feed(input) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/spotifysearch/spotify_api.rb', line 13

def self.search_feed(input)
  search_response = HTTP.get(
    URI.join(SP_API_URL, 'search'),
    params: { q: input, type: SEARCH_TYPE }
  )
  rawfeed = JSON.parse(search_response.to_s)['tracks']['items']
  Spotify::SongsHash.create(rawfeed)
end