tickethub 0.0.2 → 0.0.3
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 +4 -4
- data/lib/tickethub/collection.rb +2 -2
- data/lib/tickethub/resource.rb +136 -130
- data/lib/tickethub/supplier/message/email.rb +1 -1
- data/lib/tickethub/supplier/message/sms.rb +1 -1
- data/lib/tickethub/supplier/payment/card.rb +1 -5
- data/lib/tickethub/supplier/payment/cash.rb +1 -1
- data/lib/tickethub/supplier/payment/credit.rb +1 -1
- data/lib/tickethub/supplier/payment/direct.rb +1 -1
- data/lib/tickethub/supplier/payment/gratuity.rb +1 -1
- data/lib/tickethub/supplier.rb +2 -4
- data/lib/tickethub/token.rb +1 -1
- data/lib/tickethub/user.rb +1 -1
- data/lib/tickethub/version.rb +1 -1
- metadata +2 -7
- data/lib/tickethub/supplier/gateway/handpoint.rb +0 -8
- data/lib/tickethub/supplier/gateway/ideal.rb +0 -8
- data/lib/tickethub/supplier/gateway/paypal.rb +0 -8
- data/lib/tickethub/supplier/gateway/stripe.rb +0 -8
- data/lib/tickethub/supplier/gateway.rb +0 -16
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ccb152a358383394fb8a2903b7cf8355371fb8d7
|
|
4
|
+
data.tar.gz: 828a41238c5ab820f77bcdf4348b54c177360c89
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e9812ade047a542884babf81062e6dc99974d101b10ece33b5a8ccbb6279eba62a0d9e8de576bffb37f01173b3568b3ae4d6e88fa7275dc0bd14d4f655f5d341
|
|
7
|
+
data.tar.gz: d194028938875dda6266b94883f92e948114abf244e36aefa3758d2ad56068382425f36fe51e51221124976a4892d0fb03a5b286d663e9bfeeaf9d6267147b3f
|
data/lib/tickethub/collection.rb
CHANGED
|
@@ -137,9 +137,9 @@ module Tickethub
|
|
|
137
137
|
end
|
|
138
138
|
|
|
139
139
|
def create(attributes = {})
|
|
140
|
-
@klass.
|
|
140
|
+
@klass.load @endpoint, @endpoint.post(attributes).decoded
|
|
141
141
|
rescue Tickethub::ResourceInvalid => err
|
|
142
|
-
@klass.
|
|
142
|
+
@klass.load @endpoint, Tickethub::Response.new(err.response).decoded
|
|
143
143
|
end
|
|
144
144
|
|
|
145
145
|
def scope(key, params = {}, options = {})
|
data/lib/tickethub/resource.rb
CHANGED
|
@@ -10,16 +10,13 @@ module Tickethub
|
|
|
10
10
|
|
|
11
11
|
class << self
|
|
12
12
|
|
|
13
|
-
def
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
def polymorphic(type, options = {})
|
|
18
|
-
self.superclass.register_type type, **options
|
|
13
|
+
def path(value, options = {})
|
|
14
|
+
@path = value
|
|
15
|
+
@options = options
|
|
19
16
|
end
|
|
20
17
|
|
|
21
|
-
def
|
|
22
|
-
|
|
18
|
+
def endpoint
|
|
19
|
+
Tickethub.endpoint[@path, @options]
|
|
23
20
|
end
|
|
24
21
|
|
|
25
22
|
def registered_types
|
|
@@ -30,150 +27,163 @@ module Tickethub
|
|
|
30
27
|
@scopes ||= {}
|
|
31
28
|
end
|
|
32
29
|
|
|
33
|
-
def
|
|
34
|
-
@
|
|
35
|
-
@path = value
|
|
36
|
-
@options = options
|
|
30
|
+
def attributes
|
|
31
|
+
@attributes ||= {}
|
|
37
32
|
end
|
|
38
33
|
|
|
39
|
-
def
|
|
40
|
-
|
|
34
|
+
def descendants
|
|
35
|
+
@descendants ||= []
|
|
41
36
|
end
|
|
37
|
+
end
|
|
42
38
|
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
def self.inherited(descendant)
|
|
40
|
+
if descendant.ancestors.member? Tickethub::Resource
|
|
41
|
+
self.descendants.push descendant
|
|
45
42
|
end
|
|
43
|
+
end
|
|
46
44
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
def self.all(params = {})
|
|
46
|
+
Tickethub::Collection.new self.endpoint, self, params
|
|
47
|
+
end
|
|
50
48
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
end
|
|
49
|
+
def self.polymorphic(type, attribute = :type)
|
|
50
|
+
self.superclass.register_type type, self, attribute
|
|
51
|
+
end
|
|
55
52
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
def self.register_type(type, klass, attribute = :type) # klass, attribute
|
|
54
|
+
self.registered_types[type] = { klass: klass, attribute: attribute }
|
|
55
|
+
end
|
|
59
56
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
when String then ISO8601::Date.new(value)
|
|
66
|
-
else raise ArgumentError, 'invalid date value: ' + value
|
|
67
|
-
end
|
|
68
|
-
when :datetime
|
|
69
|
-
case value
|
|
70
|
-
when String then ISO8601::DateTime.new(value)
|
|
71
|
-
else raise ArgumentError, 'invalid datetime value: ' + value
|
|
72
|
-
end
|
|
73
|
-
when :time
|
|
74
|
-
case value
|
|
75
|
-
when String then ISO8601::Time.new(value)
|
|
76
|
-
else raise ArgumentError, 'invalid time value: ' + value
|
|
77
|
-
end
|
|
78
|
-
when :duration
|
|
79
|
-
case value
|
|
80
|
-
when String then ISO8601::Duration.new(value)
|
|
81
|
-
else raise ArgumentError, 'invalid time value: ' + value
|
|
82
|
-
end
|
|
83
|
-
when :money
|
|
84
|
-
currency = Money::Currency.new(object.currency)
|
|
85
|
-
raise ArgumentError, 'invalid money currency' if currency.blank?
|
|
86
|
-
|
|
87
|
-
case value
|
|
88
|
-
when Fixnum then Money.new(value, currency)
|
|
89
|
-
when Numeric, String
|
|
90
|
-
currency = Money::Currency.wrap(currency)
|
|
91
|
-
Money.new(value.to_d * currency.subunit_to_unit, currency)
|
|
92
|
-
else raise ArgumentError, 'invalid money value: ' + value
|
|
93
|
-
end
|
|
94
|
-
when :currency
|
|
95
|
-
case value
|
|
96
|
-
when String then Money::Currency.new(value)
|
|
97
|
-
else raise ArgumentError, 'invalid currency value: ' + value
|
|
98
|
-
end
|
|
99
|
-
when :timezone
|
|
100
|
-
case value
|
|
101
|
-
when String then Timezone::Zone.new(zone: value)
|
|
102
|
-
else raise ArgumentError, 'invalid timezone value: ' + value
|
|
103
|
-
end
|
|
104
|
-
when :country
|
|
105
|
-
case value
|
|
106
|
-
when String then Country.new(value)
|
|
107
|
-
else raise ArgumentError, 'invalid country value: ' + value
|
|
108
|
-
end
|
|
109
|
-
else value
|
|
110
|
-
end
|
|
57
|
+
def self.attribute(key, options)
|
|
58
|
+
self.attributes[key] = options
|
|
59
|
+
|
|
60
|
+
self.descendants.each do |descendant|
|
|
61
|
+
descendant.attributes[key] = options
|
|
111
62
|
end
|
|
63
|
+
end
|
|
112
64
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
65
|
+
def self.scope(key, proc = -> (params = {}) { self.scope key, params })
|
|
66
|
+
self.scopes[key] = proc
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def self.load_value(key, value, object)
|
|
70
|
+
return nil if value.nil? || (value.is_a?(String) && value.empty?)
|
|
71
|
+
return value unless self.attributes.key? key
|
|
72
|
+
|
|
73
|
+
case self.attributes[key][:type]
|
|
74
|
+
when :date
|
|
75
|
+
case value
|
|
76
|
+
when String then ISO8601::Date.new(value)
|
|
77
|
+
else raise ArgumentError, 'invalid date value: ' + value
|
|
78
|
+
end
|
|
79
|
+
when :datetime
|
|
80
|
+
case value
|
|
81
|
+
when String then ISO8601::DateTime.new(value)
|
|
82
|
+
else raise ArgumentError, 'invalid datetime value: ' + value
|
|
83
|
+
end
|
|
84
|
+
when :time
|
|
85
|
+
case value
|
|
86
|
+
when String then ISO8601::Time.new(value)
|
|
87
|
+
else raise ArgumentError, 'invalid time value: ' + value
|
|
88
|
+
end
|
|
89
|
+
when :duration
|
|
90
|
+
case value
|
|
91
|
+
when String then ISO8601::Duration.new(value)
|
|
92
|
+
else raise ArgumentError, 'invalid time value: ' + value
|
|
93
|
+
end
|
|
94
|
+
when :money
|
|
95
|
+
currency = Money::Currency.new(object.currency)
|
|
96
|
+
raise ArgumentError, 'invalid money currency' if currency.blank?
|
|
97
|
+
|
|
98
|
+
case value
|
|
99
|
+
when Fixnum then Money.new(value, currency)
|
|
100
|
+
when Numeric, String
|
|
101
|
+
currency = Money::Currency.wrap(currency)
|
|
102
|
+
Money.new(value.to_d * currency.subunit_to_unit, currency)
|
|
103
|
+
else raise ArgumentError, 'invalid money value: ' + value
|
|
104
|
+
end
|
|
105
|
+
when :currency
|
|
106
|
+
case value
|
|
107
|
+
when String then Money::Currency.new(value)
|
|
108
|
+
else raise ArgumentError, 'invalid currency value: ' + value
|
|
109
|
+
end
|
|
110
|
+
when :timezone
|
|
111
|
+
case value
|
|
112
|
+
when String then Timezone::Zone.new(zone: value)
|
|
113
|
+
else raise ArgumentError, 'invalid timezone value: ' + value
|
|
114
|
+
end
|
|
115
|
+
when :country
|
|
116
|
+
case value
|
|
117
|
+
when String then Country.new(value)
|
|
118
|
+
else raise ArgumentError, 'invalid country value: ' + value
|
|
119
|
+
end
|
|
120
|
+
else value
|
|
125
121
|
end
|
|
122
|
+
end
|
|
126
123
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
124
|
+
def self.dump_value(key, value)
|
|
125
|
+
return value unless self.attributes.key? key
|
|
126
|
+
case self.attributes[key][:type]
|
|
127
|
+
when :date then value.iso8601
|
|
128
|
+
when :datetime then value.iso8601
|
|
129
|
+
when :time then value.iso8601[10..-1]
|
|
130
|
+
when :duration then value.iso8601
|
|
131
|
+
when :money then value.fractional
|
|
132
|
+
when :timezone then value.zone
|
|
133
|
+
when :country then value.alpha2
|
|
134
|
+
when :currency then value.iso_code
|
|
135
|
+
else value
|
|
131
136
|
end
|
|
137
|
+
end
|
|
132
138
|
|
|
133
|
-
|
|
134
|
-
|
|
139
|
+
def self.serialize(attributes)
|
|
140
|
+
attributes.collect do |key, value|
|
|
141
|
+
[key, dump_value(key, value)]
|
|
142
|
+
end.to_h
|
|
143
|
+
end
|
|
135
144
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
end
|
|
145
|
+
def self.load(endpoint, attributes = nil)
|
|
146
|
+
attributes ||= endpoint.get
|
|
139
147
|
|
|
140
|
-
|
|
148
|
+
klass = registered_types.find do |type, options|
|
|
149
|
+
attributes[options[:attribute].to_s] == type
|
|
150
|
+
end
|
|
141
151
|
|
|
142
|
-
|
|
143
|
-
endpoint = klass.endpoint[id, endpoint.options]
|
|
144
|
-
end
|
|
152
|
+
klass = klass ? klass[1][:klass] : self
|
|
145
153
|
|
|
146
|
-
|
|
154
|
+
if id = attributes['id']
|
|
155
|
+
endpoint = klass.endpoint[id, endpoint.options]
|
|
147
156
|
end
|
|
148
157
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
instance_variable_defined?("@#{key}") ? instance_variable_get("@#{key}") :
|
|
152
|
-
instance_variable_set("@#{key}", klass.load(@endpoint[path]))
|
|
153
|
-
end
|
|
158
|
+
klass.new endpoint, attributes
|
|
159
|
+
end
|
|
154
160
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
161
|
+
def self.association(key, klass, path: key)
|
|
162
|
+
define_method key do
|
|
163
|
+
instance_variable_defined?("@#{key}") ? instance_variable_get("@#{key}") :
|
|
164
|
+
instance_variable_set("@#{key}", klass.load(@endpoint[path]))
|
|
159
165
|
end
|
|
160
166
|
|
|
161
|
-
|
|
167
|
+
define_method "#{key}=" do |value|
|
|
168
|
+
instance_variable_set "@#{key}", ((value.nil? || value.is_a?(klass)) ? value :
|
|
169
|
+
klass.load(@endpoint[path], value))
|
|
170
|
+
end
|
|
171
|
+
end
|
|
162
172
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
173
|
+
def self.collection(key, klass, path: key, &block)
|
|
174
|
+
define_method key do |params = {}|
|
|
175
|
+
(instance_variable_defined?("@#{key}") ? instance_variable_get("@#{key}") :
|
|
176
|
+
(sinleton? || id?) ? instance_variable_set("@#{key}",
|
|
177
|
+
Tickethub::Collection.new(@endpoint[path], klass, params)) : []).tap do |collection|
|
|
178
|
+
collection.instance_eval &block if block
|
|
179
|
+
end
|
|
180
|
+
end
|
|
170
181
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
end
|
|
182
|
+
define_method "#{key}=" do |values|
|
|
183
|
+
instance_variable_set "@#{key}", id??
|
|
184
|
+
(Tickethub::Collection.new(@endpoint[path], klass).tap do |collection|
|
|
185
|
+
collection.cache = values
|
|
186
|
+
end) : values.collect { |value| klass.load @endpoint, value }
|
|
177
187
|
end
|
|
178
188
|
end
|
|
179
189
|
|
|
@@ -202,10 +212,6 @@ module Tickethub
|
|
|
202
212
|
self.load @endpoint.delete.decoded
|
|
203
213
|
end
|
|
204
214
|
|
|
205
|
-
def singleton?
|
|
206
|
-
!! @singleton
|
|
207
|
-
end
|
|
208
|
-
|
|
209
215
|
def respond_to?(method, include_priv = false)
|
|
210
216
|
@attributes.key?(method.to_s.remove(/[=\?]\Z/).to_sym) || super
|
|
211
217
|
end
|
|
@@ -2,17 +2,13 @@ require_relative '../payment'
|
|
|
2
2
|
|
|
3
3
|
module Tickethub
|
|
4
4
|
class Supplier::Payment::Card < Supplier::Payment
|
|
5
|
-
polymorphic 'card'
|
|
5
|
+
polymorphic 'card'
|
|
6
6
|
path '/supplier/payments/card'
|
|
7
7
|
|
|
8
8
|
require_relative '../card'
|
|
9
|
-
require_relative '../gateway'
|
|
10
|
-
|
|
11
9
|
require_relative '../../address'
|
|
12
10
|
|
|
13
11
|
association :card, Supplier::Card
|
|
14
|
-
association :gateway, Supplier::Gateway
|
|
15
|
-
|
|
16
12
|
association :address, Tickethub::Address
|
|
17
13
|
end
|
|
18
14
|
end
|
data/lib/tickethub/supplier.rb
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
module Tickethub
|
|
2
2
|
class Supplier < Resource
|
|
3
|
-
path '/supplier'
|
|
3
|
+
path '/supplier'
|
|
4
4
|
|
|
5
5
|
require_relative 'supplier/bill'
|
|
6
|
-
require_relative 'supplier/gateway'
|
|
7
6
|
require_relative 'supplier/customer'
|
|
8
7
|
require_relative 'supplier/template'
|
|
9
8
|
require_relative 'supplier/order'
|
|
@@ -31,7 +30,6 @@ module Tickethub
|
|
|
31
30
|
require_relative 'token'
|
|
32
31
|
|
|
33
32
|
collection :bills, Bill
|
|
34
|
-
collection :gateways, Gateway
|
|
35
33
|
collection :customers, Customer
|
|
36
34
|
collection :templates, Template
|
|
37
35
|
collection :orders, Order
|
|
@@ -80,7 +78,7 @@ module Tickethub
|
|
|
80
78
|
end
|
|
81
79
|
|
|
82
80
|
def settings
|
|
83
|
-
@endpoint[:settings].get
|
|
81
|
+
@endpoint[:settings].get.decoded
|
|
84
82
|
end
|
|
85
83
|
end
|
|
86
84
|
end
|
data/lib/tickethub/token.rb
CHANGED
data/lib/tickethub/user.rb
CHANGED
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.0.
|
|
4
|
+
version: 0.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Oliver Morgan
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-11-
|
|
11
|
+
date: 2014-11-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -143,11 +143,6 @@ files:
|
|
|
143
143
|
- lib/tickethub/supplier/customer.rb
|
|
144
144
|
- lib/tickethub/supplier/element.rb
|
|
145
145
|
- lib/tickethub/supplier/fee.rb
|
|
146
|
-
- lib/tickethub/supplier/gateway.rb
|
|
147
|
-
- lib/tickethub/supplier/gateway/handpoint.rb
|
|
148
|
-
- lib/tickethub/supplier/gateway/ideal.rb
|
|
149
|
-
- lib/tickethub/supplier/gateway/paypal.rb
|
|
150
|
-
- lib/tickethub/supplier/gateway/stripe.rb
|
|
151
146
|
- lib/tickethub/supplier/invoice.rb
|
|
152
147
|
- lib/tickethub/supplier/message.rb
|
|
153
148
|
- lib/tickethub/supplier/message/email.rb
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
require_relative '../resource'
|
|
2
|
-
|
|
3
|
-
module Tickethub
|
|
4
|
-
class Supplier::Gateway < Resource
|
|
5
|
-
path '/supplier/gateways'
|
|
6
|
-
|
|
7
|
-
require_relative 'gateway/stripe'
|
|
8
|
-
require_relative 'gateway/paypal'
|
|
9
|
-
require_relative 'gateway/handpoint'
|
|
10
|
-
require_relative 'gateway/ideal'
|
|
11
|
-
|
|
12
|
-
require_relative 'payment'
|
|
13
|
-
|
|
14
|
-
collection :payments, Supplier::Payment
|
|
15
|
-
end
|
|
16
|
-
end
|