Class: Songkickr::Remote

Overview

Create an instance of the remote class to interact with the Songkick API.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Songkickr::RemoteApi::SimilarArtists

#similar_artists

Methods included from Songkickr::RemoteApi::VenueDetails

#venue

Methods included from Songkickr::RemoteApi::EventDetails

#event

Methods included from Songkickr::RemoteApi::ArtistDetails

#artist

Methods included from Songkickr::RemoteApi::PastEvents

#artists_gigography, #concert_setlists, #users_gigography

Methods included from Songkickr::RemoteApi::UserEventsAndTrackings

#users_artist_tracking, #users_attendance, #users_attendance_calendar, #users_events, #users_metro_area_tracking, #users_muted_artists, #users_tracked_artists, #users_tracked_events_calendar, #users_tracked_metro_areas

Methods included from Songkickr::RemoteApi::UpcomingEvents

#artist_events, #artist_search, #events, #location_search, #location_search_geo, #location_search_ip, #location_search_metro_area_name, #metro_areas_events, #venue_calendar, #venue_search

Constructor Details

#initialize(api_key = nil, options = {}) ⇒ Remote

Create a new instance of the remote class to talk to Songkick

Get an API key for your app from developer.songkick.com/


23
24
25
26
27
28
29
30
31
32
# File 'lib/songkickr/remote.rb', line 23

def initialize(api_key = nil, options = {})
  @api_key = api_key
  @api_key ||= Songkickr.api_key
  @debug = options[:debug] || false

  self.class.default_params apikey: @api_key
  if @debug
    self.class.debug_output $stderr
  end
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key


16
17
18
# File 'lib/songkickr/remote.rb', line 16

def api_key
  @api_key
end

#debugObject

Returns the value of attribute debug


15
16
17
# File 'lib/songkickr/remote.rb', line 15

def debug
  @debug
end

Instance Method Details

#get(location, query_params = {}) ⇒ Object


34
35
36
37
38
39
40
41
42
43
# File 'lib/songkickr/remote.rb', line 34

def get(location, query_params = {})
  result = self.class.get(location, query_params)
  # FIXME: this is shit. should be based on on http response.
  if result['resultsPage']['error']
    msg = result['resultsPage']['error']['message']
    raise ResourceNotFound if msg =~ /not found/
    raise APIError.new(msg)
  end
  result
end