class UnderFire::Client
Public interface to UnderFire's functionality.
@example
client = UnderFire::Client.new client.album_search(:artist => 'Miles Davis') #=> lots of results client = UnderFire::Client.new client.find_by_toc space_delimited_toc_offsets
Attributes
api_url[R]
@return [String] API URL for application.
Public Class Methods
new()
click to toggle source
# File lib/under_fire/client.rb, line 25 def initialize @api_url = Configuration.instance.api_url end
Public Instance Methods
fetch_album(args)
click to toggle source
Fetches album with given album :gn_id or track :gn_id @return [APIResponse] @see UnderFire::AlbumFetch
Description of arguments.
# File lib/under_fire/client.rb, line 51 def fetch_album(args) search = AlbumFetch.new(args) response = APIRequest.post(search.query, api_url) APIResponse.new(response.body) end
fetch_cover(response, file_name)
click to toggle source
Fetches cover art using results of query. @param [APIResponse] response
# File lib/under_fire/client.rb, line 68 def fetch_cover(response, file_name) res = response.to_h response_url = res['RESPONSE']['ALBUM']['URL'] title = res['RESPONSE']['ALBUM']['TITLE'] file_name = file_name || "#{title}-cover.jpg" APIRequest.get_file(response_url, filename) end
find_album(args)
click to toggle source
Finds album using one or more of :artist, :track_title and :album_title @return [APIResponse] @see UnderFire::AlbumSearch
Description of arguments.
# File lib/under_fire/client.rb, line 42 def find_album(args) search = AlbumSearch.new(args) response = APIRequest.post(search.query, api_url) APIResponse.new(response.body) end
find_by_toc(*offsets)
click to toggle source
Searches for album using provided toc offsets. @return [APIResponse] @see UnderFire::AlbumTOCSearch
# File lib/under_fire/client.rb, line 32 def find_by_toc(*offsets) offsets = offsets.join(" ") search = AlbumTOCSearch.new(:toc => offsets) response = APIRequest.post(search.query, api_url) APIResponse.new(response.body) end
register(client_id)
click to toggle source
Registers user with given client_id @return [APIResponse] @see UnderFire::Registration
Description of arguments
# File lib/under_fire/client.rb, line 60 def register(client_id) search = Registration.new(client_id) response = APIRequest.post(search.query, api_url) APIResponse.new(response.body) end