songkick_ruby 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,16 +2,16 @@ module Songkick
2
2
  class Client
3
3
  module Calendar
4
4
 
5
- def artist_calendar(artist_id)
6
- get "artists/#{artist_id}/calendar.#{format}"
5
+ def artist_calendar(artist_id, page = 1)
6
+ get "artists/#{artist_id}/calendar.#{format}", page
7
7
  end
8
8
 
9
- def location_calendar(location_id)
10
- get "metro_areas/#{location_id}/calendar.#{format}"
9
+ def location_calendar(location_id, page = 1)
10
+ get "metro_areas/#{location_id}/calendar.#{format}", page
11
11
  end
12
12
 
13
- def user_calendar(username)
14
- get "users/#{artist_id}/calendar.#{format}"
13
+ def user_calendar(username, page = 1)
14
+ get "users/#{artist_id}/calendar.#{format}", page
15
15
  end
16
16
 
17
17
  end
@@ -2,8 +2,8 @@ module Songkick
2
2
  class Client
3
3
  module Event
4
4
 
5
- def find_event(event_id)
6
- get "events/#{event_id}.#{format}"
5
+ def find_event(event_id, page = 1)
6
+ get "events/#{event_id}.#{format}", page
7
7
  end
8
8
 
9
9
  end
@@ -4,14 +4,21 @@ module Songkick
4
4
 
5
5
  private
6
6
 
7
- def get(url)
8
- uri = API_URL + url
9
- uri = URI.parse uri.include?("?") ? uri + "&apikey=#{api_key}" : uri + "?apikey=#{api_key}"
10
-
7
+ def get(url, page)
8
+ uri = generate_uri(url, page)
9
+
11
10
  response = Net::HTTP.get_response(uri)
12
11
  json? ? JSON.parse(response.body) : response.body
13
12
  end
14
13
 
14
+ def generate_uri(url, page)
15
+ uri = API_URL + url
16
+ uri += uri.include?("?") ? "&page=#{page}" : "?page=#{page}" if page.to_i > 1
17
+ uri = URI.parse uri.include?("?") ? uri + "&apikey=#{api_key}" : uri + "?apikey=#{api_key}"
18
+ print
19
+ uri
20
+ end
21
+
15
22
  end
16
23
  end
17
24
  end
@@ -2,21 +2,21 @@ module Songkick
2
2
  class Client
3
3
  module Search
4
4
 
5
- def search_events(opts)
5
+ def search_events(opts, page = 1)
6
6
  _opts = opts.collect{|k, v| "#{k}=#{v.gsub(" ", "%20")}"}.join("&")
7
- get "events.#{format}?#{_opts}"
7
+ get "events.#{format}?#{_opts}", page
8
8
  end
9
9
  alias_method :search_event, :search_events
10
10
 
11
11
 
12
- def search_locations(opts)
12
+ def search_locations(opts, page = 1)
13
13
  _opts = opts.collect{|k, v| "#{k}=#{v.gsub(" ", "%20")}"}.join("&")
14
- get "search/locations.#{format}?#{_opts}"
14
+ get "search/locations.#{format}?#{_opts}", page
15
15
  end
16
16
  alias_method :search_location, :search_locations
17
17
 
18
- def search_artists(text)
19
- get "search/artists.#{format}?query=#{text.gsub(" ","%20")}"
18
+ def search_artists(text, page = 1)
19
+ get "search/artists.#{format}?query=#{text.gsub(" ","%20")}", page
20
20
  end
21
21
  alias_method :search_artist, :search_artists
22
22
 
@@ -10,7 +10,7 @@ module Songkick
10
10
 
11
11
  attr_accessor :api_key, :format
12
12
 
13
- def initialize(api_key, format)
13
+ def initialize(api_key, format = :json)
14
14
  @api_key = api_key
15
15
  @format = format
16
16
  end
@@ -1,3 +1,3 @@
1
1
  module Songkick
2
- VERSION = '1.0.0'
2
+ VERSION = '1.1.0'
3
3
  end
data/lib/songkick.rb CHANGED
@@ -7,8 +7,8 @@ require "songkick/client.rb"
7
7
 
8
8
  module Songkick
9
9
  class << self
10
-
11
- def new(api_key, format)
10
+
11
+ def new(api_key, format = :json)
12
12
  Songkick::Client.new(api_key, format)
13
13
  end
14
14
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "songkick_ruby"
3
- s.version = "1.0.0"
3
+ s.version = "1.1.0"
4
4
  s.author = "Gregory Marcilhacy"
5
5
  s.email = "g.marcilhacy@gmail.com"
6
6
  s.homepage = "http://github.com/gregorym/songkick_ruby"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: songkick_ruby
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
+ - 1
8
9
  - 0
9
- - 0
10
- version: 1.0.0
10
+ version: 1.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Gregory Marcilhacy