chiketto 0.0.3 → 0.0.4
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 +3 -0
- data/lib/chiketto/category.rb +12 -0
- data/lib/chiketto/event.rb +5 -0
- data/lib/chiketto/resource.rb +6 -2
- data/lib/chiketto/version.rb +1 -1
- data/lib/hash_ext.rb +27 -0
- data/test/category_test.rb +24 -0
- data/test/event_test.rb +22 -2
- metadata +5 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dda2ccb3f3bb08a0fa9608d64fe991a454699238
|
4
|
+
data.tar.gz: 96bf882e5d1422ccb2302c3265cea13824d559d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04304e643ed8c6fc72275d6255cddcb34c09821cea74df11baa73921c38037d8d3d2e5cb07f81556c8199c113331aa4eeba341c9d2cd310aa5e64f41691e70f6
|
7
|
+
data.tar.gz: 81958275e5cbfe1e511d22e098dd080e9bb84d3fffe85c84a8324cd2197473b2ffc63e11c3cc70e3bcb6278e26015cc2099ade2ecf3dcc11df17a2306eaab9a3
|
data/lib/chiketto.rb
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
module Chiketto
|
2
2
|
ENDPOINT = 'https://www.eventbriteapi.com/v3/'
|
3
3
|
|
4
|
+
require 'hash_ext'
|
5
|
+
|
4
6
|
require 'chiketto/version'
|
5
7
|
require 'chiketto/attribute'
|
6
8
|
require 'chiketto/attr_attribute'
|
7
9
|
require 'chiketto/resource'
|
8
10
|
require 'chiketto/address'
|
11
|
+
require 'chiketto/category'
|
9
12
|
require 'chiketto/event'
|
10
13
|
require 'chiketto/organizer'
|
11
14
|
require 'chiketto/ticket_class'
|
data/lib/chiketto/event.rb
CHANGED
data/lib/chiketto/resource.rb
CHANGED
@@ -13,8 +13,8 @@ module Chiketto
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
def self.get(uri)
|
17
|
-
uri = endpoint
|
16
|
+
def self.get(uri, params = {})
|
17
|
+
uri = endpoint(uri) + query(params)
|
18
18
|
resource = open uri
|
19
19
|
JSON.parse resource.read
|
20
20
|
end
|
@@ -23,6 +23,10 @@ module Chiketto
|
|
23
23
|
ENDPOINT + uri + token
|
24
24
|
end
|
25
25
|
|
26
|
+
def self.query(params)
|
27
|
+
params.to_params
|
28
|
+
end
|
29
|
+
|
26
30
|
def self.token
|
27
31
|
"?token=#{ENV['EVENTBRITE_API_TOKEN']}"
|
28
32
|
end
|
data/lib/chiketto/version.rb
CHANGED
data/lib/hash_ext.rb
ADDED
@@ -0,0 +1,27 @@
|
|
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
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class CategoryTest < MiniTest::Test
|
4
|
+
def list_categories
|
5
|
+
VCR.use_cassette 'catgories' do
|
6
|
+
@categories = Chiketto::Category.list
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_categories_returns_list
|
11
|
+
list_categories
|
12
|
+
assert_kind_of Array, @categories
|
13
|
+
assert_kind_of Chiketto::Category, @categories.first
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_category_responds_to_methods
|
17
|
+
list_categories
|
18
|
+
@category = @categories.first
|
19
|
+
assert_respond_to @category, :id
|
20
|
+
assert_respond_to @category, :name
|
21
|
+
assert_respond_to @category, :resource_uri
|
22
|
+
assert_respond_to @category, :short_name
|
23
|
+
end
|
24
|
+
end
|
data/test/event_test.rb
CHANGED
@@ -3,18 +3,26 @@ require 'test_helper'
|
|
3
3
|
class EventTest < MiniTest::Test
|
4
4
|
TEST_ID = '9203575141'
|
5
5
|
|
6
|
-
def
|
7
|
-
VCR.use_cassette '
|
6
|
+
def find_event
|
7
|
+
VCR.use_cassette 'event-find' do
|
8
8
|
@event = Chiketto::Event.find TEST_ID
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
+
def search_events
|
13
|
+
VCR.use_cassette 'event-search' do
|
14
|
+
@events = Chiketto::Event.search q: 'Test Event'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
12
18
|
def test_fetching_event
|
19
|
+
find_event
|
13
20
|
assert_kind_of Chiketto::Event, @event
|
14
21
|
assert_equal @event.id, TEST_ID
|
15
22
|
end
|
16
23
|
|
17
24
|
def test_event_exposes_data
|
25
|
+
find_event
|
18
26
|
assert_respond_to @event, :id
|
19
27
|
assert_respond_to @event, :name
|
20
28
|
assert_respond_to @event, :description
|
@@ -33,31 +41,43 @@ class EventTest < MiniTest::Test
|
|
33
41
|
end
|
34
42
|
|
35
43
|
def test_name_attribute_is_valid
|
44
|
+
find_event
|
36
45
|
assert_respond_to @event.name, :html
|
37
46
|
assert_respond_to @event.name, :text
|
38
47
|
end
|
39
48
|
|
40
49
|
def test_description_attribute_is_valid
|
50
|
+
find_event
|
41
51
|
assert_respond_to @event.description, :html
|
42
52
|
assert_respond_to @event.description, :text
|
43
53
|
end
|
44
54
|
|
45
55
|
def test_organizer_is_object
|
56
|
+
find_event
|
46
57
|
assert_kind_of Chiketto::Organizer, @event.organizer
|
47
58
|
end
|
48
59
|
|
49
60
|
def test_venue_is_object
|
61
|
+
find_event
|
50
62
|
assert_kind_of Chiketto::Venue, @event.venue
|
51
63
|
end
|
52
64
|
|
53
65
|
def test_ticket_classes_is_object
|
66
|
+
find_event
|
54
67
|
assert_kind_of Chiketto::TicketClass, @event.ticket_classes.first
|
55
68
|
end
|
56
69
|
|
57
70
|
def test_date_attributes
|
71
|
+
find_event
|
58
72
|
assert_kind_of DateTime, @event.end
|
59
73
|
assert_kind_of DateTime, @event.start
|
60
74
|
assert_kind_of DateTime, @event.created
|
61
75
|
assert_kind_of DateTime, @event.changed
|
62
76
|
end
|
77
|
+
|
78
|
+
def test_search_returns_array_of_events
|
79
|
+
search_events
|
80
|
+
assert_kind_of Array, @events
|
81
|
+
assert_kind_of Chiketto::Event, @events.first
|
82
|
+
end
|
63
83
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chiketto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Radford
|
@@ -140,14 +140,17 @@ files:
|
|
140
140
|
- lib/chiketto/address.rb
|
141
141
|
- lib/chiketto/attr_attribute.rb
|
142
142
|
- lib/chiketto/attribute.rb
|
143
|
+
- lib/chiketto/category.rb
|
143
144
|
- lib/chiketto/event.rb
|
144
145
|
- lib/chiketto/organizer.rb
|
145
146
|
- lib/chiketto/resource.rb
|
146
147
|
- lib/chiketto/ticket_class.rb
|
147
148
|
- lib/chiketto/venue.rb
|
148
149
|
- lib/chiketto/version.rb
|
150
|
+
- lib/hash_ext.rb
|
149
151
|
- test/address_test.rb
|
150
152
|
- test/attribute_test.rb
|
153
|
+
- test/category_test.rb
|
151
154
|
- test/chiketto_test.rb
|
152
155
|
- test/event_test.rb
|
153
156
|
- test/organizer_test.rb
|
@@ -181,6 +184,7 @@ summary: Chiketto is a ruby gem for interacting with the Eventbrite V3 API
|
|
181
184
|
test_files:
|
182
185
|
- test/address_test.rb
|
183
186
|
- test/attribute_test.rb
|
187
|
+
- test/category_test.rb
|
184
188
|
- test/chiketto_test.rb
|
185
189
|
- test/event_test.rb
|
186
190
|
- test/organizer_test.rb
|