tickethub 0.3.7 → 0.3.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5d4a096f67ed58b50591b241abd2255bfa3ac03e
4
- data.tar.gz: 8c46ad998705a95f638119f825ebb5280292ac74
3
+ metadata.gz: 1cb8b0b77986976c93f03f3bb4d277f44fd8b613
4
+ data.tar.gz: 226d787e65748b173aab9859a5e6e20c036e99fb
5
5
  SHA512:
6
- metadata.gz: d019a9d113811eae8b1103cf140823963e73bbc125c326b6929ac02e4c7d86ffd935a3ed269ecdd6510f51b8da2d6a41ff6afbb246a67c0feb31390043f66806
7
- data.tar.gz: 490b52b2a3966e513c03cb8bf40039759da47d39f683d93f3cd5e886f2668c22ec11dcb1839a7a31f1cf184921ca4887611444807673eed2f676bca973e2b696
6
+ metadata.gz: e0ac1c12c2d2a53fee584287dfc93d3a8c0a6d7729b740c720df4380174aaea75d8f4bbbfc4bff77706554df49aa3954c9e56e367eb97e8ed618f4b156f61826
7
+ data.tar.gz: 200666283f1cebd7e78d2ad8f96359bb9728df7e673b2f476f9d497d2bbd068c380318b584edc61719613a2e46ad8225543009bf75b58c49d7e8130613194d56
data/lib/tickethub.rb CHANGED
@@ -26,5 +26,4 @@ module Tickethub
26
26
  require_relative 'tickethub/supplier'
27
27
  require_relative 'tickethub/app'
28
28
  require_relative 'tickethub/user'
29
- require_relative 'tickethub/job'
30
29
  end
@@ -30,13 +30,13 @@ module Tickethub
30
30
  self.reload! if cache.nil?
31
31
 
32
32
  cache.each do |row|
33
- yielder << @klass.load(endpoint, row)
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.load(endpoint, row)
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.load endpoint, endpoint.get(params)
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.load endpoint, post(attributes)
153
+ @klass.call endpoint, post(attributes)
154
154
  rescue Tickethub::ResourceInvalid => err
155
- @klass.load endpoint, Tickethub::Response.new(err.response).decoded
155
+ @klass.call endpoint, Tickethub::Response.new(err.response).decoded
156
156
  end
157
157
  end
158
158
  end
@@ -151,9 +151,8 @@ module Tickethub
151
151
  end.to_h
152
152
  end
153
153
 
154
- def self.load(endpoint, attributes = nil)
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, path: key)
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.load(@endpoint[path], attrs) :
179
- klass.load(@endpoint[path])
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, path: key, &block)
182
+ def self.collection(key, klass, &block)
184
183
  define_method key do |params = {}|
185
- Tickethub::Collection.new(@endpoint[path], klass, params).tap do |collection|
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.load @endpoint.get
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
@@ -26,7 +26,6 @@ module Tickethub
26
26
 
27
27
  def decoded
28
28
  @decoded ||= parser ? parser.decode(body) : body
29
- code == 202 ? Tickethub::Job.load(Tickethub.endpoint, @decoded) : @decoded
30
29
  end
31
30
 
32
31
  def respond_to?(name)
@@ -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.load Tickethub.endpoint(auth_type: :bearer, password: token)[path]
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
- Tickethub::Job.load self.endpoint, post(:broadcast, params)
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
@@ -0,0 +1,13 @@
1
+ require_relative '../resource'
2
+
3
+ module Tickethub
4
+ class Supplier::Broadcast < Resource
5
+ path '/supplier/broadcasts'
6
+
7
+ require_relative 'message'
8
+
9
+ collection :messages, Supplier::Message
10
+
11
+ attribute :created_at, type: :datetime
12
+ end
13
+ end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Tickethub
2
- VERSION = '0.3.7'
2
+ VERSION = '0.3.9'
3
3
  end
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.7
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-23 00:00:00.000000000 Z
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