stubhub 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in stubhub.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Ryan Loomba
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Stubhub
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'stubhub'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install stubhub
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/lib/stubhub.rb ADDED
@@ -0,0 +1,24 @@
1
+ require 'json'
2
+ require 'httparty'
3
+ require 'ostruct'
4
+
5
+ require_relative 'stubhub/document'
6
+ require_relative 'stubhub/client'
7
+ require_relative 'stubhub/event'
8
+ require_relative 'stubhub/genre'
9
+ require_relative 'stubhub/geo'
10
+ require_relative 'stubhub/ticket'
11
+ require_relative 'stubhub/venue'
12
+ require_relative 'stubhub/venue_zone_section'
13
+ require_relative 'stubhub/version'
14
+
15
+
16
+ module Stubhub
17
+
18
+ # EXAMPLES -----------
19
+ # doc types: event, venue, genre, geo (Geography), venue_zone_section (Venue Zone Section)
20
+ # puts Stubhub::Ticket.find_by_ticket_id(487197960)
21
+ # puts Stubhub::Event.find_by_event_id(4236091) => individual event
22
+ # puts Stubhub::Event.search("swedish house mafia")
23
+ # --------------------------
24
+ end
@@ -0,0 +1,24 @@
1
+ module Stubhub
2
+ module Client
3
+ include HTTParty
4
+
5
+ base_uri "http://www.stubhub.com/listingCatalog/select/?q="
6
+ format :json
7
+
8
+ def self.convert_query_to_url(options)
9
+ options.map do |k,v|
10
+ "%2B+#{k}%3A#{v}%0D%0A"
11
+ end.join << '&start=0&rows=10&wt=json'
12
+ end
13
+
14
+ def self.make_request(klass, options)
15
+ query_url = convert_query_to_url(options)
16
+ result = get(query_url)
17
+ parsed_result = JSON.parse(result.body)
18
+ parsed_result["response"]["docs"].map do |doc|
19
+ klass.new(doc)
20
+ end
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,18 @@
1
+ module Stubhub
2
+ class Document < OpenStruct
3
+
4
+ def self.demodulize(class_name_in_module)
5
+ class_name_in_module.to_s.gsub(/^.*::/, '')
6
+ end
7
+
8
+ def fields
9
+ @table.keys.map{|k| k.to_s}
10
+ end
11
+
12
+ def initialize(data = {})
13
+ raise ArgumentError, "Invalid data passed to Document.new: #{data.inspect}" unless data.is_a?(Hash)
14
+ super(data)
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ module Stubhub
2
+ class Event < Document
3
+
4
+ def self.find_by_event_id(event_id)
5
+ options = {"stubhubDocumentType" => "#{demodulize(self).downcase}",
6
+ "event_id" => "#{event_id}"}
7
+ Client.make_request(Event, options)
8
+ end
9
+
10
+ def self.search(search_query)
11
+ search_query.gsub!(/\s+/, '+')
12
+ options = {"stubhubDocumentType" => "#{demodulize(self).downcase}",
13
+ "description" => "#{search_query}"}
14
+ Client.make_request(Event, options)
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,3 @@
1
+ module Stubhub
2
+ class Genre < Document;end
3
+ end
@@ -0,0 +1,3 @@
1
+ module Stubhub
2
+ class Geo < Document;end
3
+ end
@@ -0,0 +1,12 @@
1
+ module Stubhub
2
+ class Ticket < Document
3
+
4
+ def self.find_by_ticket_id(ticket_id)
5
+ options = {"stubhubDocumentType" => "#{demodulize(self).downcase}",
6
+ "id" => "#{ticket_id}"}
7
+ Client.make_request(Ticket, options)
8
+ end
9
+
10
+
11
+ end
12
+ end
@@ -0,0 +1,3 @@
1
+ module Stubhub
2
+ class Venue < Document;end
3
+ end
@@ -0,0 +1,3 @@
1
+ module Stubhub
2
+ class VenueZoneSection < Document;end
3
+ end
@@ -0,0 +1,3 @@
1
+ module Stubhub
2
+ VERSION = "0.0.1"
3
+ end
data/stubhub.gemspec ADDED
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'stubhub/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "stubhub"
8
+ gem.version = Stubhub::VERSION
9
+ gem.authors = ["Ryan Loomba"]
10
+ gem.email = ["ryan.loomba@gmail.com"]
11
+ gem.description = %q{A Ruby gem for accessing the stubhub api}
12
+ gem.summary = %q{A Ruby gem for accessing the stubhub api}
13
+ gem.homepage = "http://github.com/rloomba/stubhub"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ gem.add_development_dependency 'HTTParty'
20
+ end
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stubhub
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Ryan Loomba
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-02-18 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: HTTParty
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: A Ruby gem for accessing the stubhub api
31
+ email:
32
+ - ryan.loomba@gmail.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - Gemfile
38
+ - LICENSE.txt
39
+ - README.md
40
+ - Rakefile
41
+ - lib/stubhub.rb
42
+ - lib/stubhub/client.rb
43
+ - lib/stubhub/document.rb
44
+ - lib/stubhub/event.rb
45
+ - lib/stubhub/genre.rb
46
+ - lib/stubhub/geo.rb
47
+ - lib/stubhub/ticket.rb
48
+ - lib/stubhub/venue.rb
49
+ - lib/stubhub/venue_zone_section.rb
50
+ - lib/stubhub/version.rb
51
+ - stubhub.gemspec
52
+ homepage: http://github.com/rloomba/stubhub
53
+ licenses: []
54
+ post_install_message:
55
+ rdoc_options: []
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ requirements: []
71
+ rubyforge_project:
72
+ rubygems_version: 1.8.25
73
+ signing_key:
74
+ specification_version: 3
75
+ summary: A Ruby gem for accessing the stubhub api
76
+ test_files: []
77
+ has_rdoc: