seatgeek 0.1.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +31 -3
- data/.travis.yml +12 -6
- data/Gemfile +6 -7
- data/Gemfile.lock +31 -38
- data/{README.markdown → README.md} +12 -10
- data/lib/seat_geek/connection.rb +84 -35
- data/lib/seat_geek/version.rb +3 -1
- data/spec/fixtures/handle_response.json +1 -0
- data/spec/lib/seat_geek/connection_spec.rb +181 -122
- data/spec/lib/seat_geek/version_spec.rb +2 -2
- data/spec/lib/sg_spec.rb +1 -1
- data/spec/spec_helper.rb +0 -1
- metadata +52 -44
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7ea02bcbb451f64c78d3298bc0d9a580b80f0f4229955ec3b8e1a92248492580
|
4
|
+
data.tar.gz: 164188c7662ebabfb0f3719fd923ed8e6cf31afd0bc4898b9f6bef6c00b393d6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4d7670113e4596d936c93ff9e2e619770f5398354cf133f61a187e310131961d154700fd183770674456b0fa48ea6a5e69cbbd0595c6a8ecf34948ba6b332eb4
|
7
|
+
data.tar.gz: b382ea251fc3baa64fd0b66446922a1dcae28651b7355dec2b9c594bc35be5bcb8d097398ab1bbe54625acb8938e07d25b8e2f44a0b83828e44d2d6a20890a77
|
data/.gitignore
CHANGED
@@ -1,5 +1,33 @@
|
|
1
1
|
.DS_Store
|
2
|
-
|
3
|
-
*.
|
4
|
-
|
2
|
+
|
3
|
+
*.gem
|
4
|
+
*.rbc
|
5
|
+
/.config
|
6
|
+
/coverage/
|
7
|
+
/InstalledFiles
|
8
|
+
/pkg/
|
9
|
+
/spec/reports/
|
10
|
+
/spec/examples.txt
|
11
|
+
/test/tmp/
|
12
|
+
/test/version_tmp/
|
13
|
+
/tmp/
|
14
|
+
|
15
|
+
## Documentation cache and generated files:
|
16
|
+
/.yardoc/
|
17
|
+
/_yardoc/
|
18
|
+
/doc/
|
19
|
+
/rdoc/
|
20
|
+
|
21
|
+
## Environment normalization:
|
22
|
+
/.bundle/
|
23
|
+
/vendor/bundle
|
24
|
+
/lib/bundler/man/
|
25
|
+
|
26
|
+
# for a library or gem, you might want to ignore these files since the code is
|
27
|
+
# intended to run in multiple environments; otherwise, check them in:
|
28
|
+
# Gemfile.lock
|
29
|
+
.ruby-version
|
30
|
+
.ruby-gemset
|
31
|
+
|
32
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
5
33
|
.rvmrc
|
data/.travis.yml
CHANGED
@@ -1,8 +1,14 @@
|
|
1
|
-
bundler_args: --without no_travis
|
2
1
|
language: ruby
|
2
|
+
dist: xenial
|
3
|
+
os: linux
|
4
|
+
|
3
5
|
rvm:
|
4
|
-
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
- 2.5.3
|
7
|
+
|
8
|
+
before_install:
|
9
|
+
- gem install bundler
|
10
|
+
|
11
|
+
install: bundle install --retry=3
|
12
|
+
|
13
|
+
notifications:
|
14
|
+
email: false
|
data/Gemfile
CHANGED
@@ -1,17 +1,16 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
gem 'faraday'
|
4
|
-
gem 'multi_json'
|
5
|
-
gem 'rake'
|
6
|
-
gem 'yajl-ruby'
|
3
|
+
gem 'faraday', '~> 0.8.11'
|
4
|
+
gem 'multi_json', '~> 1.3.5'
|
5
|
+
gem 'rake', '~> 13.0.1'
|
6
|
+
gem 'yajl-ruby', '~> 1.3.1'
|
7
7
|
|
8
8
|
group :test do
|
9
|
-
gem 'rspec'
|
9
|
+
gem 'rspec', '~> 3.4.0'
|
10
10
|
end
|
11
11
|
|
12
12
|
group :no_travis do
|
13
|
-
gem 'awesome_print'
|
14
|
-
RUBY_VERSION =~ /^1\.9/ ? gem('ruby-debug19') : gem('ruby-debug')
|
13
|
+
gem 'awesome_print', '~> 1.8.0'
|
15
14
|
end
|
16
15
|
|
17
16
|
gemspec
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
seatgeek (0.
|
4
|
+
seatgeek (1.0.2)
|
5
5
|
faraday
|
6
6
|
multi_json
|
7
7
|
rake
|
@@ -10,46 +10,39 @@ PATH
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
rspec (
|
25
|
-
rspec-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
rspec-
|
30
|
-
diff-lcs (
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
linecache19 (>= 0.5.11)
|
35
|
-
ruby_core_source (>= 0.1.4)
|
36
|
-
ruby-debug19 (0.11.6)
|
37
|
-
columnize (>= 0.3.1)
|
38
|
-
linecache19 (>= 0.5.11)
|
39
|
-
ruby-debug-base19 (>= 0.11.19)
|
40
|
-
ruby_core_source (0.1.5)
|
41
|
-
archive-tar-minitar (>= 0.5.2)
|
42
|
-
yajl-ruby (1.1.0)
|
13
|
+
awesome_print (1.8.0)
|
14
|
+
diff-lcs (1.4.4)
|
15
|
+
faraday (0.8.11)
|
16
|
+
multipart-post (~> 1.2.0)
|
17
|
+
multi_json (1.3.7)
|
18
|
+
multipart-post (1.2.0)
|
19
|
+
rake (13.0.1)
|
20
|
+
rspec (3.4.0)
|
21
|
+
rspec-core (~> 3.4.0)
|
22
|
+
rspec-expectations (~> 3.4.0)
|
23
|
+
rspec-mocks (~> 3.4.0)
|
24
|
+
rspec-core (3.4.4)
|
25
|
+
rspec-support (~> 3.4.0)
|
26
|
+
rspec-expectations (3.4.0)
|
27
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
28
|
+
rspec-support (~> 3.4.0)
|
29
|
+
rspec-mocks (3.4.1)
|
30
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
31
|
+
rspec-support (~> 3.4.0)
|
32
|
+
rspec-support (3.4.1)
|
33
|
+
yajl-ruby (1.3.1)
|
43
34
|
|
44
35
|
PLATFORMS
|
45
36
|
ruby
|
46
37
|
|
47
38
|
DEPENDENCIES
|
48
|
-
awesome_print
|
49
|
-
faraday
|
50
|
-
multi_json
|
51
|
-
rake
|
52
|
-
rspec
|
53
|
-
ruby-debug19
|
39
|
+
awesome_print (~> 1.8.0)
|
40
|
+
faraday (~> 0.8.11)
|
41
|
+
multi_json (~> 1.3.5)
|
42
|
+
rake (~> 13.0.1)
|
43
|
+
rspec (~> 3.4.0)
|
54
44
|
seatgeek!
|
55
|
-
yajl-ruby
|
45
|
+
yajl-ruby (~> 1.3.1)
|
46
|
+
|
47
|
+
BUNDLED WITH
|
48
|
+
2.1.4
|
@@ -1,4 +1,4 @@
|
|
1
|
-
SeatGeek [![Build Status](https://secure.travis-ci.org/
|
1
|
+
SeatGeek [![Build Status](https://secure.travis-ci.org/seatshare/seatgeek.png)](http://travis-ci.org/seatshare/seatgeek)
|
2
2
|
========
|
3
3
|
SeatGeek maintains a canonical directory of live events in the United States. The SeatGeek Platform makes it easy to construct applications that help users find and discover events by exposing the wealth of data and powerful search behind SeatGeek.com in an easy-to-consume format.
|
4
4
|
|
@@ -9,8 +9,7 @@ For more information, including a detailed description of the functionality avai
|
|
9
9
|
**Rubies supported**
|
10
10
|
|
11
11
|
- 1.9.2
|
12
|
-
- 1.
|
13
|
-
- ree
|
12
|
+
- 2.1.0
|
14
13
|
|
15
14
|
Installation
|
16
15
|
------------
|
@@ -32,6 +31,10 @@ NOTE: Unless it is already defined in your application, SG will be defined as a
|
|
32
31
|
|
33
32
|
SeatGeek::Connection is where all the meat is.
|
34
33
|
|
34
|
+
You will first need to provide the `client_id` for your application. For assistance registering and locating your `client_id`, please see [the platform documentation](http://platform.seatgeek.com/#authentication).
|
35
|
+
|
36
|
+
SeatGeek::Connection.client_id = 'some_client_id'
|
37
|
+
|
35
38
|
Each of the four endpoints can be accessed with a class method reflecting the endpoint's name.
|
36
39
|
|
37
40
|
SeatGeek::Connection.events
|
@@ -57,12 +60,12 @@ SeatGeek::Connection objects can be instantiated before calls. Any parameters pa
|
|
57
60
|
|
58
61
|
There are a number of class level options that can be overridden.
|
59
62
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
63
|
+
SeatGeek::Connection.adapter # the Faraday adapter to use (default: :net_http)
|
64
|
+
SeatGeek::Connection.logger # a Logger object for logging requests (default: nil)
|
65
|
+
SeatGeek::Connection.protocol # http or https (default: :http)
|
66
|
+
SeatGeek::Connection.response_format # ruby, json, jsonp or xml (default: ruby)
|
67
|
+
SeatGeek::Connection.url # api.seatgeek.com [Advanced tuning]
|
68
|
+
SeatGeek::Connection.version # 2 [Forward thinking]
|
66
69
|
|
67
70
|
Example:
|
68
71
|
|
@@ -105,4 +108,3 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
105
108
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
106
109
|
|
107
110
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
108
|
-
|
data/lib/seat_geek/connection.rb
CHANGED
@@ -1,44 +1,95 @@
|
|
1
1
|
require 'faraday'
|
2
2
|
|
3
|
+
##
|
4
|
+
# Module: SeatGeek
|
3
5
|
module SeatGeek
|
6
|
+
##
|
7
|
+
# Class: Connection
|
4
8
|
class Connection
|
5
9
|
class << self; self; end.class_eval do
|
6
|
-
def adapter
|
7
|
-
|
10
|
+
def adapter
|
11
|
+
@@adapter ||= :net_http
|
12
|
+
end
|
13
|
+
|
14
|
+
def adapter=(input)
|
15
|
+
@@adapter = input
|
16
|
+
end
|
17
|
+
|
18
|
+
def events(*args)
|
19
|
+
new.events(*args)
|
20
|
+
end
|
8
21
|
|
9
|
-
def
|
22
|
+
def logger
|
23
|
+
@@logger ||= nil
|
24
|
+
end
|
10
25
|
|
11
|
-
def logger
|
12
|
-
|
26
|
+
def logger=(input)
|
27
|
+
@@logger = input
|
28
|
+
end
|
13
29
|
|
14
30
|
def options
|
15
31
|
{
|
16
|
-
:
|
17
|
-
:
|
18
|
-
:
|
19
|
-
:
|
20
|
-
:
|
21
|
-
:
|
32
|
+
adapter: adapter,
|
33
|
+
logger: logger,
|
34
|
+
protocol: protocol,
|
35
|
+
response_format: response_format,
|
36
|
+
url: url,
|
37
|
+
version: version,
|
38
|
+
client_id: client_id
|
22
39
|
}
|
23
40
|
end
|
24
41
|
|
25
|
-
def performers(*args)
|
42
|
+
def performers(*args)
|
43
|
+
new.performers(*args)
|
44
|
+
end
|
45
|
+
|
46
|
+
def protocol
|
47
|
+
@@protocol ||= :https
|
48
|
+
end
|
26
49
|
|
27
|
-
def protocol
|
28
|
-
|
50
|
+
def protocol=(input)
|
51
|
+
@@protocol = input
|
52
|
+
end
|
29
53
|
|
30
|
-
def response_format
|
31
|
-
|
54
|
+
def response_format
|
55
|
+
@@response_format ||= :ruby
|
56
|
+
end
|
32
57
|
|
33
|
-
def
|
58
|
+
def response_format=(input)
|
59
|
+
@@response_format = input
|
60
|
+
end
|
34
61
|
|
35
|
-
def
|
36
|
-
|
62
|
+
def taxonomies(*args)
|
63
|
+
new.taxonomies(*args)
|
64
|
+
end
|
37
65
|
|
38
|
-
def
|
66
|
+
def url
|
67
|
+
@@url ||= 'api.seatgeek.com'
|
68
|
+
end
|
39
69
|
|
40
|
-
def
|
41
|
-
|
70
|
+
def url=(input)
|
71
|
+
@@url = input
|
72
|
+
end
|
73
|
+
|
74
|
+
def venues(*args)
|
75
|
+
new.venues(*args)
|
76
|
+
end
|
77
|
+
|
78
|
+
def version
|
79
|
+
@@version ||= 2
|
80
|
+
end
|
81
|
+
|
82
|
+
def version=(input)
|
83
|
+
@@version = input
|
84
|
+
end
|
85
|
+
|
86
|
+
def client_id
|
87
|
+
@@client_id ||= nil
|
88
|
+
end
|
89
|
+
|
90
|
+
def client_id=(input)
|
91
|
+
@@client_id = input
|
92
|
+
end
|
42
93
|
end
|
43
94
|
|
44
95
|
def initialize(options = {})
|
@@ -54,26 +105,25 @@ module SeatGeek
|
|
54
105
|
end
|
55
106
|
|
56
107
|
def handle_response(response)
|
57
|
-
if response_format == :ruby
|
108
|
+
if response_format == :ruby && response.status == 200
|
58
109
|
MultiJson.decode(response.body)
|
59
110
|
else
|
60
|
-
{:
|
111
|
+
{ status: response.status, body: response.body }
|
61
112
|
end
|
62
113
|
end
|
63
114
|
|
64
|
-
# Ruby 1.8.7 / ree compatibility
|
65
|
-
def id
|
66
|
-
@options[:id]
|
67
|
-
end
|
68
|
-
|
69
115
|
def performers(params = {})
|
70
116
|
request('/performers', params)
|
71
117
|
end
|
72
118
|
|
73
119
|
def request(url, params)
|
120
|
+
raise 'You must provide a `client_id` for SeatGeek' unless client_id || params[:client_id]
|
74
121
|
handle_response(Faraday.new(*builder(url, params.clone)) do |build|
|
75
|
-
|
122
|
+
if client_id
|
123
|
+
build.use Faraday::Request::BasicAuthentication, client_id, nil
|
124
|
+
end
|
76
125
|
build.use Faraday::Response::VerboseLogger, logger unless logger.nil?
|
126
|
+
build.adapter adapter
|
77
127
|
end.get)
|
78
128
|
end
|
79
129
|
|
@@ -100,15 +150,14 @@ module SeatGeek
|
|
100
150
|
end
|
101
151
|
|
102
152
|
def builder(uri_segment, params)
|
103
|
-
|
153
|
+
[
|
104
154
|
uri([].tap do |part|
|
105
|
-
part <<
|
155
|
+
part << uri_segment
|
106
156
|
part << "/#{params.delete(:id)}" unless params[:id].nil?
|
107
157
|
end.join),
|
108
158
|
{
|
109
|
-
:
|
110
|
-
[:jsonp, :xml].include?(response_format) ?
|
111
|
-
params.merge(:format => response_format) : params))
|
159
|
+
params: custom_options.merge((
|
160
|
+
[:jsonp, :xml].include?(response_format) ? params.merge(format: response_format) : params))
|
112
161
|
}
|
113
162
|
]
|
114
163
|
end
|
data/lib/seat_geek/version.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
{"meta":{"per_page":1,"total":63188,"page":1,"took":4,"geolocation":null},"events":[{"stats":{"listing_count":0,"average_price":0,"lowest_price":null,"highest_price":null},"relative_url":"/palm-beach-cardinals-at-jupiter-hammerheads-tickets/minor-league-baseball/2012-05-14/798459/","title":"Palm Beach Cardinals at Jupiter Hammerheads","url":"https://seatgeek.com/palm-beach-cardinals-at-jupiter-hammerheads-tickets/minor-league-baseball/2012-05-14/798459/","datetime_local":"2012-05-14T10:35:00","performers":[{"away_team":true,"name":"Palm Beach Cardinals","url":"https://seatgeek.com/palm-beach-cardinals-tickets/","image":null,"short_name":"Palm Beach Cardinals","slug":"palm-beach-cardinals","score":0,"images":[],"type":"minor_league_baseball","id":9420},{"home_team":true,"name":"Jupiter Hammerheads","url":"https://seatgeek.com/jupiter-hammerheads-tickets/","image":null,"short_name":"Jupiter Hammerheads","primary":true,"slug":"jupiter-hammerheads","score":0,"images":[],"type":"minor_league_baseball","id":9421}],"venue":{"city":"Jupiter","name":"Roger Dean Stadium","url":"https://seatgeek.com/roger-dean-stadium-tickets/","country":"US","state":"FL","score":16592,"postal_code":"33468","location":{"lat":26.8936,"lon":-80.1156},"extended_address":null,"address":"4751 Main St","id":3927},"short_title":"Palm Beach Cardinals at Jupiter Hammerheads","datetime_utc":"2012-05-14T14:35:00","score":0,"taxonomies":[{"parent_id":null,"id":1000000,"name":"sports"},{"parent_id":1000000,"id":1010000,"name":"baseball"},{"parent_id":1010000,"id":1010300,"name":"minor_league_baseball"}],"type":"minor_league_baseball","id":798459}]}
|
@@ -3,280 +3,339 @@ require 'ostruct'
|
|
3
3
|
|
4
4
|
describe SeatGeek::Connection do
|
5
5
|
let(:klass) { SeatGeek::Connection }
|
6
|
-
let(:instance) { klass.new }
|
6
|
+
let(:instance) { klass.new(client_id: 'foobar') }
|
7
7
|
|
8
|
-
describe
|
8
|
+
describe '.adapter' do
|
9
9
|
subject { klass.adapter }
|
10
10
|
let(:default) { :net_http }
|
11
11
|
|
12
12
|
it { should == default }
|
13
|
-
it
|
13
|
+
it 'should be writable' do
|
14
14
|
klass.adapter = :typhoeus
|
15
|
-
klass.adapter.
|
15
|
+
expect(klass.adapter).to eq(:typhoeus)
|
16
16
|
end
|
17
17
|
|
18
18
|
after { klass.adapter = default }
|
19
19
|
end
|
20
20
|
|
21
|
-
describe
|
22
|
-
it
|
23
|
-
klass.
|
21
|
+
describe '.events' do
|
22
|
+
it 'proxies to #events' do
|
23
|
+
expect_any_instance_of(klass).to receive(:events).and_return(nil)
|
24
24
|
klass.events
|
25
25
|
end
|
26
26
|
|
27
|
-
it
|
28
|
-
klass.
|
27
|
+
it 'passes any attributes to #events' do
|
28
|
+
expect_any_instance_of(klass).to receive(:events).with(1, 2)
|
29
|
+
.and_return(nil)
|
29
30
|
klass.events(1, 2)
|
30
31
|
end
|
31
32
|
end
|
32
33
|
|
33
|
-
describe
|
34
|
+
describe '.logger' do
|
34
35
|
subject { klass.logger }
|
35
36
|
let(:default) { nil }
|
36
37
|
let(:logger) { Logger.new(STDOUT) }
|
37
38
|
|
38
39
|
it { should == default }
|
39
|
-
it
|
40
|
+
it 'should be writable' do
|
40
41
|
klass.logger = logger
|
41
|
-
klass.logger.
|
42
|
+
expect(klass.logger).to eq(logger)
|
42
43
|
end
|
43
44
|
|
44
45
|
after { klass.logger = default }
|
45
46
|
end
|
46
47
|
|
47
|
-
describe
|
48
|
-
it
|
49
|
-
klass.options.
|
50
|
-
:
|
51
|
-
:
|
52
|
-
:
|
53
|
-
:
|
54
|
-
:
|
55
|
-
:
|
56
|
-
|
48
|
+
describe '.options' do
|
49
|
+
it 'should return a hash of all of the class level settings' do
|
50
|
+
expect(klass.options).to eq(
|
51
|
+
adapter: :net_http,
|
52
|
+
logger: nil,
|
53
|
+
protocol: :https,
|
54
|
+
response_format: :ruby,
|
55
|
+
url: 'api.seatgeek.com',
|
56
|
+
version: 2,
|
57
|
+
client_id: nil
|
58
|
+
)
|
57
59
|
end
|
58
60
|
end
|
59
61
|
|
60
|
-
describe
|
61
|
-
it
|
62
|
-
klass.
|
62
|
+
describe '.performers' do
|
63
|
+
it 'proxies to #performers' do
|
64
|
+
expect_any_instance_of(klass).to receive(:performers).and_return(nil)
|
63
65
|
klass.performers
|
64
66
|
end
|
65
67
|
|
66
|
-
it
|
67
|
-
klass.
|
68
|
+
it 'passes any attributes to #performers' do
|
69
|
+
expect_any_instance_of(klass).to receive(:performers).with(1, 2)
|
70
|
+
.and_return(nil)
|
68
71
|
klass.performers(1, 2)
|
69
72
|
end
|
70
73
|
end
|
71
74
|
|
72
|
-
describe
|
75
|
+
describe '.protocol' do
|
73
76
|
subject { klass.protocol }
|
74
|
-
let(:default) { :
|
77
|
+
let(:default) { :https }
|
75
78
|
|
76
79
|
it { should == default }
|
77
|
-
it
|
80
|
+
it 'should be writable' do
|
78
81
|
klass.protocol = :https
|
79
|
-
klass.protocol.
|
82
|
+
expect(klass.protocol).to eq(:https)
|
80
83
|
end
|
81
84
|
|
82
85
|
after { klass.protocol = default }
|
83
86
|
end
|
84
87
|
|
85
|
-
describe
|
88
|
+
describe '.client_id' do
|
89
|
+
subject { klass.client_id }
|
90
|
+
let(:default) { nil }
|
91
|
+
|
92
|
+
it { should == default }
|
93
|
+
it 'should be writable' do
|
94
|
+
klass.client_id = 'some_client_id'
|
95
|
+
expect(klass.client_id).to eq('some_client_id')
|
96
|
+
end
|
97
|
+
|
98
|
+
after { klass.client_id = default }
|
99
|
+
end
|
100
|
+
|
101
|
+
describe '.response_format' do
|
86
102
|
subject { klass.response_format }
|
87
103
|
let(:default) { :ruby }
|
88
104
|
|
89
105
|
it { should == default }
|
90
|
-
it
|
106
|
+
it 'should be writable' do
|
91
107
|
klass.response_format = :jsonp
|
92
|
-
klass.response_format.
|
108
|
+
expect(klass.response_format).to eq(:jsonp)
|
93
109
|
end
|
94
110
|
|
95
111
|
after { klass.response_format = default }
|
96
112
|
end
|
97
113
|
|
98
|
-
describe
|
99
|
-
it
|
100
|
-
klass.
|
114
|
+
describe '.taxonomies' do
|
115
|
+
it 'proxies to #taxonomies' do
|
116
|
+
expect_any_instance_of(klass).to receive(:taxonomies).and_return(nil)
|
101
117
|
klass.taxonomies
|
102
118
|
end
|
103
119
|
|
104
|
-
it
|
105
|
-
klass.
|
120
|
+
it 'passes any attributes to #taxonomies' do
|
121
|
+
expect_any_instance_of(klass).to receive(:taxonomies).with(1, 2)
|
122
|
+
.and_return(nil)
|
106
123
|
klass.taxonomies(1, 2)
|
107
124
|
end
|
108
125
|
end
|
109
126
|
|
110
|
-
describe
|
127
|
+
describe '.url' do
|
111
128
|
subject { klass.url }
|
112
|
-
let(:default) {
|
129
|
+
let(:default) { 'api.seatgeek.com' }
|
113
130
|
|
114
131
|
it { should == default }
|
115
|
-
it
|
116
|
-
klass.url =
|
117
|
-
klass.url.
|
132
|
+
it 'should be writable' do
|
133
|
+
klass.url = 'ticketevolution.com'
|
134
|
+
expect(klass.url).to eq('ticketevolution.com')
|
118
135
|
end
|
119
136
|
|
120
137
|
after { klass.url = default }
|
121
138
|
end
|
122
139
|
|
123
|
-
describe
|
124
|
-
it
|
125
|
-
klass.
|
140
|
+
describe '.venues' do
|
141
|
+
it 'proxies to #venues' do
|
142
|
+
expect_any_instance_of(klass).to receive(:venues).and_return(nil)
|
126
143
|
klass.venues
|
127
144
|
end
|
128
145
|
|
129
|
-
it
|
130
|
-
klass.
|
146
|
+
it 'passes any attributes to #venues' do
|
147
|
+
expect_any_instance_of(klass).to receive(:venues).with(1, 2)
|
148
|
+
.and_return(nil)
|
131
149
|
klass.venues(1, 2)
|
132
150
|
end
|
133
151
|
end
|
134
152
|
|
135
|
-
describe
|
153
|
+
describe '.version' do
|
136
154
|
subject { klass.version }
|
137
155
|
let(:default) { 2 }
|
138
156
|
|
139
157
|
it { should == 2 }
|
140
|
-
it
|
158
|
+
it 'should be writable' do
|
141
159
|
klass.version = 1
|
142
|
-
klass.version.
|
160
|
+
expect(klass.version).to eq(1)
|
143
161
|
end
|
144
162
|
|
145
163
|
after { klass.version = default }
|
146
164
|
end
|
147
165
|
|
148
|
-
describe
|
166
|
+
describe '#initialize' do
|
149
167
|
let(:expected) { klass.options.merge(options) }
|
150
|
-
let(:options) { { :
|
151
|
-
let(:str_options) { {}.tap{|o| options.each{|k, v| o[k.to_s] = v}} }
|
168
|
+
let(:options) { { testing: 123, clone: 'hello', client_id: 'some_data' } }
|
169
|
+
let(:str_options) { {}.tap { |o| options.each { |k, v| o[k.to_s] = v } } }
|
152
170
|
let(:instance) { klass.new(options) }
|
153
171
|
|
154
|
-
it
|
155
|
-
|
172
|
+
it 'should take options passed and store '\
|
173
|
+
'them on top of the class options hash' do
|
174
|
+
expect(instance.instance_eval('@options')).to eq(expected)
|
156
175
|
end
|
157
176
|
|
158
|
-
it
|
159
|
-
klass.new(str_options).instance_eval('@options').
|
177
|
+
it 'should convert the keys passed to symbols' do
|
178
|
+
expect(klass.new(str_options).instance_eval('@options')).to eq(expected)
|
160
179
|
end
|
161
180
|
|
162
|
-
it
|
163
|
-
|
164
|
-
instance.
|
181
|
+
it 'should serve options up via read accessor '\
|
182
|
+
'methods unless the methods already exist' do
|
183
|
+
expect(instance.testing).to eq(options[:testing])
|
184
|
+
expect(instance.clone).not_to eq(options[:clone])
|
165
185
|
end
|
166
186
|
end
|
167
187
|
|
168
|
-
describe
|
169
|
-
let(:url) { '/events'}
|
170
|
-
let(:params) { {:
|
188
|
+
describe '#events' do
|
189
|
+
let(:url) { '/events' }
|
190
|
+
let(:params) { { test: 123 } }
|
171
191
|
|
172
|
-
it
|
173
|
-
|
192
|
+
it 'should call #request with the correct'\
|
193
|
+
'url segment and the params passed' do
|
194
|
+
expect(instance).to receive(:request).with(url, params)
|
174
195
|
instance.events(params)
|
175
196
|
end
|
176
197
|
end
|
177
198
|
|
178
|
-
describe
|
179
|
-
let(:response) { double(Faraday::Response, :
|
199
|
+
describe '#handle_response' do
|
200
|
+
let(:response) { double(Faraday::Response, status: status, body: body) }
|
180
201
|
|
181
|
-
context
|
182
|
-
context
|
202
|
+
context 'when response_format is set to ruby' do
|
203
|
+
context 'and the request was successful' do
|
183
204
|
let(:status) { 200 }
|
184
|
-
let(:body) {
|
205
|
+
let(:body) { File.read('spec/fixtures/handle_response.json') }
|
185
206
|
|
186
|
-
it
|
187
|
-
instance.handle_response(response)
|
207
|
+
it 'should parse the json returned and respond with a ruby object' do
|
208
|
+
expect(instance.handle_response(response))
|
209
|
+
.to eq(MultiJson.decode(body))
|
188
210
|
end
|
189
211
|
end
|
190
212
|
|
191
|
-
context
|
213
|
+
context 'and the request was not successful' do
|
192
214
|
let(:status) { 500 }
|
193
|
-
let(:body) {
|
215
|
+
let(:body) { 'Internal Server Error' }
|
194
216
|
|
195
|
-
it
|
196
|
-
instance.handle_response(response)
|
217
|
+
it 'should return the status code and exact result body' do
|
218
|
+
expect(instance.handle_response(response))
|
219
|
+
.to eq(status: status, body: body)
|
197
220
|
end
|
198
221
|
end
|
199
222
|
end
|
200
223
|
|
201
|
-
context
|
224
|
+
context 'when response format is not set to ruby' do
|
202
225
|
let(:status) { 200 }
|
203
|
-
let(:body) {
|
226
|
+
let(:body) { File.read('spec/fixtures/handle_response.json') }
|
204
227
|
|
205
|
-
it
|
206
|
-
klass.new(:
|
207
|
-
|
228
|
+
it 'should return the status code and exact result body' do
|
229
|
+
expect(klass.new(response_format: :json).handle_response(response))
|
230
|
+
.to eq(status: status, body: body)
|
208
231
|
end
|
209
232
|
end
|
210
233
|
end
|
211
234
|
|
212
|
-
describe
|
213
|
-
let(:url) { '/performers'}
|
214
|
-
let(:params) { {:
|
235
|
+
describe '#performers' do
|
236
|
+
let(:url) { '/performers' }
|
237
|
+
let(:params) { { test: 123 } }
|
215
238
|
|
216
|
-
it
|
217
|
-
|
239
|
+
it 'should call #request with the correct '\
|
240
|
+
'url segment and the params passed' do
|
241
|
+
expect(instance).to receive(:request).with(url, params)
|
218
242
|
instance.performers(params)
|
219
243
|
end
|
220
244
|
end
|
221
245
|
|
222
|
-
describe
|
223
|
-
let(:
|
246
|
+
describe '#request' do
|
247
|
+
let(:uri_segment) { '/venues' }
|
248
|
+
let(:url) { "https://api.seatgeek.com/2#{uri_segment}" }
|
224
249
|
let(:params) { {} }
|
225
|
-
let(:faraday) {
|
250
|
+
let(:faraday) { double(:faraday, get: OpenStruct.new(status: 200, body: '[]')) }
|
251
|
+
|
252
|
+
context 'when .client_id is not set as class property' do
|
253
|
+
let(:instance) { klass.new }
|
254
|
+
let(:expected_params) { { params: params.merge(format: :jsonp) } }
|
255
|
+
|
256
|
+
it 'should throw an exception' do
|
257
|
+
expect { instance.request(uri_segment, params) }
|
258
|
+
.to raise_error('You must provide a `client_id` for SeatGeek')
|
259
|
+
end
|
260
|
+
|
261
|
+
it 'should not throw an exception if provided in paramters' do
|
262
|
+
expect {
|
263
|
+
params[:client_id] = 'foobar'
|
264
|
+
instance.request(uri_segment, params)
|
265
|
+
}.to_not raise_error
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
context 'when .response_format is jsonp' do
|
270
|
+
let(:instance) { klass.new(response_format: :jsonp, client_id: 'foobar') }
|
271
|
+
let(:expected_params) { { params: params.merge(format: :jsonp) } }
|
272
|
+
|
273
|
+
it 'should set the format param to jsonp' do
|
274
|
+
expect(Faraday).to receive(:new).with(url, expected_params)
|
275
|
+
.and_return(faraday)
|
276
|
+
instance.request(uri_segment, params)
|
277
|
+
end
|
278
|
+
end
|
226
279
|
|
227
|
-
context
|
228
|
-
let(:instance) { klass.new(
|
229
|
-
let(:expected_params) { {:
|
280
|
+
context 'when .response_format is xml' do
|
281
|
+
let(:instance) { klass.new(response_format: :xml, client_id: 'foobar') }
|
282
|
+
let(:expected_params) { { params: params.merge(format: :xml) } }
|
230
283
|
|
231
|
-
it
|
232
|
-
Faraday.
|
233
|
-
|
284
|
+
it 'should set the format param to xml' do
|
285
|
+
expect(Faraday).to receive(:new).with(url, expected_params)
|
286
|
+
.and_return(faraday)
|
287
|
+
instance.request(uri_segment, params)
|
234
288
|
end
|
235
289
|
end
|
236
290
|
|
237
|
-
context
|
238
|
-
let(:instance) { klass.new(
|
239
|
-
let(:expected_params) { {:
|
291
|
+
context 'when additional parameters were passed to #initialize' do
|
292
|
+
let(:instance) { klass.new(response_format: :jsonp, testing: 123, client_id: 'foobar') }
|
293
|
+
let(:expected_params) { { params: params.merge(format: :jsonp, testing: 123)} }
|
240
294
|
|
241
|
-
it
|
242
|
-
Faraday.
|
243
|
-
|
295
|
+
it 'should add those parameters to the request params' do
|
296
|
+
expect(Faraday).to receive(:new).with(url, expected_params)
|
297
|
+
.and_return(faraday)
|
298
|
+
instance.request(uri_segment, params)
|
244
299
|
end
|
245
300
|
end
|
246
301
|
|
247
|
-
context
|
248
|
-
let(:instance) { klass.new
|
249
|
-
let(:
|
302
|
+
context 'when client_id was passed as a parameter' do
|
303
|
+
let(:instance) { klass.new }
|
304
|
+
let(:params) { { client_id: 'foobar' } }
|
305
|
+
let(:expected_params) { { params: params.merge(client_id: 'foobar') } }
|
250
306
|
|
251
|
-
it
|
252
|
-
Faraday.
|
253
|
-
|
307
|
+
it 'should make the request with the client_id parameter set' do
|
308
|
+
expect(Faraday).to receive(:new).with(url, expected_params)
|
309
|
+
.and_return(faraday)
|
310
|
+
instance.request(uri_segment, params)
|
254
311
|
end
|
255
312
|
end
|
256
313
|
end
|
257
314
|
|
258
|
-
describe
|
259
|
-
let(:url) { '/taxonomies'}
|
260
|
-
let(:params) { {:
|
315
|
+
describe '#taxonomies' do
|
316
|
+
let(:url) { '/taxonomies' }
|
317
|
+
let(:params) { { test: 123 } }
|
261
318
|
|
262
|
-
it
|
263
|
-
|
319
|
+
it 'should call #request with the correct '\
|
320
|
+
'url segment and the params passed' do
|
321
|
+
expect(instance).to receive(:request).with(url, params)
|
264
322
|
instance.taxonomies(params)
|
265
323
|
end
|
266
324
|
end
|
267
325
|
|
268
|
-
describe
|
269
|
-
it
|
270
|
-
instance.uri('/events').
|
326
|
+
describe '#uri' do
|
327
|
+
it 'should take in a path and combine it with protocol, url and version' do
|
328
|
+
expect(instance.uri('/events')).to eq('https://api.seatgeek.com/2/events')
|
271
329
|
end
|
272
330
|
end
|
273
331
|
|
274
|
-
describe
|
275
|
-
let(:url) { '/venues'}
|
276
|
-
let(:params) { {:
|
332
|
+
describe '#venues' do
|
333
|
+
let(:url) { '/venues' }
|
334
|
+
let(:params) { { test: 123 } }
|
277
335
|
|
278
|
-
it
|
279
|
-
|
336
|
+
it 'should call #request with the correct '\
|
337
|
+
'url segment and the params passed' do
|
338
|
+
expect(instance).to receive(:request).with(url, params)
|
280
339
|
instance.venues(params)
|
281
340
|
end
|
282
341
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe SeatGeek::VERSION do
|
4
|
-
it
|
5
|
-
subject.
|
4
|
+
it 'should match a three segment version number format' do
|
5
|
+
expect(subject).to match(/^\d+\.\d+\.\d+(rc\d+)?$/)
|
6
6
|
end
|
7
7
|
end
|
data/spec/lib/sg_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,71 +1,85 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: seatgeek
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Dan Matthews
|
9
|
-
autorequire:
|
8
|
+
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2020-07-13 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: faraday
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
25
27
|
- !ruby/object:Gem::Dependency
|
26
28
|
name: multi_json
|
27
|
-
requirement:
|
28
|
-
none: false
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
|
-
- -
|
31
|
+
- - ">="
|
31
32
|
- !ruby/object:Gem::Version
|
32
33
|
version: '0'
|
33
34
|
type: :runtime
|
34
35
|
prerelease: false
|
35
|
-
version_requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
36
41
|
- !ruby/object:Gem::Dependency
|
37
42
|
name: rake
|
38
|
-
requirement:
|
39
|
-
none: false
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
40
44
|
requirements:
|
41
|
-
- -
|
45
|
+
- - ">="
|
42
46
|
- !ruby/object:Gem::Version
|
43
47
|
version: '0'
|
44
48
|
type: :runtime
|
45
49
|
prerelease: false
|
46
|
-
version_requirements:
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
47
55
|
- !ruby/object:Gem::Dependency
|
48
56
|
name: yajl-ruby
|
49
|
-
requirement:
|
50
|
-
none: false
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
51
58
|
requirements:
|
52
|
-
- -
|
59
|
+
- - ">="
|
53
60
|
- !ruby/object:Gem::Version
|
54
61
|
version: '0'
|
55
62
|
type: :runtime
|
56
63
|
prerelease: false
|
57
|
-
version_requirements:
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
58
69
|
- !ruby/object:Gem::Dependency
|
59
70
|
name: rspec
|
60
|
-
requirement:
|
61
|
-
none: false
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
62
72
|
requirements:
|
63
|
-
- -
|
73
|
+
- - ">="
|
64
74
|
- !ruby/object:Gem::Version
|
65
75
|
version: '0'
|
66
76
|
type: :development
|
67
77
|
prerelease: false
|
68
|
-
version_requirements:
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
description: This gem provides Ruby functionality around the SeatGeek Platform API
|
70
84
|
(http://platform.seatgeek.com). It is designed to be framework agnostic and was
|
71
85
|
originally developed for use in my day job at Ticket Evolution.
|
@@ -75,54 +89,48 @@ executables: []
|
|
75
89
|
extensions: []
|
76
90
|
extra_rdoc_files: []
|
77
91
|
files:
|
78
|
-
- .gitignore
|
79
|
-
- .rdebugrc
|
80
|
-
- .rspec
|
81
|
-
- .travis.yml
|
92
|
+
- ".gitignore"
|
93
|
+
- ".rdebugrc"
|
94
|
+
- ".rspec"
|
95
|
+
- ".travis.yml"
|
82
96
|
- Gemfile
|
83
97
|
- Gemfile.lock
|
84
|
-
- README.
|
98
|
+
- README.md
|
85
99
|
- Rakefile
|
86
100
|
- lib/faraday/response/verbose_logger.rb
|
87
101
|
- lib/seat_geek/connection.rb
|
88
102
|
- lib/seat_geek/version.rb
|
89
103
|
- lib/seatgeek.rb
|
90
104
|
- seatgeek.gemspec
|
105
|
+
- spec/fixtures/handle_response.json
|
91
106
|
- spec/lib/seat_geek/connection_spec.rb
|
92
107
|
- spec/lib/seat_geek/version_spec.rb
|
93
108
|
- spec/lib/sg_spec.rb
|
94
109
|
- spec/spec_helper.rb
|
95
110
|
homepage: http://platform.seatgeek.com
|
96
111
|
licenses: []
|
97
|
-
|
112
|
+
metadata: {}
|
113
|
+
post_install_message:
|
98
114
|
rdoc_options: []
|
99
115
|
require_paths:
|
100
116
|
- lib
|
101
117
|
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
-
none: false
|
103
118
|
requirements:
|
104
|
-
- -
|
119
|
+
- - ">="
|
105
120
|
- !ruby/object:Gem::Version
|
106
121
|
version: '0'
|
107
|
-
segments:
|
108
|
-
- 0
|
109
|
-
hash: 2766271802599134346
|
110
122
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
-
none: false
|
112
123
|
requirements:
|
113
|
-
- -
|
124
|
+
- - ">="
|
114
125
|
- !ruby/object:Gem::Version
|
115
126
|
version: '0'
|
116
|
-
segments:
|
117
|
-
- 0
|
118
|
-
hash: 2766271802599134346
|
119
127
|
requirements: []
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
specification_version: 3
|
128
|
+
rubygems_version: 3.1.2
|
129
|
+
signing_key:
|
130
|
+
specification_version: 4
|
124
131
|
summary: A Ruby wrapper for the SeatGeek Platform API.
|
125
132
|
test_files:
|
133
|
+
- spec/fixtures/handle_response.json
|
126
134
|
- spec/lib/seat_geek/connection_spec.rb
|
127
135
|
- spec/lib/seat_geek/version_spec.rb
|
128
136
|
- spec/lib/sg_spec.rb
|