seat_geek 0.7.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cf1e8a3542fb54082ff4b52f850bab8463cc358d
4
- data.tar.gz: d06de55d40b8dc790931209f5e1d5ad240eba08e
3
+ metadata.gz: a6de3a9e2781e940114bf3bbdb7088450e7e9e7f
4
+ data.tar.gz: 65020b1a8224143e1d9250981f2b6432be6b56ca
5
5
  SHA512:
6
- metadata.gz: 95b721a373f73dfb13641c378c25d3060180239c541379eb21c5cc25e3dcc442d00ee8e14d3180046294094f452379c38e99a6b8856768a8d3872193d78e1fc8
7
- data.tar.gz: 695bf82730ce8cbe0ea90dea2e21595ededf37c5e6ecac8de2bff0983e68ee822489408e7e76c0d28780cac30a19b86a5246ee2938e6a32be205c50823c00c18
6
+ metadata.gz: fe9843f0edaa856fee3e063b505128074bc28da662c86c46bfda6fbf257772e125aaa05199d8791555bab2f9cc27b8fa34c27d8dac6330c80cc784d62308fb63
7
+ data.tar.gz: 2e8edc504a62268396bd7527fb7d3c64a01ca51f40e64057523ddb21ed1072389045be5100c8c66f7f06123a30428b08e734b8b265165432de276e2fefa145d6
data/.byebug_history ADDED
@@ -0,0 +1,9 @@
1
+ exit
2
+ @taxonomies.
3
+ @taxonomies.sports
4
+ @taxonomies
5
+ exit
6
+ @taxonomies[:sports].sports
7
+ @taxonomies[:sports]
8
+ @taxonomies.sports
9
+ @taxonomies
data/README.md CHANGED
@@ -20,7 +20,7 @@ Or install it yourself as:
20
20
  Taxonomy
21
21
 
22
22
  ```ruby
23
- taxonomy = SeatGeek::Taxonomy.new()
23
+ taxonomy = SeatGeek.get_taxonomies
24
24
 
25
25
  taxonomy.sports
26
26
  # Events that contains parent_id of 1000000
@@ -34,16 +34,12 @@ taxonomy.concert
34
34
 
35
35
  taxonomy.theater
36
36
  # Events that contains parent_id of 3000000
37
- #=> <SeatGeek::Taxonomies::Concert: @parent_object={ ... },
37
+ #=> <SeatGeek::Taxonomies::Theater: @parent_object={ ... },
38
38
  @sub_taxonomies= [{"parent_id"=>3000000, "id"=>3020000, "name"=>"cirque_du_soleil"} ..]
39
39
 
40
- all = taxonomy.all
40
+ taxonomy
41
41
  # => GET http://api.seatgeek.com/2/taxonomies
42
42
  #=> contains all of the above
43
-
44
- all[:sports] or
45
- all[:concert] or
46
- all[:theater]
47
43
  ```
48
44
 
49
45
  Events
@@ -6,10 +6,6 @@ module SeatGeek
6
6
  @sub_taxonomies = sub_taxonomies
7
7
  end
8
8
 
9
- def name
10
- parent_object['name']
11
- end
12
-
13
9
  attr_accessor :sub_taxonomies, :parent_object
14
10
  end
15
11
  end
@@ -6,10 +6,6 @@ module SeatGeek
6
6
  @sub_taxonomies = sub_taxonomies
7
7
  end
8
8
 
9
- def name
10
- parent_object['name']
11
- end
12
-
13
9
  attr_accessor :sub_taxonomies, :parent_object
14
10
  end
15
11
  end
@@ -6,10 +6,6 @@ module SeatGeek
6
6
  @sub_taxonomies = sub_taxonomies
7
7
  end
8
8
 
9
- def name
10
- parent_object['name']
11
- end
12
-
13
9
  attr_accessor :sub_taxonomies, :parent_object
14
10
  end
15
11
  end
@@ -1,12 +1,16 @@
1
1
  module SeatGeek
2
2
  module Taxonomies
3
3
  class Tree
4
- def initialize(parent_ids, taxonomies)
4
+ def initialize(parent_ids:, taxonomies:)
5
5
  @parent_ids = parent_ids
6
6
  @taxonomies = taxonomies
7
7
  build_tree
8
8
  end
9
9
 
10
+ def all
11
+ finished_tree
12
+ end
13
+
10
14
  def sports
11
15
  finished_tree[:sports]
12
16
  end
@@ -31,14 +35,8 @@ module SeatGeek
31
35
  taxonomy['parent_id'] == parent_id
32
36
  end
33
37
 
34
- if parent_object.fetch('name') == 'sports'
35
- klass = SeatGeek::Taxonomies::Sports
36
- elsif parent_object.fetch('name') == 'concert'
37
- klass = SeatGeek::Taxonomies::Concert
38
- elsif parent_object.fetch('name') == 'theater'
39
- klass = SeatGeek::Taxonomies::Theater
40
- end
41
- finished_tree[parent_object['name'].to_sym] = klass.new(parent_object: parent_object, sub_taxonomies: sub_taxonomies)
38
+ klass = { 'sports' => SeatGeek::Taxonomies::Sports, 'concert' => SeatGeek::Taxonomies::Concert, 'theater' => SeatGeek::Taxonomies::Theater }
39
+ finished_tree[parent_object['name'].to_sym] = klass[parent_object['name']].new(parent_object: parent_object, sub_taxonomies: sub_taxonomies)
42
40
  end
43
41
  end
44
42
 
@@ -17,6 +17,9 @@ module SeatGeek
17
17
  if options[:event_type]
18
18
  query = query + event_type_query(options[:event_type])
19
19
  end
20
+ if options[:taxonomies]
21
+ query = query + 'taxonomies.name=' + options[:taxonomies]
22
+ end
20
23
  base_url + query
21
24
  end
22
25
 
@@ -1,62 +0,0 @@
1
- module SeatGeek
2
- class Taxonomy
3
- PUBLIC_API_URL = 'https://api.seatgeek.com/2/taxonomies'
4
- SPORTS_ID = 1000000
5
- CONCERT_ID = 2000000
6
- THEATRE_ID = 3000000
7
-
8
- def initialize
9
- @base_url = PUBLIC_API_URL
10
- @taxonomies = parse_response(typhoeus_request.body)
11
- end
12
-
13
- def all
14
- taxonomies
15
- end
16
-
17
- def sports
18
- taxonomies_tree.sports
19
- end
20
-
21
- def concert
22
- taxonomies_tree.concert
23
- end
24
-
25
- def theater
26
- taxonomies_tree.theater
27
- end
28
-
29
- private
30
-
31
- attr_accessor :base_url, :taxonomies
32
-
33
- def taxonomies_tree
34
- @taxonomies_tree ||= SeatGeek::Taxonomies::Tree.new([SPORTS_ID, CONCERT_ID, THEATRE_ID], taxonomies['taxonomies'])
35
- end
36
-
37
- def get_events(event_ids)
38
- events = []
39
- taxonomies = SeatGeek::Taxonomy.new.all['taxonomies']
40
-
41
- event_ids.each do |x|
42
- events << taxonomies[x]
43
- end
44
- events
45
- end
46
-
47
- def build_url
48
- BuildQuery.build({}, base_url)
49
- end
50
-
51
- def typhoeus_request
52
- request = Typhoeus::Request.new(build_url,
53
- method: :get,
54
- headers: { Accept: "json" }
55
- ).run
56
- end
57
-
58
- def parse_response(json_string)
59
- Oj.load(json_string)
60
- end
61
- end
62
- end
@@ -1,3 +1,3 @@
1
1
  module SeatGeek
2
- VERSION = "0.7.0"
2
+ VERSION = "0.8.1"
3
3
  end
data/lib/seat_geek.rb CHANGED
@@ -3,7 +3,6 @@ require 'oj'
3
3
 
4
4
  require "seat_geek/version"
5
5
  require "seat_geek/build_query"
6
- require "seat_geek/taxonomy"
7
6
  require "seat_geek/taxonomies/tree"
8
7
  require "seat_geek/taxonomies/sports"
9
8
  require "seat_geek/taxonomies/concert"
@@ -11,6 +10,10 @@ require "seat_geek/taxonomies/theater"
11
10
 
12
11
 
13
12
  module SeatGeek
13
+ SPORTS_ID = 1000000
14
+ CONCERT_ID = 2000000
15
+ THEATRE_ID = 3000000
16
+
14
17
  extend self
15
18
  PUBLIC_API_URL = 'https://api.seatgeek.com/2/'
16
19
 
@@ -24,6 +27,14 @@ module SeatGeek
24
27
  parse_response(typhoeus_request.body)
25
28
  end
26
29
 
30
+ def self.get_taxonomies
31
+ @options = {}
32
+ @base_url = 'https://api.seatgeek.com/2/taxonomies'
33
+ taxonomies = parse_response(typhoeus_request.body)['taxonomies']
34
+
35
+ SeatGeek::Taxonomies::Tree.new(parent_ids: [SPORTS_ID, CONCERT_ID, THEATRE_ID], taxonomies: taxonomies)
36
+ end
37
+
27
38
  #TODO Need to think this through
28
39
  # not sure how to get recommendations or what we should get recommendations
29
40
  # for
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seat_geek
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Moon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-22 00:00:00.000000000 Z
11
+ date: 2016-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -129,6 +129,7 @@ executables: []
129
129
  extensions: []
130
130
  extra_rdoc_files: []
131
131
  files:
132
+ - ".byebug_history"
132
133
  - ".gitignore"
133
134
  - ".travis.yml"
134
135
  - CODE_OF_CONDUCT.md