eventbrite-client 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Ryan Jarvinen
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,53 @@
1
+ #eventbrite-client.rb#
2
+
3
+ ##Description##
4
+ A tiny ruby-based http client for the Eventbrite API
5
+
6
+ For the latest information on this project, take a look at:
7
+
8
+ * [This project's source code repo](http://github.com/eventbrite/eventbrite-client.rb/)
9
+ * [The Eventbrite API documentation](http://developer.eventbrite.com/doc/)
10
+
11
+ ##Usage Examples##
12
+
13
+ ###Installation via rubygems ###
14
+
15
+ gem install eventbrite-client
16
+
17
+ ###Loading the Eventbrite API Client library code###
18
+
19
+ require eventbrite-client
20
+
21
+ ###Initializing the client###
22
+ Your API / Application key is required to initialize the client - http://eventbrite.com/api/key
23
+
24
+ Set your user_key if you want to access private data - http://eventbrite.com/userkeyapi
25
+
26
+ eb_auth_tokens = { app_key: 'YOUR_APP_KEY',
27
+ user_key: 'YOU_USER_KEY'}
28
+ eb_client = EventbriteClient.new(eb_auth_tokens)
29
+
30
+ ###Calling API methods###
31
+ See [Eventbrite's API method documentation](http://developer.eventbrite.com/doc/) for more information about the list of available client methods.
32
+
33
+ Here is an example using the API's [user_list_events](http://developer.eventbrite.com/doc/users/user_list_events/) method:
34
+
35
+ response = eb_client.user_list_events()
36
+
37
+ The [event_get](http://developer.eventbrite.com/doc/events/event_get/) API call should look like this:
38
+
39
+ response = eb_client.event_get({id: 1848891083})
40
+
41
+ ### Widgets ###
42
+ Rendering an event in html as a [ticketWidget](http://www.eventbrite.com/t/how-to-use-ticket-widget) is easy:
43
+
44
+ response = eb_client.event_get({id: 1848891083})
45
+ widget_html = EventbriteWidgets::ticketWidget(response['event'])
46
+
47
+ ##Resources##
48
+ * API Documentation - <http://developer.eventbrite.com/doc/>
49
+ * API QuickStart Guide - <http://developer.eventbrite.com/doc/getting-started/>
50
+ * Eventbrite Open Source - <http://eventbrite.github.com/>
51
+ * Eventbrite App Showcase - <http://eventbrite.appstores.com/>
52
+ * 0.3x source - <http://github.com/eventbrite/eventbrite-client-py/>
53
+ * 0.2x source - <http://github.com/mtai/eventbrite/>
data/Rakefile ADDED
@@ -0,0 +1,53 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "eventbrite-client"
8
+ gem.summary = %Q{A tiny EventBrite API client}
9
+ gem.description = %Q{A with the EventBrite events service. (http://developer.eventbrite.com)}
10
+ gem.email = "ryan.jarvinen@gmail.com"
11
+ gem.homepage = "http://github.com/ryanjarvinen/eventbrite-client.rb"
12
+ gem.authors = ["Ryan Jarvinen"]
13
+ gem.add_development_dependency "rspec", "~> 1.3.0"
14
+ gem.add_dependency "httparty", "~> 0.7.0"
15
+ gem.add_dependency "tzinfo", "~> 0.3.22"
16
+
17
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
18
+ end
19
+ Jeweler::GemcutterTasks.new
20
+ rescue LoadError
21
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
22
+ end
23
+
24
+ require 'spec/rake/spectask'
25
+ Spec::Rake::SpecTask.new(:spec) do |spec|
26
+ spec.libs << 'lib' << 'spec'
27
+ spec.spec_files = FileList['spec/**/*_spec.rb']
28
+ end
29
+
30
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
31
+ spec.libs << 'lib' << 'spec'
32
+ spec.pattern = 'spec/**/*_spec.rb'
33
+ spec.rcov = true
34
+ end
35
+
36
+ task :spec => :check_dependencies
37
+
38
+ task :default => :irb
39
+
40
+ require 'rake/rdoctask'
41
+ Rake::RDocTask.new do |rdoc|
42
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
43
+
44
+ rdoc.rdoc_dir = 'rdoc'
45
+ rdoc.title = "eventbrite-client #{version}"
46
+ rdoc.rdoc_files.include('README*')
47
+ rdoc.rdoc_files.include('lib/*.rb')
48
+ end
49
+
50
+ desc "Runs irb with eventbrite-client lib"
51
+ task :irb do
52
+ sh "irb -r 'lib/eventbrite-client'"
53
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,51 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{eventbrite-client}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Ryan Jarvinen"]
12
+ s.date = %q{2011-08-28}
13
+ s.description = %q{A tiny EventBrite API client. (http://developer.eventbrite.com)}
14
+ s.email = %q{ryan.jarvinen@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ "LICENSE",
22
+ "README.md",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "eventbrite-client.gemspec",
26
+ "lib/eventbrite-client.rb",
27
+ ]
28
+ s.homepage = %q{http://github.com/ryanjarvinen/eventbrite-client.rb}
29
+ s.require_paths = ["lib"]
30
+ s.rubygems_version = %q{1.6.2}
31
+ s.summary = %q{A tiny EventBrite API client}
32
+
33
+ if s.respond_to? :specification_version then
34
+ s.specification_version = 3
35
+
36
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
37
+ s.add_development_dependency(%q<rspec>, ["~> 1.3.0"])
38
+ s.add_runtime_dependency(%q<httparty>, ["~> 0.7.0"])
39
+ s.add_runtime_dependency(%q<tzinfo>, ["~> 0.3.22"])
40
+ else
41
+ s.add_dependency(%q<rspec>, ["~> 1.3.0"])
42
+ s.add_dependency(%q<httparty>, ["~> 0.7.0"])
43
+ s.add_dependency(%q<tzinfo>, ["~> 0.3.22"])
44
+ end
45
+ else
46
+ s.add_dependency(%q<rspec>, ["~> 1.3.0"])
47
+ s.add_dependency(%q<httparty>, ["~> 0.7.0"])
48
+ s.add_dependency(%q<tzinfo>, ["~> 0.3.22"])
49
+ end
50
+ end
51
+
@@ -0,0 +1,70 @@
1
+ require 'httparty'
2
+ class EventbriteClient
3
+ include HTTParty
4
+ base_uri 'https://www.eventbrite.com'
5
+
6
+ def initialize( auth_tokens )
7
+ @auth = {}
8
+ @data_type = 'json'
9
+ if auth_tokens.is_a? Hash
10
+ if auth_tokens.include? :access_token
11
+ # use oauth2 authentication tokens
12
+ self.class.headers 'Authorization' => "Bearer #{auth_tokens[:access_token]}"
13
+ elsif auth_tokens.include? :app_key
14
+ #use api_key OR api_key + user_key OR api_key+email+pass
15
+ if auth_tokens.include? :user_key
16
+ # read/write access on the user account associated with :user_key
17
+ @auth = {app_key: auth_tokens[:app_key], user_key: auth_tokens[:user_key]}
18
+ elsif auth_tokens.include?(:user) && auth_tokens.include?(:password)
19
+ # read/write access on the user account matching this login info
20
+ @auth = {app_key: auth_tokens[:app_key], user: auth_tokens[:user], :password => auth_tokens[:password]}
21
+ else
22
+ # read-only access to public data
23
+ @auth = {app_key: auth_tokens[:app_key]}
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+ # available API request methods are documented at:
30
+ # http://developer.eventbrite.com/doc
31
+ def method_request( method, params )
32
+ #merge auth params into our request querystring
33
+ querystring = @auth.merge( params.is_a?(Hash) ? params : {} )
34
+ resp = self.class.get("/#{@data_type}/#{method.to_s}",{query: querystring})
35
+ if resp['error']
36
+ raise RuntimeError, resp['error']['error_message'], caller[1..-1]
37
+ end
38
+ return resp
39
+ end
40
+
41
+ def method_missing(method, *args, &block)
42
+ self.method_request(method, args[0])
43
+ end
44
+ end
45
+
46
+ class EventbriteWidgets
47
+ def self.ticketWidget(evnt)
48
+ "<div style='width:100%; text-align:left;' ><iframe src='http://www.eventbrite.com/tickets-external?eid=#{ evnt["id"]}&ref=etckt' frameborder='0' height='192' width='100%' vspace='0' hspace='0' marginheight='5' marginwidth='5' scrolling='auto' allowtransparency='true'></iframe><div style='font-family:Helvetica, Arial; font-size:10px; padding:5px 0 5px; margin:2px; width:100%; text-align:left;'><a style='color:#ddd; text-decoration:none;' target='_blank' href='http://www.eventbrite.com/r/etckt'>Online Ticketing</a><span style='color:#ddd;'> for </span><a style='color:#ddd; text-decoration:none;' target='_blank' href='http://www.eventbrite.com/event/#{evnt["id"]}?ref=etckt'>#{evnt["title"]}</a><span style='color:#ddd;'> powered by </span><a style='color:#ddd; text-decoration:none;' target='_blank' href='http://www.eventbrite.com?ref=etckt'>Eventbrite</a></div></div>"
49
+ end
50
+
51
+ def self.registrationWidget(evnt)
52
+ "<div style='width:100%; text-align:left;'><iframe src='http://www.eventbrite.com/event/#{evnt['id']}?ref=eweb' frameborder='0' height='1000' width='100%' vspace='0' hspace='0' marginheight='5' marginwidth='5' scrolling='auto' allowtransparency='true'></iframe><div style='font-family:Helvetica, Arial; font-size:10px; padding:5px 0 5px; margin:2px; width:100%; text-align:left;'><a style='color:#ddd; text-decoration:none;' target='_blank' href='http://www.eventbrite.com/r/eweb'>Online Ticketing</a><span style='color:#ddd;'> for </span><a style='color:#ddd; text-decoration:none;' target='_blank' href='http://www.eventbrite.com/event/#{evnt['id']}?ref=eweb'>#{evnt['title']}</a><span style='color:#ddd;'> powered by </span><a style='color:#ddd; text-decoration:none;' target='_blank' href='http://www.eventbrite.com?ref=eweb'>Eventbrite</a></div></div>"
53
+ end
54
+
55
+ def self.calendarWidget(evnt)
56
+ "<div style='width:195px; text-align:center;'><iframe src='http://www.eventbrite.com/calendar-widget?eid=#{evnt['id']}' frameborder='0' height='382' width='195' marginheight='0' marginwidth='0' scrolling='no' allowtransparency='true'></iframe><div style='font-family:Helvetica, Arial; font-size:10px; padding:5px 0 5px; margin:2px; width:195px; text-align:center;'><a style='color:#ddd; text-decoration:none;' target='_blank' href='http://www.eventbrite.com/r/ecal'>Online event registration</a><span style='color:#ddd;'> powered by </span><a style='color:#ddd; text-decoration:none;' target='_blank' href='http://www.eventbrite.com?ref=ecal'>Eventbrite</a></div></div>"
57
+ end
58
+
59
+ def self.countdownWidget(evnt)
60
+ "<div style='width:195px; text-align:center;'><iframe src='http://www.eventbrite.com/countdown-widget?eid=#{evnt['id']}' frameborder='0' height='479' width='195' marginheight='0' marginwidth='0' scrolling='no' allowtransparency='true'></iframe><div style='font-family:Helvetica, Arial; font-size:10px; padding:5px 0 5px; margin:2px; width:195px; text-align:center;'><a style='color:#ddd; text-decoration:none;' target='_blank' href='http://www.eventbrite.com/r/ecount'>Online event registration</a><span style='color:#ddd;'> for </span><a style='color:#ddd; text-decoration:none;' target='_blank' href='http://www.eventbrite.com/event/#{evnt['id']}?ref=ecount'>#{evnt['title']}</a></div></div>"
61
+ end
62
+
63
+ def self.buttonWidget(evnt)
64
+ "<a href='http://www.eventbrite.com/event/#{evnt['id']}?ref=ebtn' target='_blank'><img border='0' src='http://www.eventbrite.com/registerbutton?eid=#{evnt['id']}' alt='Register for #{evnt['title']} on Eventbrite' /></a>"
65
+ end
66
+
67
+ def self.linkWidget(evnt, text=nil, color='#000000')
68
+ "<a href='http://www.eventbrite.com/event/#{evnt["id"]}?ref=elink' target='_blank' style='color:#{color};'>#{text || evnt['title']}</a>"
69
+ end
70
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: eventbrite-client
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.0
6
+ platform: ruby
7
+ authors:
8
+ - Ryan Jarvinen
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-08-28 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rspec
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: 1.3.0
24
+ type: :development
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: httparty
28
+ prerelease: false
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: 0.7.0
35
+ type: :runtime
36
+ version_requirements: *id002
37
+ - !ruby/object:Gem::Dependency
38
+ name: tzinfo
39
+ prerelease: false
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 0.3.22
46
+ type: :runtime
47
+ version_requirements: *id003
48
+ description: A tiny EventBrite API client. (http://developer.eventbrite.com)
49
+ email: ryan.jarvinen@gmail.com
50
+ executables: []
51
+
52
+ extensions: []
53
+
54
+ extra_rdoc_files:
55
+ - LICENSE
56
+ - README.md
57
+ files:
58
+ - .document
59
+ - LICENSE
60
+ - README.md
61
+ - Rakefile
62
+ - VERSION
63
+ - eventbrite-client.gemspec
64
+ - lib/eventbrite-client.rb
65
+ homepage: http://github.com/ryanjarvinen/eventbrite-client.rb
66
+ licenses: []
67
+
68
+ post_install_message:
69
+ rdoc_options: []
70
+
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: "0"
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: "0"
85
+ requirements: []
86
+
87
+ rubyforge_project:
88
+ rubygems_version: 1.8.10
89
+ signing_key:
90
+ specification_version: 3
91
+ summary: A tiny EventBrite API client
92
+ test_files: []
93
+