chiketto 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/chiketto.rb +0 -2
- data/lib/chiketto/category.rb +6 -3
- data/lib/chiketto/event.rb +33 -20
- data/lib/chiketto/organizer.rb +6 -1
- data/lib/chiketto/resource.rb +28 -4
- data/lib/chiketto/venue.rb +5 -0
- data/lib/chiketto/version.rb +1 -1
- data/test/event_test.rb +17 -9
- data/test/organizer_test.rb +1 -1
- metadata +20 -20
- data/lib/hash_ext.rb +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b827860000ff009a57e286076cd4beb25174d3c
|
4
|
+
data.tar.gz: c97bb7ae86c3102604d366e18eac425993dacf89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 535b022afc7dda335441249c3fffbe5a40558da0ba6c4ad41281aa7427fd4ae99198843dc6bab57301d172d702329cc4f436206f8c54adb69f4850f702aa0f72
|
7
|
+
data.tar.gz: 236706d3f4dc0dd3e652483aed44334d0393fc1da3be702f6b4c77ec82b4ed13706ed834b1a3311139171fcafeb3589caf27cb68522e032cb98385dde044bd41
|
data/lib/chiketto.rb
CHANGED
data/lib/chiketto/category.rb
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
module Chiketto
|
2
2
|
class Category < Resource
|
3
|
-
attr_accessor :name,
|
4
|
-
|
5
|
-
|
3
|
+
attr_accessor :name, :resource_uri, :short_name
|
4
|
+
|
5
|
+
def self.find(id)
|
6
|
+
response = get "categories/#{id}"
|
7
|
+
new response.to_h
|
8
|
+
end
|
6
9
|
|
7
10
|
def self.list
|
8
11
|
categories = get 'categories'
|
data/lib/chiketto/event.rb
CHANGED
@@ -1,27 +1,17 @@
|
|
1
1
|
module Chiketto
|
2
2
|
class Event < Resource
|
3
|
-
attr_reader :resource_uri,
|
4
|
-
:
|
5
|
-
|
6
|
-
|
7
|
-
:logo,
|
8
|
-
:logo_url
|
9
|
-
|
10
|
-
attr_attrib :description,
|
11
|
-
:name
|
12
|
-
|
13
|
-
attr_date :start,
|
14
|
-
:end,
|
15
|
-
:created,
|
16
|
-
:changed
|
3
|
+
attr_reader :resource_uri, :url, :capacity, :status, :logo, :logo_url,
|
4
|
+
:organizer_id, :venue_id, :category_id, :subcategory_id
|
5
|
+
attr_attrib :description, :name
|
6
|
+
attr_date :start, :end, :created, :changed
|
17
7
|
|
18
8
|
def self.create(params)
|
19
9
|
response = Event.post 'events', params
|
20
10
|
Event.new response
|
21
11
|
end
|
22
12
|
|
23
|
-
def self.find(id)
|
24
|
-
event = get "events/#{id}"
|
13
|
+
def self.find(id, params = {})
|
14
|
+
event = get "events/#{id}", params
|
25
15
|
Event.new event
|
26
16
|
end
|
27
17
|
|
@@ -36,7 +26,7 @@ module Chiketto
|
|
36
26
|
end
|
37
27
|
|
38
28
|
def category
|
39
|
-
|
29
|
+
@category = find_or_fetch_category(@category, @category_id)
|
40
30
|
end
|
41
31
|
|
42
32
|
def listed?
|
@@ -49,14 +39,21 @@ module Chiketto
|
|
49
39
|
end
|
50
40
|
|
51
41
|
def organizer
|
52
|
-
|
42
|
+
if @organizer.is_a?(Organizer)
|
43
|
+
@organizer
|
44
|
+
elsif @organizer
|
45
|
+
@organizer = Organizer.new @organizer.to_h
|
46
|
+
elsif @organizer_id
|
47
|
+
@organizer = Organizer.find @organizer_id
|
48
|
+
end
|
53
49
|
end
|
54
50
|
|
55
51
|
def subcategory
|
56
|
-
|
52
|
+
@subcategory = find_or_fetch_category(@subcategory, @subcategory_id)
|
57
53
|
end
|
58
54
|
|
59
55
|
def ticket_classes
|
56
|
+
return [] unless @ticket_classes
|
60
57
|
@ticket_classes.map do |t_class|
|
61
58
|
TicketClass.new t_class.to_h
|
62
59
|
end
|
@@ -68,11 +65,27 @@ module Chiketto
|
|
68
65
|
end
|
69
66
|
|
70
67
|
def venue
|
71
|
-
|
68
|
+
if @venue.is_a?(Venue)
|
69
|
+
@venue
|
70
|
+
elsif @venue
|
71
|
+
@venue = Venue.new @venue.to_h
|
72
|
+
elsif @venue_id
|
73
|
+
@venue = Venue.find @venue_id
|
74
|
+
end
|
72
75
|
end
|
73
76
|
|
74
77
|
private
|
75
78
|
|
79
|
+
def find_or_fetch_category(category, category_id)
|
80
|
+
if category.is_a?(Category)
|
81
|
+
category
|
82
|
+
elsif category
|
83
|
+
Category.new category.to_h
|
84
|
+
elsif category_id
|
85
|
+
Category.find category_id
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
76
89
|
def self.find_questions(id, params = {})
|
77
90
|
get "events/#{id}/questions", params
|
78
91
|
end
|
data/lib/chiketto/organizer.rb
CHANGED
@@ -4,8 +4,13 @@ module Chiketto
|
|
4
4
|
|
5
5
|
attr_attrib :description
|
6
6
|
|
7
|
+
def self.find(id)
|
8
|
+
response = get "organizers/#{id}"
|
9
|
+
Organizer.new response
|
10
|
+
end
|
11
|
+
|
7
12
|
def self.create(params)
|
8
|
-
response =
|
13
|
+
response = post 'organizers', params
|
9
14
|
Chiketto::Organizer.new response
|
10
15
|
end
|
11
16
|
end
|
data/lib/chiketto/resource.rb
CHANGED
@@ -15,13 +15,15 @@ module Chiketto
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.get(uri, params = {})
|
18
|
-
uri = endpoint(uri) +
|
18
|
+
uri = endpoint(uri) + build_query_string(params)
|
19
19
|
resource = open uri
|
20
20
|
JSON.parse resource.read
|
21
|
+
rescue OpenURI::HTTPError => e
|
22
|
+
raise e unless e.message =~ /^404/
|
21
23
|
end
|
22
24
|
|
23
25
|
def self.post(uri, params = {})
|
24
|
-
uri = URI.parse endpoint(uri) +
|
26
|
+
uri = URI.parse endpoint(uri) + build_query_string(params)
|
25
27
|
resource = open_post uri
|
26
28
|
JSON.parse resource
|
27
29
|
end
|
@@ -42,8 +44,30 @@ module Chiketto
|
|
42
44
|
response.body
|
43
45
|
end
|
44
46
|
|
45
|
-
def self.
|
46
|
-
|
47
|
+
def self.build_query_string(params)
|
48
|
+
query_params = ''
|
49
|
+
stack = []
|
50
|
+
|
51
|
+
params.each do |k, v|
|
52
|
+
if v.is_a?(Hash)
|
53
|
+
stack << [k, v]
|
54
|
+
else
|
55
|
+
query_params << "#{k}=#{CGI::escape(v)}&"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
stack.each do |parent, hash|
|
60
|
+
hash.each do |k, v|
|
61
|
+
if v.is_a?(Hash)
|
62
|
+
stack << ["#{parent}[#{k}]", v]
|
63
|
+
else
|
64
|
+
query_params << "#{parent}[#{k}]=#{CGI::escape(v)}&"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
query_params.chop!
|
70
|
+
"&#{query_params}"
|
47
71
|
end
|
48
72
|
|
49
73
|
def self.token
|
data/lib/chiketto/venue.rb
CHANGED
data/lib/chiketto/version.rb
CHANGED
data/test/event_test.rb
CHANGED
@@ -60,9 +60,11 @@ class EventTest < MiniTest::Test
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def test_categories_are_objects
|
63
|
-
|
64
|
-
|
65
|
-
|
63
|
+
VCR.use_cassette 'event-categories' do
|
64
|
+
find_event
|
65
|
+
assert_kind_of Chiketto::Category, @event.category
|
66
|
+
assert_kind_of Chiketto::Category, @event.subcategory
|
67
|
+
end
|
66
68
|
end
|
67
69
|
|
68
70
|
def test_questions_are_objects
|
@@ -74,18 +76,24 @@ class EventTest < MiniTest::Test
|
|
74
76
|
end
|
75
77
|
|
76
78
|
def test_organizer_is_object
|
77
|
-
|
78
|
-
|
79
|
+
VCR.use_cassette 'event-organizer' do
|
80
|
+
find_event
|
81
|
+
assert_kind_of Chiketto::Organizer, @event.organizer
|
82
|
+
end
|
79
83
|
end
|
80
84
|
|
81
85
|
def test_venue_is_object
|
82
|
-
|
83
|
-
|
86
|
+
VCR.use_cassette 'event-venue' do
|
87
|
+
find_event
|
88
|
+
assert_kind_of Chiketto::Venue, @event.venue
|
89
|
+
end
|
84
90
|
end
|
85
91
|
|
86
92
|
def test_ticket_classes_is_object
|
87
|
-
|
88
|
-
|
93
|
+
VCR.use_cassette 'event-ticket_classes' do
|
94
|
+
@event = Chiketto::Event.find TEST_ID, expand: 'ticket_classes'
|
95
|
+
assert_kind_of Chiketto::TicketClass, @event.ticket_classes.first
|
96
|
+
end
|
89
97
|
end
|
90
98
|
|
91
99
|
def test_date_attributes
|
data/test/organizer_test.rb
CHANGED
@@ -23,7 +23,7 @@ class OrganizerTest < MiniTest::Test
|
|
23
23
|
|
24
24
|
def test_creating_an_organizer
|
25
25
|
VCR.use_cassette 'organizer-create' do
|
26
|
-
name = ENV['CI'] ? Time.new.to_s : 'Test Name'
|
26
|
+
name = ENV['CI'] ? Time.new.to_s : 'Test Organizer Name'
|
27
27
|
organizer = Chiketto::Organizer.create 'organizer.name' => name
|
28
28
|
assert_kind_of Chiketto::Organizer, organizer
|
29
29
|
assert_equal name, organizer.name
|
metadata
CHANGED
@@ -1,97 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chiketto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Radford
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.6'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: dotenv
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: webmock
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: vcr
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
description: Chiketto is a ruby gem for interacting with the Eventbrite V3 API
|
@@ -101,8 +101,8 @@ executables: []
|
|
101
101
|
extensions: []
|
102
102
|
extra_rdoc_files: []
|
103
103
|
files:
|
104
|
-
- .gitignore
|
105
|
-
- .travis.yml
|
104
|
+
- ".gitignore"
|
105
|
+
- ".travis.yml"
|
106
106
|
- Gemfile
|
107
107
|
- LICENSE.txt
|
108
108
|
- README.md
|
@@ -126,7 +126,6 @@ files:
|
|
126
126
|
- lib/chiketto/user.rb
|
127
127
|
- lib/chiketto/venue.rb
|
128
128
|
- lib/chiketto/version.rb
|
129
|
-
- lib/hash_ext.rb
|
130
129
|
- test/address_test.rb
|
131
130
|
- test/attendee_profile_test.rb
|
132
131
|
- test/attendee_test.rb
|
@@ -152,17 +151,17 @@ require_paths:
|
|
152
151
|
- lib
|
153
152
|
required_ruby_version: !ruby/object:Gem::Requirement
|
154
153
|
requirements:
|
155
|
-
- -
|
154
|
+
- - ">="
|
156
155
|
- !ruby/object:Gem::Version
|
157
156
|
version: '2.0'
|
158
157
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
159
158
|
requirements:
|
160
|
-
- -
|
159
|
+
- - ">="
|
161
160
|
- !ruby/object:Gem::Version
|
162
161
|
version: '0'
|
163
162
|
requirements: []
|
164
163
|
rubyforge_project:
|
165
|
-
rubygems_version: 2.
|
164
|
+
rubygems_version: 2.4.5
|
166
165
|
signing_key:
|
167
166
|
specification_version: 4
|
168
167
|
summary: Chiketto is a ruby gem for interacting with the Eventbrite V3 API
|
@@ -182,3 +181,4 @@ test_files:
|
|
182
181
|
- test/ticket_class_test.rb
|
183
182
|
- test/user_test.rb
|
184
183
|
- test/venue_test.rb
|
184
|
+
has_rdoc:
|
data/lib/hash_ext.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
class Hash
|
2
|
-
def to_params
|
3
|
-
params = ''
|
4
|
-
stack = []
|
5
|
-
|
6
|
-
each do |k, v|
|
7
|
-
if v.is_a?(Hash)
|
8
|
-
stack << [k, v]
|
9
|
-
else
|
10
|
-
params << "#{k}=#{CGI::escape(v)}&"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
stack.each do |parent, hash|
|
15
|
-
hash.each do |k, v|
|
16
|
-
if v.is_a?(Hash)
|
17
|
-
stack << ["#{parent}[#{k}]", v]
|
18
|
-
else
|
19
|
-
params << "#{parent}[#{k}]=#{CGI::escape(v)}&"
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
params.chop!
|
25
|
-
"&#{params}"
|
26
|
-
end
|
27
|
-
end
|