chiketto 0.4.10 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f61176708050b3b558a54d859de182a0dab6829d
4
- data.tar.gz: 60eeb7cbf7d3233b13706236b23281110988a773
3
+ metadata.gz: 16a62048aa94feb842642a5399d49f5a9d39b27a
4
+ data.tar.gz: 647034874eab8db972bc7488c3028c57573f34ad
5
5
  SHA512:
6
- metadata.gz: 41b9540fa6733ee0bf5f30a5db1e6e2441f100c81c814a0dab5b41e71f048804d96f48fc745013016bbd76acc0cc8995df099035e6e3e99761465c590032342c
7
- data.tar.gz: 7ed03765f751246d344b99603d43ea5c86b7b5ad70d58fdec8241d49331955925a2c697262210606a8da80082ea3f430e2a34a736242c5f220d468e113ecb5ea
6
+ metadata.gz: 481061140823e82479caeda288bad17b9ce80328acbab3e59d21d985c6d19b4dec7fb846746bbb0ed0a52376d65a67a8efcd8d4cf4e06293bdd599a3463736ca
7
+ data.tar.gz: 79bf9fdce64ef90338130f5ae7001e4ef0d048d85a909aeebc081ca206801303fdfb03ca4695b78af0528f51f8bfd1f5e8ef7f203d7386e3ac4d3ebd49a1d202
data/README.md CHANGED
@@ -1,11 +1,31 @@
1
- [![Build Status](https://travis-ci.org/chrisradfordltd/chiketto.svg?branch=master)](https://travis-ci.org/chrisradfordltd/chiketto)
2
- [![Code Climate](https://codeclimate.com/github/chrisradfordltd/chiketto.png)](https://codeclimate.com/github/chrisradfordltd/chiketto)
1
+ [![Build Status](https://img.shields.io/travis/chrisradfordltd/chiketto.svg?style=flat-square)](https://travis-ci.org/chrisradfordltd/chiketto)
2
+ [![Code Climate](https://img.shields.io/codeclimate/github/chrisradfordltd/chiketto.svg?style=flat-square)](https://codeclimate.com/github/chrisradfordltd/chiketto)
3
+ ![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)
4
+ ![Version](https://img.shields.io/gem/v/chiketto.svg?style=flat-square)
3
5
 
4
6
  # チケット - Chiketto
5
7
 
6
8
  Chiketto is a ruby gem for interacting with the Eventbrite V3 API, in Japanese chiketto means 'Ticket'. This library is tested on Ruby 2.0 and above, though may work on 1.9.3.
7
9
 
8
- Chiketto currently falls back to the V1 API when dealing with updating and creating events, though this will change with the 1.0 release.
10
+ ## V1 to V3 Update
11
+
12
+ In version 1.0 Chiketto removed the last remaining uses of the V1 API (creating events and organizers), and moved to exclusively using the V3 API.
13
+
14
+ Part of the V1 to V3 API change includes a new naming convention for parameters passed to POST requests, the full docs can be found at: http://www.eventbrite.com/developer/v3/
15
+
16
+ For example pre-V1.0 Chiketto:
17
+
18
+ ```
19
+ Chiketto::Organizer.create name: 'Test Organizer'
20
+ ```
21
+
22
+ Would, in V1.0 become:
23
+
24
+ ```
25
+ Chiketto::Organizer.create 'organizer.name': 'Test Organizer'
26
+ ```
27
+
28
+ In the V3 API version the required fields for each endpoint have also changed, for example, `currency` is now a required field for new events. For full details please refer to the API documentation.
9
29
 
10
30
  ## Installation
11
31
 
@@ -1,9 +1,9 @@
1
1
  module Chiketto
2
2
  ENDPOINT = 'https://www.eventbriteapi.com/v3/'
3
- LEGACY_ENDPOINT = 'https://www.eventbrite.com/json/'
4
3
 
5
4
  require 'hash_ext'
6
5
 
6
+ require 'chiketto/exception'
7
7
  require 'chiketto/version'
8
8
  require 'chiketto/attribute'
9
9
  require 'chiketto/attr_attribute'
@@ -20,7 +20,7 @@ module Chiketto
20
20
  return date if date.nil?
21
21
 
22
22
  if date.is_a?(Hash)
23
- date = date['local']
23
+ date = date['utc']
24
24
  DateTime.strptime date, '%FT%T'
25
25
  else
26
26
  DateTime.strptime date, '%FT%TZ'
@@ -16,11 +16,8 @@ module Chiketto
16
16
  :changed
17
17
 
18
18
  def self.create(params)
19
- params[:title] = params.delete(:name) if params[:name]
20
- response = Event.post 'event_new', params
21
- if response.fetch('process', false)
22
- Event.find response['process']['id']
23
- end
19
+ response = Event.post 'events', params
20
+ Event.new response
24
21
  end
25
22
 
26
23
  def self.find(id)
@@ -66,12 +63,8 @@ module Chiketto
66
63
  end
67
64
 
68
65
  def update(params)
69
- params[:id] = @id
70
- params[:title] = params.delete(:name) if params[:name]
71
- response = Event.post 'event_update', params
72
- if response.fetch('process', false)
73
- response['process']['status'].upcase == 'OK'
74
- end
66
+ response = Event.post "events/#{@id}", params
67
+ Event.new response
75
68
  end
76
69
 
77
70
  def venue
@@ -0,0 +1,4 @@
1
+ module Chiketto
2
+ class Exception < StandardError
3
+ end
4
+ end
@@ -5,12 +5,8 @@ module Chiketto
5
5
  attr_attrib :description
6
6
 
7
7
  def self.create(params)
8
- response = Organizer.post 'organizer_new', params
9
- if response.fetch('process', false)
10
- response['process']['id']
11
- elsif response.fetch('error', false)
12
- raise response['error']['error_message']
13
- end
8
+ response = Organizer.post 'organizers', params
9
+ Chiketto::Organizer.new response
14
10
  end
15
11
  end
16
12
  end
@@ -21,7 +21,7 @@ module Chiketto
21
21
  end
22
22
 
23
23
  def self.post(uri, params = {})
24
- uri = URI.parse legacy_endpoint(uri) + query(params)
24
+ uri = URI.parse endpoint(uri) + query(params)
25
25
  resource = open_post uri
26
26
  JSON.parse resource
27
27
  end
@@ -30,16 +30,16 @@ module Chiketto
30
30
  ENDPOINT + uri + token
31
31
  end
32
32
 
33
- def self.legacy_endpoint(uri)
34
- LEGACY_ENDPOINT + uri + "?"
35
- end
36
-
37
33
  def self.open_post(uri)
38
34
  http = Net::HTTP.new(uri.host, uri.port)
39
35
  http.use_ssl = true
40
36
  request = Net::HTTP::Post.new(uri.request_uri)
41
37
  request.add_field 'Authorization', "Bearer #{Chiketto.api_key}"
42
- http.request(request).body
38
+ response = http.request(request)
39
+ if response.code !~ /20\d/
40
+ raise Chiketto::Exception, JSON.parse(response.body)
41
+ end
42
+ response.body
43
43
  end
44
44
 
45
45
  def self.query(params)
@@ -1,3 +1,3 @@
1
1
  module Chiketto
2
- VERSION = "0.4.10"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -135,25 +135,32 @@ class EventTest < MiniTest::Test
135
135
  def test_updates_event_with_params
136
136
  VCR.use_cassette 'event-update' do
137
137
  find_event
138
- response = @event.update name: 'Movember 2014'
139
- assert response, 'Should return true after updating'
138
+ event = @event.update 'event.name.html' => 'Movember 2014'
139
+ assert_kind_of Chiketto::Event, event
140
140
  @event = Chiketto::Event.find @event.id
141
141
  assert_equal 'Movember 2014', @event.name.to_s
142
142
  end
143
143
  end
144
144
 
145
145
  def test_update_returns_false_for_invalid_id
146
- VCR.use_cassette 'event-update-fail' do
147
- event = Chiketto::Event.new id: '12345'
148
- response = event.update name: 'Movember 2014'
149
- refute response, 'Should return false for invalid id'
146
+ VCR.use_cassette 'event-update-failure' do
147
+ assert_raises Chiketto::Exception do
148
+ event = Chiketto::Event.new id: '12345'
149
+ event.update 'event.name.html' => 'Movember 2014'
150
+ end
150
151
  end
151
152
  end
152
153
 
153
154
  def test_create_a_new_event
154
155
  VCR.use_cassette 'event-create' do
155
- event = Chiketto::Event.create name: 'Test Event Creation',
156
- start_date: '2037-12-31 22:59:59', end_date: '2037-12-31 23:59:59'
156
+ event = Chiketto::Event.create({
157
+ 'event.name.html' => 'Test Event Creation',
158
+ 'event.start.utc' => '2018-05-12T02:00:00Z',
159
+ 'event.start.timezone' => 'Europe/London',
160
+ 'event.end.utc' => '2018-05-12T08:00:00Z',
161
+ 'event.end.timezone' => 'Europe/London',
162
+ 'event.currency' => 'USD',
163
+ })
157
164
  assert_kind_of Chiketto::Event, event
158
165
  assert_equal 'Test Event Creation', event.name.to_s
159
166
  end
@@ -161,8 +168,9 @@ class EventTest < MiniTest::Test
161
168
 
162
169
  def test_create_an_event_returns_false_on_failure
163
170
  VCR.use_cassette 'event-create-failure' do
164
- event = Chiketto::Event.create name: 'Test Event'
165
- refute event, 'Should return false when API rejects creation'
171
+ assert_raises Chiketto::Exception do
172
+ Chiketto::Event.create 'event.name.html' => 'Test Event'
173
+ end
166
174
  end
167
175
  end
168
176
  end
@@ -21,10 +21,19 @@ class OrganizerTest < MiniTest::Test
21
21
  assert_respond_to @organizer.description, :text
22
22
  end
23
23
 
24
- def test_cannot_create_an_existing_organizer
24
+ def test_creating_an_organizer
25
25
  VCR.use_cassette 'organizer-create' do
26
- assert_raises RuntimeError do
27
- Chiketto::Organizer.create name: 'Test Organizer'
26
+ name = ENV['CI'] ? Time.new.to_s : 'Test Name'
27
+ organizer = Chiketto::Organizer.create 'organizer.name' => name
28
+ assert_kind_of Chiketto::Organizer, organizer
29
+ assert_equal name, organizer.name
30
+ end
31
+ end
32
+
33
+ def test_cannot_create_an_existing_organizer
34
+ VCR.use_cassette 'organizer-create-failure' do
35
+ assert_raises Chiketto::Exception do
36
+ Chiketto::Organizer.create 'organizer.name' => 'Test Organizer'
28
37
  end
29
38
  end
30
39
  end
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: 0.4.10
4
+ version: 1.0.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-04-06 00:00:00.000000000 Z
11
+ date: 2015-05-26 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
@@ -118,6 +118,7 @@ files:
118
118
  - lib/chiketto/choice.rb
119
119
  - lib/chiketto/email.rb
120
120
  - lib/chiketto/event.rb
121
+ - lib/chiketto/exception.rb
121
122
  - lib/chiketto/organizer.rb
122
123
  - lib/chiketto/question.rb
123
124
  - lib/chiketto/resource.rb
@@ -151,17 +152,17 @@ require_paths:
151
152
  - lib
152
153
  required_ruby_version: !ruby/object:Gem::Requirement
153
154
  requirements:
154
- - - ">="
155
+ - - '>='
155
156
  - !ruby/object:Gem::Version
156
157
  version: '2.0'
157
158
  required_rubygems_version: !ruby/object:Gem::Requirement
158
159
  requirements:
159
- - - ">="
160
+ - - '>='
160
161
  - !ruby/object:Gem::Version
161
162
  version: '0'
162
163
  requirements: []
163
164
  rubyforge_project:
164
- rubygems_version: 2.4.5
165
+ rubygems_version: 2.0.14
165
166
  signing_key:
166
167
  specification_version: 4
167
168
  summary: Chiketto is a ruby gem for interacting with the Eventbrite V3 API
@@ -181,4 +182,3 @@ test_files:
181
182
  - test/ticket_class_test.rb
182
183
  - test/user_test.rb
183
184
  - test/venue_test.rb
184
- has_rdoc: