tickethub 0.3.7 → 0.3.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tickethub.rb +0 -1
- data/lib/tickethub/collection.rb +5 -5
- data/lib/tickethub/resource.rb +8 -10
- data/lib/tickethub/response.rb +0 -1
- data/lib/tickethub/supplier.rb +3 -1
- data/lib/tickethub/supplier/booking.rb +6 -1
- data/lib/tickethub/supplier/broadcast.rb +13 -0
- data/lib/tickethub/supplier/customer.rb +5 -0
- data/lib/tickethub/supplier/message.rb +9 -0
- data/lib/tickethub/supplier/order.rb +5 -4
- data/lib/tickethub/supplier/reseller.rb +5 -0
- data/lib/tickethub/version.rb +1 -1
- metadata +3 -3
- data/lib/tickethub/job.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1cb8b0b77986976c93f03f3bb4d277f44fd8b613
|
4
|
+
data.tar.gz: 226d787e65748b173aab9859a5e6e20c036e99fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0ac1c12c2d2a53fee584287dfc93d3a8c0a6d7729b740c720df4380174aaea75d8f4bbbfc4bff77706554df49aa3954c9e56e367eb97e8ed618f4b156f61826
|
7
|
+
data.tar.gz: 200666283f1cebd7e78d2ad8f96359bb9728df7e673b2f476f9d497d2bbd068c380318b584edc61719613a2e46ad8225543009bf75b58c49d7e8130613194d56
|
data/lib/tickethub.rb
CHANGED
data/lib/tickethub/collection.rb
CHANGED
@@ -30,13 +30,13 @@ module Tickethub
|
|
30
30
|
self.reload! if cache.nil?
|
31
31
|
|
32
32
|
cache.each do |row|
|
33
|
-
yielder << @klass.
|
33
|
+
yielder << @klass.call(endpoint, row)
|
34
34
|
end
|
35
35
|
|
36
36
|
while (offset + cache.length) < count
|
37
37
|
response = endpoint.get params.merge(offset: cache.length)
|
38
38
|
response.decoded.each do |row| cache << row
|
39
|
-
yielder << @klass.
|
39
|
+
yielder << @klass.call(endpoint, row)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
@@ -143,16 +143,16 @@ module Tickethub
|
|
143
143
|
self.filter(id: search)
|
144
144
|
when String
|
145
145
|
endpoint = self.endpoint[@klass.path, CGI::escape(search)]
|
146
|
-
@klass.
|
146
|
+
@klass.call endpoint, endpoint.get(params)
|
147
147
|
else
|
148
148
|
raise ArgumentError, 'invalid search value type'
|
149
149
|
end
|
150
150
|
end
|
151
151
|
|
152
152
|
def create(attributes = {})
|
153
|
-
@klass.
|
153
|
+
@klass.call endpoint, post(attributes)
|
154
154
|
rescue Tickethub::ResourceInvalid => err
|
155
|
-
@klass.
|
155
|
+
@klass.call endpoint, Tickethub::Response.new(err.response).decoded
|
156
156
|
end
|
157
157
|
end
|
158
158
|
end
|
data/lib/tickethub/resource.rb
CHANGED
@@ -151,9 +151,8 @@ module Tickethub
|
|
151
151
|
end.to_h
|
152
152
|
end
|
153
153
|
|
154
|
-
def self.
|
154
|
+
def self.call(endpoint, attributes = nil)
|
155
155
|
attributes ||= endpoint.get
|
156
|
-
return attributes if attributes.is_a? Tickethub::Job
|
157
156
|
|
158
157
|
klass = registered_types.find do |type, options|
|
159
158
|
attributes[options[:attribute].to_s] == type
|
@@ -171,18 +170,18 @@ module Tickethub
|
|
171
170
|
klass.new endpoint, attributes
|
172
171
|
end
|
173
172
|
|
174
|
-
def self.association(key, klass
|
173
|
+
def self.association(key, klass)
|
175
174
|
define_method key do
|
176
175
|
@attributes.key?(key.to_sym) ?
|
177
176
|
(attrs = @attributes[key.to_sym]) &&
|
178
|
-
klass.
|
179
|
-
klass.
|
177
|
+
klass.call(@endpoint[key], attrs) :
|
178
|
+
klass.call(@endpoint[key])
|
180
179
|
end
|
181
180
|
end
|
182
181
|
|
183
|
-
def self.collection(key, klass,
|
182
|
+
def self.collection(key, klass, &block)
|
184
183
|
define_method key do |params = {}|
|
185
|
-
Tickethub::Collection.new(@endpoint[
|
184
|
+
Tickethub::Collection.new(@endpoint[key], klass, params).tap do |collection|
|
186
185
|
collection.instance_eval &block if block
|
187
186
|
end
|
188
187
|
end
|
@@ -218,7 +217,7 @@ module Tickethub
|
|
218
217
|
end
|
219
218
|
|
220
219
|
def reload!
|
221
|
-
self.
|
220
|
+
self.call @endpoint.get
|
222
221
|
end
|
223
222
|
|
224
223
|
def load(attributes)
|
@@ -277,8 +276,7 @@ module Tickethub
|
|
277
276
|
|
278
277
|
case match[2]
|
279
278
|
when '='
|
280
|
-
@attributes[key] = self.class
|
281
|
-
.load_value(key, arguments.first, self)
|
279
|
+
@attributes[key] = self.class.load_value(key, arguments.first, self)
|
282
280
|
when "?"
|
283
281
|
!! @attributes[key]
|
284
282
|
end
|
data/lib/tickethub/response.rb
CHANGED
data/lib/tickethub/supplier.rb
CHANGED
@@ -26,6 +26,7 @@ module Tickethub
|
|
26
26
|
require_relative 'supplier/message'
|
27
27
|
require_relative 'supplier/charge'
|
28
28
|
require_relative 'supplier/import'
|
29
|
+
require_relative 'supplier/broadcast'
|
29
30
|
|
30
31
|
require_relative 'contact'
|
31
32
|
require_relative 'token'
|
@@ -55,6 +56,7 @@ module Tickethub
|
|
55
56
|
collection :messages, Message
|
56
57
|
collection :charges, Charge
|
57
58
|
collection :imports, Import
|
59
|
+
collection :broadcasts, Broadcast
|
58
60
|
|
59
61
|
association :contact, Tickethub::Contact
|
60
62
|
association :token, Tickethub::Token
|
@@ -69,7 +71,7 @@ module Tickethub
|
|
69
71
|
def self.[](attributes)
|
70
72
|
token = attributes[:token].is_a?(String) ? attributes[:token]
|
71
73
|
: attributes[:token][:access_token]
|
72
|
-
self.
|
74
|
+
self.call Tickethub.endpoint(auth_type: :bearer, password: token)[path]
|
73
75
|
end
|
74
76
|
|
75
77
|
def initialize(endpoint, attributes = nil)
|
@@ -15,9 +15,14 @@ module Tickethub
|
|
15
15
|
require_relative 'message'
|
16
16
|
require_relative 'extra'
|
17
17
|
require_relative 'fee'
|
18
|
+
require_relative 'broadcast'
|
18
19
|
|
19
20
|
collection_method :broadcast do |params|
|
20
|
-
|
21
|
+
Supplier::Broadcast.call self.endpoint, begin
|
22
|
+
post(:broadcast, params)
|
23
|
+
rescue Tickethub::ResourceInvalid => err
|
24
|
+
Tickethub::Response.new(err.response).decoded
|
25
|
+
end
|
21
26
|
end
|
22
27
|
|
23
28
|
collection :answers, Supplier::Answer
|
@@ -8,9 +8,14 @@ module Tickethub
|
|
8
8
|
require_relative 'ticket'
|
9
9
|
require_relative 'message'
|
10
10
|
require_relative 'source'
|
11
|
+
require_relative 'broadcast'
|
11
12
|
|
12
13
|
require_relative '../address'
|
13
14
|
|
15
|
+
collection_method :broadcast do |params|
|
16
|
+
Tickethub::Broadcast.call self.endpoint, post(:broadcast, params)
|
17
|
+
end
|
18
|
+
|
14
19
|
collection :orders, Supplier::Booking
|
15
20
|
collection :tickets, Supplier::Ticket
|
16
21
|
collection :sources, Supplier::Source
|
@@ -13,6 +13,15 @@ module Tickethub
|
|
13
13
|
association :contact, Tickethub::Contact
|
14
14
|
association :customer, Supplier::Customer
|
15
15
|
|
16
|
+
association :context, -> (endpoint, attributes) {
|
17
|
+
case attributes['object']
|
18
|
+
when 'booking' then Supplier::Booking.call(endpoint, attributes)
|
19
|
+
when 'customer' then Supplier::Customer.call(endpoint, attributes)
|
20
|
+
when 'order' then Supplier::Order.call(endpoint, attributes)
|
21
|
+
when 'reseller' then Supplier::Reseller.call(endpoint, attributes)
|
22
|
+
end
|
23
|
+
}
|
24
|
+
|
16
25
|
attribute :created_at, type: :datetime
|
17
26
|
|
18
27
|
collection :replies, Supplier::Message
|
@@ -15,6 +15,11 @@ module Tickethub
|
|
15
15
|
require_relative 'user'
|
16
16
|
require_relative 'answer'
|
17
17
|
require_relative 'message'
|
18
|
+
require_relative 'broadcast'
|
19
|
+
|
20
|
+
collection_method :broadcast do |params|
|
21
|
+
Tickethub::Broadcast.call self.endpoint, post(:broadcast, params)
|
22
|
+
end
|
18
23
|
|
19
24
|
collection :bookings, Supplier::Booking
|
20
25
|
collection :payments, Supplier::Payment
|
@@ -37,10 +42,6 @@ module Tickethub
|
|
37
42
|
attribute :created_at, type: :datetime
|
38
43
|
attribute :updated_at, type: :datetime
|
39
44
|
|
40
|
-
def restore(params = {})
|
41
|
-
self.load @endpoint[:restore].post(params)
|
42
|
-
end
|
43
|
-
|
44
45
|
def confirm(params = {})
|
45
46
|
self.load @endpoint[:confirm].post(params)
|
46
47
|
end
|
@@ -8,11 +8,16 @@ module Tickethub
|
|
8
8
|
require_relative 'product'
|
9
9
|
require_relative 'message'
|
10
10
|
require_relative 'rate'
|
11
|
+
require_relative 'broadcast'
|
11
12
|
|
12
13
|
require_relative '../token'
|
13
14
|
require_relative '../contact'
|
14
15
|
require_relative '../address'
|
15
16
|
|
17
|
+
collection_method :broadcast do |params|
|
18
|
+
Tickethub::Broadcast.call self.endpoint, post(:broadcast, params)
|
19
|
+
end
|
20
|
+
|
16
21
|
collection :invoices, Supplier::Invoice
|
17
22
|
collection :products, Supplier::Product
|
18
23
|
collection :messages, Supplier::Message
|
data/lib/tickethub/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tickethub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oliver Morgan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -104,7 +104,6 @@ files:
|
|
104
104
|
- lib/tickethub/formats/form_format.rb
|
105
105
|
- lib/tickethub/formats/json_format.rb
|
106
106
|
- lib/tickethub/helpers.rb
|
107
|
-
- lib/tickethub/job.rb
|
108
107
|
- lib/tickethub/request.rb
|
109
108
|
- lib/tickethub/resource.rb
|
110
109
|
- lib/tickethub/response.rb
|
@@ -116,6 +115,7 @@ files:
|
|
116
115
|
- lib/tickethub/supplier/booking.rb
|
117
116
|
- lib/tickethub/supplier/booking/ticket.rb
|
118
117
|
- lib/tickethub/supplier/booking/voucher.rb
|
118
|
+
- lib/tickethub/supplier/broadcast.rb
|
119
119
|
- lib/tickethub/supplier/charge.rb
|
120
120
|
- lib/tickethub/supplier/charge/gateway.rb
|
121
121
|
- lib/tickethub/supplier/charge/service.rb
|
data/lib/tickethub/job.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
module Tickethub
|
2
|
-
class Job < Resource
|
3
|
-
path '/jobs'
|
4
|
-
|
5
|
-
attribute :completed_at, type: :datetime
|
6
|
-
attribute :created_at, type: :datetime
|
7
|
-
attribute :updated_at, type: :datetime
|
8
|
-
|
9
|
-
|
10
|
-
def self.[](id)
|
11
|
-
self.load Tickethub.endpoint[path, id]
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|