lib/songkickr/remote.rb in songkickr-0.2.0 vs lib/songkickr/remote.rb in songkickr-0.2.1

- old
+ new

@@ -2,22 +2,22 @@ # Create an instance of the remote class to interact with the Songkick API. class Remote include HTTParty base_uri 'api.songkick.com/api/3.0' format :json - + attr_reader :api_key - + # ==== Create a new instance of the remote class to talk to Songkick # Get an API key for your app from http://developer.songkick.com/ def initialize(api_key = nil) @api_key = api_key @api_key ||= Songkickr.api_key - + self.class.default_params :apikey => @api_key end - + # ==== Event Search API # http://www.songkick.com/developer/event-search # # === Parameters # * +query+ - A hash of query parameters, see below for options. @@ -37,14 +37,14 @@ def events(query = {}) path = extract_path_from_query(query) result = self.class.get("#{path}/events.json", :query => query) Songkickr::EventResult.new result end - + # ==== Event API # http://www.songkick.com/developer/upcoming-events - # + # # Getting detailed information of a single event. # # === Parameters # * +event_id+ - Songkick event ID. Extract the event ID either from a previous API call or from the URL of the event page on the website. def event(event_id) @@ -57,11 +57,11 @@ # http://groups.google.com/group/songkick-api/browse_thread/thread/af15b9a6ad3c3513# # # === Parameters # * +artist_id+ - Songkick artist_id, use artist_search to get it # * +query+ - A hash of query parameters, see below for options. - # + # # ==== Query Parameters # * +min_date+ - Oldest date for which you want to look for events # * +max_date+ - Most recent date for which you want to look for events # * +per_page+ - Number of items on a page # * +page+ - Number of page @@ -82,11 +82,28 @@ # * +artist_name+ - Name of an artist. <em>Ex. 'Lady Gaga', 'Slayer', 'Atmosphere'</em> def artist_search(query={}) result = self.class.get("/search/artists.json", :query => query) Songkickr::ArtistResult.new result end - + + # ==== Artist calendar (Upcoming) + # Returns an array of Events. + # + # http://www.songkick.com/developer/upcoming-events-for-artist + # + # === Parameters + # * +artist_id+ - Songkick unique ID for artist. Use artist_search to find an artist ID. + # * +query+ - A hash of query parameters, see below for options. + # + # ==== Query Parameters + # * +page+ - Page number + # * +per_page+ - Number of results per page, max 50. + def artist_events(artist_id, query = {}) + result = self.class.get("/artists/#{artist_id}/calendar.json", :query => query) + Songkickr::EventResult.new result + end + # ==== User Events API # http://www.songkick.com/developer/upcoming-events-for-user # # === Parameters # * +username+ - A Songkick username. @@ -121,22 +138,22 @@ # * +per_page+ - Number of results per page, max 50. def metro_areas_events(metro_area_id, query = {}) result = self.class.get("/metro_areas/#{metro_area_id}/calendar.json", :query => query) Songkickr::EventResult.new result end - + # ==== Concert Setlists API # http://www.songkick.com/developer/setlists # # === Parameters # # * +event_id+ - Songkick event ID. Extract the event ID either from a previous API call or from the URL of the event page on the website. def concert_setlists(event_id) result = self.class.get("/events/#{event_id}/setlists.json") Songkickr::ConcertSetlistResult.new result end - + # ==== Location Search API # http://www.songkick.com/developer/location-search # # === Parameters # * +query+ - A hash of query parameters, see below for options. @@ -145,16 +162,27 @@ # * +location+ - 'geo:{lat,lng}' string <em>Ex. 'geo:{-0.128,51.5078}'</em> def location_search(query = {}) result = self.class.get("/search/locations.json", :query => query) Songkickr::LocationResult.new result end - - + + # ==== Venue Search + # http://www.songkick.com/developer/venue-details + # + # === Parameters + # + # * +venue_id+ - Songkick venue ID. + def venue(venue_id) + result = self.class.get("/venues/#{venue_id}.json") + Songkickr::Venue.new result['resultsPage']['results']['venue'] + end + + private - + # Given a query, look for an mbid key and return a path to access it. def extract_path_from_query(query = {}) mbid = query.delete :mbid "/artists/mbid:#{mbid}" if mbid end end -end \ No newline at end of file +end