eventbrite_api_client 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f0e0107cfb193a9558a87caea1090b082ff95951
4
+ data.tar.gz: d5c66b4ebb98c326ea11f632b9568280372a7fa4
5
+ SHA512:
6
+ metadata.gz: 8c674da11e8ab18ba4a3453c1ac79859c8ac2fbea03e9f2d28ebd71eec36bec0662301aedbba3471251a9cb85fc93fca8888488538b16da9b3c9a5874760665e
7
+ data.tar.gz: 1c91d8e589e0b16423e6a5619104f0732c537bff6597395d18da2eabc4bf0365d5b297dedf2e400ab0f84b55e7d1b28294f505193bfb8a7a9c544383b8d3a6e8
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in eventbrite_api_client.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Kelly Price
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,40 @@
1
+ # EventbriteApiClient
2
+
3
+ This gem is was heavily influence by Eventbrite's official gem:
4
+ [eventbrite-client](https://github.com/ryanj/eventbrite-client.rb)
5
+
6
+ A simple client for Eventbrite's v3 API. It's just a wrapper around
7
+ `HTTParty` and returns `HTTParty::Response`'s. The mechanism is pretty
8
+ generic and could easily be applied to any API.
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ gem 'eventbrite_api_client'
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install eventbrite_api_client
23
+
24
+ ## Usage
25
+
26
+ ```ruby
27
+ eb_api_client = EventbriteApiClient.new(auth_token: YOUR_TOKEN)
28
+
29
+ response = eb_api_client.events.search.get(q: 'Free Beer')
30
+
31
+ response = eb_api_client.users(1_000_000).owned_events.get()
32
+ ```
33
+
34
+ ## Contributing
35
+
36
+ 1. Fork it ( http://github.com/kellyjosephprice/eventbrite_api_client/fork )
37
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
38
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
39
+ 4. Push to the branch (`git push origin my-new-feature`)
40
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ Dir.glob('tasks/**/*.rake').each(&method(:import))
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'eventbrite_api_client/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "eventbrite_api_client"
8
+ spec.version = EventbriteApiClient::VERSION
9
+ spec.authors = ["Kelly Price"]
10
+ spec.email = ["kellyjosephprice@gmail.com"]
11
+ spec.summary = %q{Eventbrite API Client}
12
+ spec.description = %q{A simple interface for the Eventbrite API}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.5"
22
+ spec.add_development_dependency "rake", "~> 10.4"
23
+ spec.add_development_dependency "rspec", "~> 3.3"
24
+
25
+ spec.add_runtime_dependency "httparty", "~> 0"
26
+ end
@@ -0,0 +1,3 @@
1
+ class EventbriteApiClient
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,53 @@
1
+ require 'eventbrite_api_client/version'
2
+ require 'httparty'
3
+
4
+ class EventbriteApiClient
5
+ include HTTParty
6
+ base_uri 'https://www.eventbriteapi.com/v3'
7
+
8
+ attr_reader :path
9
+
10
+ def initialize(options)
11
+ self.class.headers 'Authorization' => "Bearer #{options[:auth_token]}"
12
+
13
+ @path = ""
14
+ end
15
+
16
+ def get(params = {})
17
+ check_errors self.class.get(path, query: params)
18
+ end
19
+
20
+ def post(params = {})
21
+ check_errors self.class.post(path, query: params)
22
+ end
23
+
24
+ def method_missing(method_sym, *args)
25
+ them = self.dup
26
+
27
+ them.path = "#{them.path}/#{method_sym.to_s}"
28
+ them.path = "#{them.path}/#{args.first}" if args.first
29
+
30
+ them
31
+ end
32
+
33
+ protected
34
+ attr_writer :path
35
+
36
+ private
37
+ def check_errors(response)
38
+ if !is_json?(response)
39
+ {
40
+ 'error' => 'NOT_FOUND',
41
+ 'error_description' => 'That is not a valid api endpoint',
42
+ 'status_code' => 404
43
+ }
44
+ else
45
+ response
46
+ end
47
+ end
48
+
49
+ def is_json?(response)
50
+ response.respond_to?(:headers) &&
51
+ response.headers['content-type'] == 'application/json'
52
+ end
53
+ end
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ describe EventbriteApiClient do
4
+ subject { EventbriteApiClient.new(auth_token: 123) }
5
+
6
+ describe '#initialize' do
7
+ it 'should set headers' do
8
+ expect(subject.class.headers)
9
+ .to eq('Authorization' => 'Bearer 123')
10
+ end
11
+ end
12
+
13
+ describe '#method_missing' do
14
+ let(:client) { subject.events }
15
+ let(:params) { subject.events(24) }
16
+
17
+ it 'should update the path' do
18
+ expect(client.path).to eq('/events')
19
+ end
20
+
21
+ it 'should add params' do
22
+ expect(params.path).to eq('/events/24')
23
+ end
24
+
25
+ context 'chained calls' do
26
+ let(:nested) { client.search }
27
+ let(:nested_params) { params.search(48) }
28
+
29
+ it 'should update the path' do
30
+ expect(nested.path).to eq('/events/search')
31
+ end
32
+
33
+ it 'should add params' do
34
+ expect(nested_params.path).to eq('/events/24/search/48')
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Requests' do
4
+ subject { EventbriteApiClient.new(auth_token: 'BKKRDKVUVRC5WG4HAVLT') }
5
+
6
+ describe 'get event details' do
7
+ context 'on success' do
8
+ let(:response) { subject.events(10584525601).get() }
9
+
10
+ it 'should return a response' do
11
+ expect(response).to be_a(Hash)
12
+ expect(response['resource_uri'])
13
+ .to eq('https://www.eventbriteapi.com/v3/events/10584525601/')
14
+ end
15
+ end
16
+
17
+ context 'on failure' do
18
+ let(:failed) { subject.events(1).get() }
19
+
20
+ it 'should error gracefully' do
21
+ expect(failed).to be_a(Hash)
22
+ expect(failed['status_code']).to eq(404)
23
+ end
24
+ end
25
+ end
26
+
27
+ describe 'search events' do
28
+ context 'on success' do
29
+ let(:response) { subject.events.search.get(q: 'Free Beer') }
30
+
31
+ it 'should return a response' do
32
+ expect(response).to be_a(Hash)
33
+ expect(response).to include('pagination')
34
+ expect(response).to include('events')
35
+ end
36
+ end
37
+ end
38
+
39
+ describe 'polling an invalid API endpoint' do
40
+ let(:response) { subject.foo.get() }
41
+
42
+ it 'should error gracefully' do
43
+ expect(response).to be_a(Hash)
44
+ expect(response['status_code']).to eq(404)
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,4 @@
1
+ require 'bundler/setup'
2
+ Bundler.setup
3
+
4
+ require 'eventbrite_api_client'
data/tasks/rspec.rake ADDED
@@ -0,0 +1,3 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ RSpec::Core::RakeTask.new(:spec)
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: eventbrite_api_client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Kelly Price
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-06-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.4'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.4'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: httparty
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: A simple interface for the Eventbrite API
70
+ email:
71
+ - kellyjosephprice@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - eventbrite_api_client.gemspec
83
+ - lib/eventbrite_api_client.rb
84
+ - lib/eventbrite_api_client/version.rb
85
+ - spec/eventbrite_api_client_spec.rb
86
+ - spec/features/requests_spec.rb
87
+ - spec/spec_helper.rb
88
+ - tasks/rspec.rake
89
+ homepage: ''
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.4.5
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: Eventbrite API Client
113
+ test_files:
114
+ - spec/eventbrite_api_client_spec.rb
115
+ - spec/features/requests_spec.rb
116
+ - spec/spec_helper.rb