songkickr 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. checksums.yaml +7 -0
  2. data/.bundle/config +2 -0
  3. data/.gitignore +1 -0
  4. data/.travis.yml +8 -0
  5. data/Gemfile.lock +42 -22
  6. data/LICENSE +1 -1
  7. data/README.rdoc +14 -9
  8. data/Rakefile +3 -4
  9. data/lib/songkickr/artist.rb +2 -2
  10. data/lib/songkickr/artist_result.rb +4 -24
  11. data/lib/songkickr/calendar_entry.rb +23 -0
  12. data/lib/songkickr/calendar_result.rb +10 -0
  13. data/lib/songkickr/concert_setlist_result.rb +5 -27
  14. data/lib/songkickr/event.rb +8 -14
  15. data/lib/songkickr/event_result.rb +5 -23
  16. data/lib/songkickr/location.rb +4 -4
  17. data/lib/songkickr/location_result.rb +5 -30
  18. data/lib/songkickr/metro_area.rb +28 -0
  19. data/lib/songkickr/metro_area_result.rb +12 -0
  20. data/lib/songkickr/performance.rb +17 -12
  21. data/lib/songkickr/remote.rb +18 -198
  22. data/lib/songkickr/remote_api/artist_details.rb +17 -0
  23. data/lib/songkickr/remote_api/event_details.rb +17 -0
  24. data/lib/songkickr/remote_api/past_events.rb +48 -0
  25. data/lib/songkickr/remote_api/similar_artists.rb +14 -0
  26. data/lib/songkickr/remote_api/upcoming_events.rb +125 -0
  27. data/lib/songkickr/remote_api/user_events_and_trackings.rb +143 -0
  28. data/lib/songkickr/remote_api/venue_details.rb +16 -0
  29. data/lib/songkickr/result_set.rb +27 -0
  30. data/lib/songkickr/setlist.rb +7 -12
  31. data/lib/songkickr/setlist_item.rb +1 -1
  32. data/lib/songkickr/tracking.rb +18 -0
  33. data/lib/songkickr/tracking_result.rb +24 -0
  34. data/lib/songkickr/venue.rb +10 -2
  35. data/lib/songkickr/venue_result.rb +32 -0
  36. data/lib/songkickr/version.rb +1 -1
  37. data/lib/songkickr.rb +24 -17
  38. data/songkickr.gemspec +17 -44
  39. data/test/fixtures/event_7391451.json +732 -1
  40. data/test/fixtures/location_search.json +38 -0
  41. data/test/fixtures/metro_area.json +11 -0
  42. data/test/fixtures/users_attendance_calendar.json +243 -0
  43. data/test/fixtures/vcr/artist_events.yml +1394 -0
  44. data/test/fixtures/vcr/artist_search.yml +38 -0
  45. data/test/fixtures/vcr/artists_gigography.yml +187 -0
  46. data/test/fixtures/vcr/concert_setlists.yml +47 -0
  47. data/test/fixtures/vcr/event_search.yml +110 -0
  48. data/test/fixtures/vcr/invalid_api_key.yml +6 -36
  49. data/test/fixtures/vcr/invalid_artist_id.yml +6 -6
  50. data/test/fixtures/vcr/invalid_event_id.yml +6 -6
  51. data/test/fixtures/vcr/invalid_user.yml +6 -6
  52. data/test/fixtures/vcr/invalid_venue_id.yml +6 -6
  53. data/test/fixtures/vcr/location_search.yml +42 -0
  54. data/test/fixtures/vcr/metro_areas_events.yml +1535 -0
  55. data/test/fixtures/vcr/similar_artists.yml +64 -0
  56. data/test/fixtures/vcr/users_artist_tracking.yml +99 -0
  57. data/test/fixtures/vcr/users_attendance.yml +66 -0
  58. data/test/fixtures/vcr/users_attendance_calendar.yml +51 -0
  59. data/test/fixtures/vcr/users_events.yml +809 -0
  60. data/test/fixtures/vcr/users_gigography.yml +2782 -0
  61. data/test/fixtures/vcr/users_metro_area_tracking.yml +66 -0
  62. data/test/fixtures/vcr/users_muted_artists.yml +66 -0
  63. data/test/fixtures/vcr/users_tracked_artists.yml +75 -0
  64. data/test/fixtures/vcr/users_tracked_events_calendar.yml +1901 -0
  65. data/test/fixtures/vcr/users_tracked_metro_areas.yml +37 -0
  66. data/test/fixtures/vcr/valid_artist.yml +9 -9
  67. data/test/fixtures/vcr/valid_event.yml +103 -38
  68. data/test/fixtures/vcr/valid_user.yml +634 -44
  69. data/test/fixtures/vcr/valid_venue.yml +25 -26
  70. data/test/fixtures/vcr/venue_calendar.yml +500 -0
  71. data/test/fixtures/vcr/venue_search.yml +42 -0
  72. data/test/helper.rb +1 -27
  73. data/test/songkickr/test_calendar_entry.rb +15 -0
  74. data/test/songkickr/test_event.rb +8 -9
  75. data/test/songkickr/test_location.rb +11 -11
  76. data/test/songkickr/test_metro_area.rb +17 -0
  77. data/test/songkickr/test_remote.rb +149 -3
  78. data/test/songkickr/test_setlist_item.rb +20 -0
  79. data/test/songkickr/test_venue.rb +1 -2
  80. data/test.rb +3 -5
  81. metadata +120 -152
  82. data/bin/autospec +0 -16
  83. data/bin/convert_to_should_syntax +0 -16
  84. data/bin/guard +0 -16
  85. data/bin/htmldiff +0 -16
  86. data/bin/httparty +0 -16
  87. data/bin/jeweler +0 -16
  88. data/bin/ldiff +0 -16
  89. data/bin/rake +0 -16
  90. data/bin/rake2thor +0 -16
  91. data/bin/rg +0 -16
  92. data/bin/ri +0 -16
  93. data/bin/rspec +0 -16
  94. data/bin/thor +0 -16
  95. data/doc/APIError.html +0 -241
  96. data/doc/APIKeyNotSet.html +0 -203
  97. data/doc/LICENSE.html +0 -133
  98. data/doc/README_rdoc.html +0 -173
  99. data/doc/ResourceNotFound.html +0 -203
  100. data/doc/Songkickr/Artist.html +0 -278
  101. data/doc/Songkickr/ArtistResult.html +0 -308
  102. data/doc/Songkickr/ConcertSetlistResult.html +0 -283
  103. data/doc/Songkickr/Event.html +0 -491
  104. data/doc/Songkickr/EventResult.html +0 -306
  105. data/doc/Songkickr/Location.html +0 -299
  106. data/doc/Songkickr/LocationResult.html +0 -309
  107. data/doc/Songkickr/Performance.html +0 -295
  108. data/doc/Songkickr/Remote.html +0 -864
  109. data/doc/Songkickr/Setlist.html +0 -360
  110. data/doc/Songkickr/SetlistItem.html +0 -244
  111. data/doc/Songkickr/Venue.html +0 -265
  112. data/doc/Songkickr.html +0 -261
  113. data/doc/created.rid +0 -16
  114. data/doc/images/add.png +0 -0
  115. data/doc/images/brick.png +0 -0
  116. data/doc/images/brick_link.png +0 -0
  117. data/doc/images/bug.png +0 -0
  118. data/doc/images/bullet_black.png +0 -0
  119. data/doc/images/bullet_toggle_minus.png +0 -0
  120. data/doc/images/bullet_toggle_plus.png +0 -0
  121. data/doc/images/date.png +0 -0
  122. data/doc/images/delete.png +0 -0
  123. data/doc/images/find.png +0 -0
  124. data/doc/images/loadingAnimation.gif +0 -0
  125. data/doc/images/macFFBgHack.png +0 -0
  126. data/doc/images/package.png +0 -0
  127. data/doc/images/page_green.png +0 -0
  128. data/doc/images/page_white_text.png +0 -0
  129. data/doc/images/page_white_width.png +0 -0
  130. data/doc/images/plugin.png +0 -0
  131. data/doc/images/ruby.png +0 -0
  132. data/doc/images/tag_blue.png +0 -0
  133. data/doc/images/tag_green.png +0 -0
  134. data/doc/images/transparent.png +0 -0
  135. data/doc/images/wrench.png +0 -0
  136. data/doc/images/wrench_orange.png +0 -0
  137. data/doc/images/zoom.png +0 -0
  138. data/doc/index.html +0 -110
  139. data/doc/js/darkfish.js +0 -153
  140. data/doc/js/jquery.js +0 -18
  141. data/doc/js/navigation.js +0 -142
  142. data/doc/js/quicksearch.js +0 -114
  143. data/doc/js/search.js +0 -94
  144. data/doc/js/search_index.js +0 -1
  145. data/doc/js/searcher.js +0 -228
  146. data/doc/js/thickbox-compressed.js +0 -10
  147. data/doc/lib/songkickr/artist_rb.html +0 -52
  148. data/doc/lib/songkickr/artist_result_rb.html +0 -52
  149. data/doc/lib/songkickr/concert_setlist_result_rb.html +0 -52
  150. data/doc/lib/songkickr/event_rb.html +0 -52
  151. data/doc/lib/songkickr/event_result_rb.html +0 -52
  152. data/doc/lib/songkickr/location_rb.html +0 -52
  153. data/doc/lib/songkickr/location_result_rb.html +0 -52
  154. data/doc/lib/songkickr/performance_rb.html +0 -52
  155. data/doc/lib/songkickr/remote_rb.html +0 -52
  156. data/doc/lib/songkickr/setlist_item_rb.html +0 -52
  157. data/doc/lib/songkickr/setlist_rb.html +0 -52
  158. data/doc/lib/songkickr/venue_rb.html +0 -52
  159. data/doc/lib/songkickr_rb.html +0 -56
  160. data/doc/rdoc.css +0 -543
  161. data/doc/table_of_contents.html +0 -185
  162. data/test/fixtures/locations_bar.json +0 -1
@@ -1,205 +1,34 @@
1
+ Dir[File.dirname(__FILE__) + '/remote_api/*.rb'].each { |file| require file }
2
+
1
3
  module Songkickr
2
4
  # Create an instance of the remote class to interact with the Songkick API.
3
5
  class Remote
4
6
  include HTTParty
7
+ include Songkickr::RemoteApi::UpcomingEvents
8
+ include Songkickr::RemoteApi::UserEventsAndTrackings
9
+ include Songkickr::RemoteApi::PastEvents
10
+ include Songkickr::RemoteApi::ArtistDetails
11
+ include Songkickr::RemoteApi::EventDetails
12
+ include Songkickr::RemoteApi::VenueDetails
13
+ include Songkickr::RemoteApi::SimilarArtists
14
+
15
+ attr_accessor :debug
16
+ attr_reader :api_key
17
+
5
18
  base_uri 'api.songkick.com/api/3.0'
6
19
  format :json
7
20
 
8
- attr_reader :api_key
9
-
10
21
  # ==== Create a new instance of the remote class to talk to Songkick
11
22
  # Get an API key for your app from http://developer.songkick.com/
12
- def initialize(api_key = nil)
23
+ def initialize(api_key = nil, options = {})
13
24
  @api_key = api_key
14
25
  @api_key ||= Songkickr.api_key
26
+ @debug = options[:debug] || false
15
27
 
16
28
  self.class.default_params :apikey => @api_key
17
- end
18
-
19
- # ==== Event Search API
20
- # http://www.songkick.com/developer/event-search
21
- #
22
- # === Parameters
23
- # * +query+ - A hash of query parameters, see below for options.
24
- #
25
- # _Example:_ <code>{ :type => 'concert', :artists => 'Coolio' }</code>
26
- #
27
- # ==== Query Parameters
28
- # * +type+ - valid types: concert or festival
29
- # * +artists+ - events by any of the artists, comma-separated
30
- # * +artist_name+ - plain text name of artist ex. 'As I Lay Dying', 'Parkway Drive', 'Animals As Leaders'
31
- # * +artist_id+ - Songkick unique ID for an artist
32
- # * +venue_id+ - Songkick unique ID for a venue
33
- # * +setlist_item_name+ - name of a song which was played at the event – use with artist_id or artist_name
34
- # * +min_date+ - Oldest date for which you want to look for events
35
- # * +max_date+ - Most recent date for which you want to look for events
36
- # * +location+ - See the Songkick website for instructions on how to use the location parameter http://www.songkick.com/developer/location-search
37
- def events(query = {})
38
- path = extract_path_from_query(query)
39
- result = get("#{path}/events.json", :query => query)
40
- Songkickr::EventResult.new result
41
- end
42
-
43
- # ==== Event API
44
- # http://www.songkick.com/developer/upcoming-events
45
- #
46
- # Getting detailed information of a single event.
47
- #
48
- # === Parameters
49
- # * +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.
50
- def event(event_id)
51
- result = get("/events/#{event_id}.json")
52
- Songkickr::Event.new result["resultsPage"]["results"]["event"]
53
- end
54
-
55
- # ==== Gigography API
56
- # http://groups.google.com/group/songkick-api/browse_thread/thread/af15b9a6ad3c3513#
57
- #
58
- # === Parameters
59
- # * +artist_id+ - Songkick artist_id, use artist_search to get it
60
- # * +query+ - A hash of query parameters, see below for options.
61
- #
62
- # ==== Query Parameters
63
- # * +min_date+ - Oldest date for which you want to look for events
64
- # * +max_date+ - Most recent date for which you want to look for events
65
- # * +per_page+ - Number of items on a page
66
- # * +page+ - Number of page
67
- def gigography(artist_id, query= {})
68
- result = get("/artists/#{artist_id}/gigography.json",:query=>query)
69
- Songkickr::EventResult.new result
70
- end
71
-
72
- # === Artist API
73
- # Undocumented, but it works fine
74
- #
75
- # Returns an artist object
76
- #
77
- # === Parameters
78
- # * +artist_id+ - Songkick artist_id, use artist_search to get it
79
- def artist(artist_id)
80
- result = get("/artists/#{artist_id}.json")
81
- Songkickr::Artist.new result["resultsPage"]["results"]["artist"]
82
- end
83
-
84
- # ==== Artist Search API
85
- # Returns Artist objects.
86
- #
87
- # http://www.songkick.com/developer/artist-search
88
- #
89
- # === Parameters
90
- # * +query+ - Search for artists by name using full text search. Results from Songkick are returned by relevancy.
91
- #
92
- # ==== Query Parameters
93
- # * +artist_name+ - Name of an artist. <em>Ex. 'Lady Gaga', 'Slayer', 'Atmosphere'</em>
94
- def artist_search(query={})
95
- result = get("/search/artists.json", :query => query)
96
- Songkickr::ArtistResult.new result
97
- end
98
-
99
- # ==== Artist calendar (Upcoming)
100
- # Returns an array of Events.
101
- #
102
- # http://www.songkick.com/developer/upcoming-events-for-artist
103
- #
104
- # === Parameters
105
- # * +artist_id+ - Songkick unique ID for artist. Use artist_search to find an artist ID.
106
- # * +query+ - A hash of query parameters, see below for options.
107
- #
108
- # ==== Query Parameters
109
- # * +page+ - Page number
110
- # * +per_page+ - Number of results per page, max 50.
111
- def artist_events(artist_id, query = {})
112
- result = get("/artists/#{artist_id}/calendar.json", :query => query)
113
- Songkickr::EventResult.new result
114
- end
115
-
116
- # ==== User Events API
117
- # http://www.songkick.com/developer/upcoming-events-for-user
118
- #
119
- # === Parameters
120
- # * +username+ - A Songkick username.
121
- # * +query+ - A hash of query parameters, see below for options.
122
- #
123
- # ==== Query Parameters
124
- # * +attendance+ (all, im_going, i_might_go) - defaults to im_going
125
- # * +type+ (concert or festival)
126
- # * +artists+ (events by any of the artists, comma-separated)
127
- # * +artist_id+ - Songkick unique ID for an artist
128
- # * +venue_id+ - Songkick unique ID for a venue
129
- # * +setlist_item_name+ (name of a song which was played at the event – use with artist_id or artist_name)
130
- # * +min_date+ - Oldest date for which you want to look for events
131
- # * +max_date+ - Most recent date for which you want to look for events
132
- # * +location+ - see the Songkick website for instructions on how to use the location parameter
133
- def users_events(username, query = {})
134
- result = get("/users/#{username}/events.json", :query => query)
135
- Songkickr::EventResult.new result
136
- end
137
-
138
- # ==== User Tracked Artists
139
- # http://www.songkick.com/developer/trackings
140
- #
141
- # === Parameters
142
- # * +username+ - A Songkick username.
143
- # * +query+ - A hash of query parameters, see below for options.
144
- #
145
- # ==== Query Parameters
146
- # * +page+ - Page number
147
- # * +per_page+ - Number of results per page, max 50.
148
- def users_tracked_artists(username, query = {})
149
- result = get("/users/#{username}/artists/tracked.json", :query => query)
150
- Songkickr::ArtistResult.new result
151
- end
152
-
153
- # ==== Metro Area Events (Upcoming)
154
- # Returns an array of Events.
155
- #
156
- # http://www.songkick.com/developer/upcoming-events-for-metro-area
157
- #
158
- # === Parameters
159
- # * +metro_area_id+ - Songkick unique ID for metro areas. Use location_search to find a metro area ID.
160
- # * +query+ - A hash of query parameters, see below for options.
161
- #
162
- # ==== Query Parameters
163
- # * +page+ - Page number
164
- # * +per_page+ - Number of results per page, max 50.
165
- def metro_areas_events(metro_area_id, query = {})
166
- result = get("/metro_areas/#{metro_area_id}/calendar.json", :query => query)
167
- Songkickr::EventResult.new result
168
- end
169
-
170
- # ==== Concert Setlists API
171
- # http://www.songkick.com/developer/setlists
172
- #
173
- # === Parameters
174
- #
175
- # * +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.
176
- def concert_setlists(event_id)
177
- result = get("/events/#{event_id}/setlists.json")
178
- Songkickr::ConcertSetlistResult.new result
179
- end
180
-
181
- # ==== Location Search API
182
- # http://www.songkick.com/developer/location-search
183
- #
184
- # === Parameters
185
- # * +query+ - A hash of query parameters, see below for options.
186
- #
187
- # ==== Query Parameters
188
- # * +location+ - 'geo:{lat,lng}' string <em>Ex. 'geo:{-0.128,51.5078}'</em>
189
- def location_search(query = {})
190
- result = get("/search/locations.json", :query => query)
191
- Songkickr::LocationResult.new result
192
- end
193
-
194
- # ==== Venue Search
195
- # http://www.songkick.com/developer/venue-details
196
- #
197
- # === Parameters
198
- #
199
- # * +venue_id+ - Songkick venue ID.
200
- def venue(venue_id)
201
- result = get("/venues/#{venue_id}.json")
202
- Songkickr::Venue.new result['resultsPage']['results']['venue']
29
+ if @debug
30
+ self.class.debug_output $stderr
31
+ end
203
32
  end
204
33
 
205
34
  def get(location, query_params = {})
@@ -212,14 +41,5 @@ module Songkickr
212
41
  end
213
42
  result
214
43
  end
215
-
216
-
217
- private
218
-
219
- # Given a query, look for an mbid key and return a path to access it.
220
- def extract_path_from_query(query = {})
221
- mbid = query.delete :mbid
222
- "/artists/mbid:#{mbid}" if mbid
223
- end
224
44
  end
225
45
  end
@@ -0,0 +1,17 @@
1
+ module Songkickr
2
+ module RemoteApi
3
+ module ArtistDetails
4
+ # === Artist API
5
+ # Undocumented, but it works fine
6
+ #
7
+ # Getting detailed information of a single artist.
8
+ #
9
+ # === Parameters
10
+ # * +artist_id+ - Songkick artist_id, use artist_search to get it
11
+ def artist(artist_id)
12
+ result = get("/artists/#{artist_id}.json")
13
+ Songkickr::Artist.new result["resultsPage"]["results"]["artist"]
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ module Songkickr
2
+ module RemoteApi
3
+ module EventDetails
4
+ # ==== Event API
5
+ # http://www.songkick.com/developer/upcoming-events
6
+ #
7
+ # Getting detailed information of a single event.
8
+ #
9
+ # === Parameters
10
+ # * +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.
11
+ def event(event_id)
12
+ result = get("/events/#{event_id}.json")
13
+ Songkickr::Event.new result["resultsPage"]["results"]["event"]
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,48 @@
1
+ module Songkickr
2
+ module RemoteApi
3
+ module PastEvents
4
+ # ==== Artists Gigography API
5
+ # https://www.songkick.com/developer/past-events-for-artist
6
+ #
7
+ # === Parameters
8
+ # * +artist_id+ - Songkick artist_id, use artist_search to get it
9
+ # * +query+ - A hash of query parameters, see below for options.
10
+ #
11
+ # ==== Query Parameters
12
+ # * +per_page+ - Number of items on a page
13
+ # * +page+ - Number of page
14
+ # * +order+ - 'asc' or 'desc', 'asc' by default
15
+ def artists_gigography(artist_id, query = {})
16
+ result = self.class.get("/artists/#{artist_id}/gigography.json", :query => query)
17
+ Songkickr::EventResult.new result
18
+ end
19
+
20
+ # ==== User’s past events (gigography)
21
+ # https://www.songkick.com/developer/past-events-for-user
22
+ #
23
+ # === Parameters
24
+ # * +username+ - A Songkick username
25
+ # * +query+ - A hash of query parameters, see below for options.
26
+ #
27
+ # ==== Query Parameters
28
+ # * +per_page+ - Number of items on a page
29
+ # * +page+ - Number of page
30
+ # * +order+ - 'asc' or 'desc', 'asc' by default
31
+ def users_gigography(username, query = {})
32
+ result = self.class.get("/users/#{username}/gigography.json", :query => query)
33
+ Songkickr::EventResult.new result
34
+ end
35
+
36
+ # ==== Concert Setlists API
37
+ # http://www.songkick.com/developer/setlists
38
+ #
39
+ # === Parameters
40
+ #
41
+ # * +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.
42
+ def concert_setlists(event_id)
43
+ result = get("/events/#{event_id}/setlists.json")
44
+ Songkickr::ConcertSetlistResult.new result
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,14 @@
1
+ module Songkickr
2
+ module RemoteApi
3
+ module SimilarArtists
4
+ # ==== Similar Artists
5
+ # Returns an array of Artists similar to a given artist, based on tracking and attendance data
6
+ #
7
+ # https://www.songkick.com/developer/similar-artists
8
+ def similar_artists(artist_id)
9
+ result = get("/artists/#{artist_id}/similar_artists.json")
10
+ Songkickr::ArtistResult.new result
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,125 @@
1
+ module Songkickr
2
+ module RemoteApi
3
+ module UpcomingEvents
4
+ # ==== Artist calendar (Upcoming)
5
+ # Returns an array of Events.
6
+ #
7
+ # ex. remote.artist_events('mbid:5bac9b4f-2f1c-4d39-8d11-231d5b6650ce', :page => 1, :per_page => 5, :order => 'desc')
8
+ #
9
+ # http://www.songkick.com/developer/upcoming-events-for-artist
10
+ #
11
+ # === Parameters
12
+ # * +artist_id_or_music_brainz_id+ - Songkick unique ID for artist. Use artist_search to find an artist ID. Or a MusicBrainz.org id string. ex. mbid:5bac9b4f-2f1c-4d39-8d11-231d5b6650ce
13
+ # * +query+ - A hash of query parameters, see below for options.
14
+ #
15
+ # ==== Query Parameters
16
+ # * +page+ - Page number
17
+ # * +per_page+ - Number of results per page, max 50.
18
+ # * +order+ - Results are sorted by date. The order can be specified with: order ('asc' or 'desc', 'asc' by default).
19
+ def artist_events(artist_id_or_music_brainz_id, query = {})
20
+ if artist_id_or_music_brainz_id.to_s.match /^mbid\:\d+$/
21
+ url = "/artists/mbid:#{artist_id_or_music_brainz_id}/calendar.json"
22
+ else
23
+ url = "/artists/#{artist_id_or_music_brainz_id}/calendar.json"
24
+ end
25
+
26
+ result = get(url, :query => query)
27
+ Songkickr::EventResult.new result
28
+ end
29
+
30
+ # ==== Artist Search API
31
+ # Returns Artist objects.
32
+ #
33
+ # http://www.songkick.com/developer/artist-search
34
+ #
35
+ # === Parameters
36
+ # * +query+ - Search for artists by name using full text search. Results from Songkick are returned by relevancy.
37
+ #
38
+ # ==== Query Parameters
39
+ # * +artist_name+ - Name of an artist. <em>Ex. 'Lady Gaga', 'Slayer', 'Atmosphere'</em>
40
+ def artist_search(query = {})
41
+ result = self.class.get("/search/artists.json", :query => { :query => query })
42
+ Songkickr::ArtistResult.new result
43
+ end
44
+
45
+ # ==== Event Search API
46
+ # http://www.songkick.com/developer/event-search
47
+ #
48
+ # === Parameters
49
+ # * +query+ - A hash of query parameters, see below for options.
50
+ #
51
+ # _Example:_ <code>{ :type => 'concert', :artists => 'Coolio' }</code>
52
+ #
53
+ # ==== Query Parameters
54
+ # * +type+ - valid types: concert or festival
55
+ # * +artists+ - events by any of the artists, comma-separated
56
+ # * +artist_name+ - plain text name of artist ex. 'As I Lay Dying', 'Parkway Drive', 'Animals As Leaders'
57
+ # * +artist_id+ - Songkick unique ID for an artist
58
+ # * +venue_id+ - Songkick unique ID for a venue
59
+ # * +setlist_item_name+ - name of a song which was played at the event – use with artist_id or artist_name
60
+ # * +min_date+ - Oldest date for which you want to look for events
61
+ # * +max_date+ - Most recent date for which you want to look for events
62
+ # * +location+ - See the Songkick website for instructions on how to use the location parameter http://www.songkick.com/developer/location-search
63
+ def events(query = {})
64
+ result = get("/events.json", :query => query)
65
+ Songkickr::EventResult.new result
66
+ end
67
+
68
+ # ==== Location Search API
69
+ # http://www.songkick.com/developer/location-search
70
+ #
71
+ # === Parameters
72
+ # * +query+ - A hash of query parameters, see below for options.
73
+ #
74
+ # ==== Query Parameters
75
+ # * +name+ - Metro area or city named 'location_name' string <em>Ex. 'Minneapolis, Nashville, or London'</em>
76
+ # * +location+ - 'geo:{lat,lng}' string <em>Ex. 'geo:{-0.128,51.5078}'</em>
77
+ # * +ip+ - 'ip:{ip-addr}' string <em>Ex. 'ip:{123.123.123.123}'</em>
78
+ # * +page+ - Page number
79
+ # * +per_page+ - Number of results per page, max 50.
80
+ def location_search(query = {})
81
+ result = get("/search/locations.json", :query => { :query => query })
82
+ Songkickr::LocationResult.new result
83
+ end
84
+
85
+ # ==== Metro Area Events (Upcoming)
86
+ # Returns an array of Events.
87
+ #
88
+ # http://www.songkick.com/developer/upcoming-events-for-metro-area
89
+ #
90
+ # === Parameters
91
+ # * +metro_area_id+ - Songkick unique ID for metro areas. Use location_search to find a metro area ID.
92
+ # * +query+ - A hash of query parameters, see below for options.
93
+ #
94
+ # ==== Query Parameters
95
+ # * +page+ - Page number
96
+ # * +per_page+ - Number of results per page, max 50.
97
+ def metro_areas_events(metro_area_id, query = {})
98
+ result = get("/metro_areas/#{metro_area_id}/calendar.json", :query => query)
99
+ Songkickr::EventResult.new result
100
+ end
101
+
102
+ # ==== Venue Calendar
103
+ # https://www.songkick.com/developer/upcoming-events-for-venue
104
+ #
105
+ # === Parameters
106
+ #
107
+ # * +venue_id+ - Songkick venue ID.
108
+ def venue_calendar(venue_id)
109
+ result = get("/venues/#{venue_id}/calendar.json")
110
+ Songkickr::EventResult.new result
111
+ end
112
+
113
+ # ==== Venue Search
114
+ # https://www.songkick.com/developer/venue-search
115
+ #
116
+ # === Parameters
117
+ #
118
+ # * +query+ -
119
+ def venue_search(query)
120
+ result = get("/search/venues.json", :query => { :query => query })
121
+ Songkickr::VenueResult.new result
122
+ end
123
+ end
124
+ end
125
+ end
@@ -0,0 +1,143 @@
1
+ module Songkickr
2
+ module RemoteApi
3
+ module UserEventsAndTrackings
4
+ # ==== Users Tracked Events Calendar
5
+ # Returns a list of calendar entries with events for a user's tracked artists in her tracked metro areas.
6
+ # /users/#{username}/calendar.json?reason=tracked_artist
7
+ #
8
+ # === Parameters
9
+ # * +username+ - A Songkick username.
10
+ # * +query+ - A hash of query parameters, see below for options.
11
+ #
12
+ # ==== Query Parameters
13
+ # * +page+ - Page number
14
+ # * +per_page+ - Number of results per page, max 50.
15
+ def users_tracked_events_calendar(username, query = {})
16
+ result = get("/users/#{username}/calendar.json?reason=tracked_artist", :query => query)
17
+ Songkickr::CalendarResult.new result
18
+ end
19
+
20
+ # ==== User Attendance Calendar
21
+ # Returns a list of calendar entries with events that a user is planning to attend.
22
+ # /users/#{username}/calendar.json?reason=attendance
23
+ #
24
+ # === Parameters
25
+ # * +username+ - A Songkick username.
26
+ # * +query+ - A hash of query parameters, see below for options.
27
+ #
28
+ # ==== Query Parameters
29
+ # * +page+ - Page number
30
+ # * +per_page+ - Number of results per page, max 50.
31
+ def users_attendance_calendar(username, query = {})
32
+ result = get("/users/#{username}/calendar.json?reason=attendance", :query => query)
33
+ Songkickr::CalendarResult.new result
34
+ end
35
+
36
+
37
+ # ==== User Tracked Metro Areas
38
+ # http://www.songkick.com/developer/trackings
39
+ #
40
+ # === Parameters
41
+ # * +username+ - A Songkick username.
42
+ # * +query+ - A hash of query parameters, see below for options.
43
+ #
44
+ # ==== Query Parameters
45
+ # * +page+ - Page number
46
+ # * +per_page+ - Number of results per page, max 50.
47
+ def users_tracked_metro_areas(username, query = {})
48
+ result = get("/users/#{username}/metro_areas/tracked.json", :query => query)
49
+ Songkickr::MetroAreaResult.new result
50
+ end
51
+
52
+ # ==== User Metro Area Tracking
53
+ # http://www.songkick.com/developer/trackings
54
+ #
55
+ # === Parameters
56
+ # * +username+ - A Songkick username.
57
+ # * +metro_area_id+ - A Songkick metro area ID.
58
+ # * +query+ - A hash of query parameters, see below for options.
59
+ def users_metro_area_tracking(username, metro_area_id, query = {})
60
+ result = get("/users/#{username}/trackings/metro_area:#{metro_area_id}.json", :query => query)
61
+ Songkickr::MetroAreaResult.new result
62
+ end
63
+
64
+ # ==== User Tracked Artists
65
+ # http://www.songkick.com/developer/trackings
66
+ #
67
+ # === Parameters
68
+ # * +username+ - A Songkick username.
69
+ # * +query+ - A hash of query parameters, see below for options.
70
+ #
71
+ # ==== Query Parameters
72
+ # * +page+ - Page number
73
+ # * +per_page+ - Number of results per page, max 50.
74
+ def users_tracked_artists(username, query = {})
75
+ result = get("/users/#{username}/artists/tracked.json", :query => query)
76
+ Songkickr::ArtistResult.new result
77
+ end
78
+
79
+ # ==== User Artist Tracking
80
+ # http://www.songkick.com/developer/trackings
81
+ #
82
+ # === Parameters
83
+ # * +username+ - A Songkick username.
84
+ # * +artist_id+ - A Songkick artist ID.
85
+ def users_artist_tracking(username, artist_id)
86
+ result = get("/users/#{username}/trackings/artist:#{artist_id}.json")
87
+ Songkickr::ArtistResult.new result
88
+ end
89
+
90
+ # ==== User Muted Artists
91
+ # http://www.songkick.com/developer/trackings
92
+ #
93
+ # === Parameters
94
+ # * +username+ - A Songkick username.
95
+ # * +query+ - A hash of query parameters, see below for options.
96
+ #
97
+ # ==== Query Parameters
98
+ # * +page+ - Page number
99
+ # * +per_page+ - Number of results per page, max 50.
100
+ def users_muted_artists(username, query = {})
101
+ result = get("/users/#{username}/artists/muted.json", :query => query)
102
+ Songkickr::ArtistResult.new result
103
+ end
104
+
105
+ # ==== User Events API
106
+ # http://www.songkick.com/developer/upcoming-events-for-user
107
+ #
108
+ # === Parameters
109
+ # * +username+ - A Songkick username.
110
+ # * +query+ - A hash of query parameters, see below for options.
111
+ #
112
+ # ==== Query Parameters
113
+ # * +page+ - Page number
114
+ # * +per_page+ - Number of results per page, max 50.
115
+ # * +attendance+ (all, im_going, i_might_go) - defaults to im_going
116
+ # * +type+ (concert or festival)
117
+ # * +artists+ (events by any of the artists, comma-separated)
118
+ # * +artist_id+ - Songkick unique ID for an artist
119
+ # * +venue_id+ - Songkick unique ID for a venue
120
+ # * +setlist_item_name+ (name of a song which was played at the event – use with artist_id or artist_name)
121
+ # * +min_date+ - Oldest date for which you want to look for events
122
+ # * +max_date+ - Most recent date for which you want to look for events
123
+ # * +location+ - see the Songkick website for instructions on how to use the location parameter
124
+ # * +order+ - 'asc' or 'desc', 'asc' by default
125
+ # * +created_after+ - timestamp using ISO8601 format, e.g. 2012-02-29T13:37:00Z
126
+ def users_events(username, query = {})
127
+ result = get("/users/#{username}/events.json", :query => query)
128
+ Songkickr::EventResult.new result
129
+ end
130
+
131
+ # ==== User Attendance
132
+ # http://www.songkick.com/developer/trackings
133
+ #
134
+ # === Parameters
135
+ # * +username+ - A Songkick username.
136
+ # * +event_id+ - A Songkick event/concert ID.
137
+ def users_attendance(username, event_id)
138
+ result = get("/users/#{username}/trackings/event:#{event_id}.json")
139
+ Songkickr::TrackingResult.new result
140
+ end
141
+ end
142
+ end
143
+ end
@@ -0,0 +1,16 @@
1
+ module Songkickr
2
+ module RemoteApi
3
+ module VenueDetails
4
+ # ==== Venue Details
5
+ # http://www.songkick.com/developer/venue-details
6
+ #
7
+ # === Parameters
8
+ #
9
+ # * +venue_id+ - Songkick venue ID.
10
+ def venue(venue_id)
11
+ result = get("/venues/#{venue_id}.json")
12
+ Songkickr::Venue.new result['resultsPage']['results']['venue']
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,27 @@
1
+ module Songkickr
2
+ class ResultSet
3
+ attr_accessor :page, :per_page, :total_entries, :results, :result_type, :result_key_string, :status
4
+
5
+ def initialize(result_hash = {})
6
+ # @result_type = "Event" or "MetroArea"
7
+ results_page = result_hash["resultsPage"]
8
+
9
+ if results_page
10
+ @status = results_page["status"] if results_page.include? "status"
11
+ @page = results_page["page"] if results_page.include? "page"
12
+ @per_page = results_page["per_page"] if results_page.include? "per_page"
13
+ @total_entries = results_page["totalEntries"] if results_page.include? "totalEntries"
14
+ @results = parse_results results_page["results"] if results_page.include? "results"
15
+ end
16
+ end
17
+
18
+ protected
19
+
20
+ def parse_results(results = {})
21
+ return [] unless results.include? result_key_string
22
+ results[result_key_string].inject([]) do |result_items, result_item|
23
+ result_items << eval("Songkickr::#{result_type}.new(#{result_item})")
24
+ end
25
+ end
26
+ end
27
+ end