tickethub 0.3.30 → 0.3.31
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 +5 -5
- data/lib/tickethub/endpoint.rb +2 -2
- data/lib/tickethub/reseller/channel.rb +18 -0
- data/lib/tickethub/reseller/product.rb +19 -0
- data/lib/tickethub/reseller.rb +33 -0
- data/lib/tickethub/resource.rb +15 -7
- data/lib/tickethub/supplier/override.rb +16 -0
- data/lib/tickethub/supplier/product.rb +0 -4
- data/lib/tickethub/supplier/reseller.rb +4 -4
- data/lib/tickethub/user/app.rb +2 -0
- data/lib/tickethub/user/reseller.rb +7 -0
- data/lib/tickethub/user/supplier.rb +2 -0
- data/lib/tickethub/user.rb +13 -0
- data/lib/tickethub/version.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07c9fbf4c9ee640bac8a02569679bdccec914a6d
|
4
|
+
data.tar.gz: 335943a4029d019d8188f20dedbf8ee37e78f224
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aafcc034f51534c2b5cc3f6fc62610f9888b0bf1cdb3de3d7e0ec4c8292b446430cc297674fe5621baf6edb91a6eb9a3b9444f4e5c4f8738e5d20bb589771915
|
7
|
+
data.tar.gz: 55a409843cd7c4bcad3cb3d5a1434923fa8a8fc980965017584a5ec53a5eedc4926101c447dcd5f4d8113293fe67e3f992951cc1f12730fa4a181c2fd11dc8d5
|
data/lib/tickethub/collection.rb
CHANGED
@@ -10,8 +10,9 @@ module Tickethub
|
|
10
10
|
attr_accessor :cache
|
11
11
|
attr_reader :count, :endpoint, :params
|
12
12
|
|
13
|
-
def initialize(endpoint, klass, params = {})
|
13
|
+
def initialize(endpoint, klass, params = {}, options = {})
|
14
14
|
@params = params.dup
|
15
|
+
@options = options.dup
|
15
16
|
@endpoint = endpoint
|
16
17
|
@klass = klass
|
17
18
|
|
@@ -142,17 +143,16 @@ module Tickethub
|
|
142
143
|
when Array
|
143
144
|
self.filter(id: search)
|
144
145
|
when String
|
145
|
-
|
146
|
-
@klass.call endpoint, endpoint.get(params)
|
146
|
+
@klass.call endpoint, CGI::escape(search), @options
|
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.call endpoint, post(attributes)
|
153
|
+
@klass.call endpoint, post(attributes), @options
|
154
154
|
rescue Tickethub::ResourceInvalid => err
|
155
|
-
@klass.call endpoint, Tickethub::Response.new(err.response).decoded
|
155
|
+
@klass.call endpoint, Tickethub::Response.new(err.response).decoded, @options
|
156
156
|
end
|
157
157
|
end
|
158
158
|
end
|
data/lib/tickethub/endpoint.rb
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative '../resource'
|
2
|
+
|
3
|
+
module Tickethub
|
4
|
+
class Reseller::Channel < Resource
|
5
|
+
path '/reseller/channels'
|
6
|
+
|
7
|
+
require_relative 'product'
|
8
|
+
require_relative '../token'
|
9
|
+
|
10
|
+
association :private_token, Tickethub::Token
|
11
|
+
association :public_token, Tickethub::Token
|
12
|
+
|
13
|
+
association :product, Reseller::Product
|
14
|
+
|
15
|
+
attribute :updated_at, type: :datetime
|
16
|
+
attribute :created_at, type: :datetime
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative '../resource'
|
2
|
+
|
3
|
+
module Tickethub
|
4
|
+
class Reseller::Product < Resource
|
5
|
+
path '/reseller/products'
|
6
|
+
|
7
|
+
require_relative '../contact'
|
8
|
+
require_relative '../address'
|
9
|
+
|
10
|
+
association :contact, Tickethub::Contact
|
11
|
+
association :address, Tickethub::Address
|
12
|
+
|
13
|
+
attribute :time_zone, type: :timezone
|
14
|
+
attribute :currency, type: :currency
|
15
|
+
|
16
|
+
attribute :created_at, type: :datetime
|
17
|
+
attribute :updated_at, type: :datetime
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Tickethub
|
2
|
+
class Reseller < Resource
|
3
|
+
path '/resellers'
|
4
|
+
|
5
|
+
require_relative 'contact'
|
6
|
+
require_relative 'reseller/channel'
|
7
|
+
|
8
|
+
association :contact, Tickethub::Contact
|
9
|
+
association :token, Tickethub::Token
|
10
|
+
|
11
|
+
association :category, App::Category
|
12
|
+
collection :subscriptions, App::Subscription
|
13
|
+
|
14
|
+
attribute :currency, type: :currency
|
15
|
+
|
16
|
+
def self.[](attributes)
|
17
|
+
token = attributes[:token].is_a?(String) ? attributes[:token]
|
18
|
+
: attributes[:token][:access_token]
|
19
|
+
self.new Tickethub.endpoint(auth_type: :bearer, password: token)['/reseller']
|
20
|
+
end
|
21
|
+
|
22
|
+
def initialize(endpoint, attributes = nil)
|
23
|
+
attributes ||= endpoint.get
|
24
|
+
|
25
|
+
if attributes['token']
|
26
|
+
endpoint = Tickethub.endpoint(auth_type: :bearer,
|
27
|
+
password: attributes['token']['access_token'])[self.class.path]
|
28
|
+
end
|
29
|
+
|
30
|
+
super(endpoint, attributes)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/tickethub/resource.rb
CHANGED
@@ -151,7 +151,13 @@ module Tickethub
|
|
151
151
|
end.to_h
|
152
152
|
end
|
153
153
|
|
154
|
-
def self.call(endpoint, attributes = nil)
|
154
|
+
def self.call(endpoint, attributes = nil, options = {})
|
155
|
+
if attributes.is_a? String
|
156
|
+
attributes = (options[:shallow] == false ?
|
157
|
+
endpoint[CGI::escape(attributes)] :
|
158
|
+
endpoint[self.path, CGI::escape(attributes)]).get
|
159
|
+
end
|
160
|
+
|
155
161
|
attributes ||= endpoint.get
|
156
162
|
|
157
163
|
klass = registered_types.find do |type, options|
|
@@ -159,10 +165,12 @@ module Tickethub
|
|
159
165
|
end
|
160
166
|
|
161
167
|
klass = klass ? klass[1][:klass] : self
|
168
|
+
path = options[:shallow] == false ? endpoint.uri.path + klass.path : klass.path
|
169
|
+
|
162
170
|
endpoint = if klass.singleton?
|
163
171
|
endpoint[klass.path]
|
164
172
|
elsif id = attributes['id']
|
165
|
-
endpoint[klass.path, id]
|
173
|
+
options[:shallow] == false ? endpoint[id] : endpoint[klass.path, id]
|
166
174
|
else # readonly
|
167
175
|
endpoint[klass.path].freeze
|
168
176
|
end
|
@@ -170,18 +178,18 @@ module Tickethub
|
|
170
178
|
klass.new endpoint, attributes
|
171
179
|
end
|
172
180
|
|
173
|
-
def self.association(key, klass)
|
181
|
+
def self.association(key, klass, options = {})
|
174
182
|
define_method key do
|
175
183
|
@attributes.key?(key.to_sym) ?
|
176
184
|
(attrs = @attributes[key.to_sym]) &&
|
177
|
-
klass.call(@endpoint[key], attrs) :
|
178
|
-
klass.call(@endpoint[key])
|
185
|
+
klass.call(@endpoint[key], attrs, options) :
|
186
|
+
klass.call(@endpoint[key], nil, options)
|
179
187
|
end
|
180
188
|
end
|
181
189
|
|
182
|
-
def self.collection(key, klass, &block)
|
190
|
+
def self.collection(key, klass, options = {}, &block)
|
183
191
|
define_method key do |params = {}|
|
184
|
-
Tickethub::Collection.new(@endpoint[key], klass, params).tap do |collection|
|
192
|
+
Tickethub::Collection.new(@endpoint[key], klass, params, options).tap do |collection|
|
185
193
|
collection.instance_eval &block if block
|
186
194
|
end
|
187
195
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require_relative '../resource'
|
2
|
+
|
3
|
+
module Tickethub
|
4
|
+
class Supplier::Override < Resource
|
5
|
+
path '/supplier/overrides'
|
6
|
+
|
7
|
+
attribute :price, type: :money
|
8
|
+
attribute :currency, type: :currency
|
9
|
+
|
10
|
+
attribute :notice, type: :duration
|
11
|
+
attribute :period, type: :duration
|
12
|
+
|
13
|
+
attribute :interval, type: :duration
|
14
|
+
attribute :duration, type: :duration
|
15
|
+
end
|
16
|
+
end
|
@@ -4,13 +4,13 @@ module Tickethub
|
|
4
4
|
class Supplier::Reseller < Resource
|
5
5
|
path '/supplier/resellers'
|
6
6
|
|
7
|
+
require_relative 'user'
|
7
8
|
require_relative 'invoice'
|
8
9
|
require_relative 'product'
|
9
10
|
require_relative 'message'
|
10
|
-
require_relative '
|
11
|
+
require_relative 'channel'
|
11
12
|
require_relative 'broadcast'
|
12
13
|
|
13
|
-
require_relative '../token'
|
14
14
|
require_relative '../contact'
|
15
15
|
require_relative '../address'
|
16
16
|
|
@@ -21,9 +21,9 @@ module Tickethub
|
|
21
21
|
collection :invoices, Supplier::Invoice
|
22
22
|
collection :products, Supplier::Product
|
23
23
|
collection :messages, Supplier::Message
|
24
|
-
collection :
|
24
|
+
collection :channels, Supplier::Channel
|
25
|
+
collection :users, Supplier::User, shallow: false
|
25
26
|
|
26
|
-
association :token, Tickethub::Token
|
27
27
|
association :contact, Tickethub::Contact
|
28
28
|
association :address, Tickethub::Address
|
29
29
|
|
data/lib/tickethub/user/app.rb
CHANGED
data/lib/tickethub/user.rb
CHANGED
@@ -3,9 +3,11 @@ module Tickethub
|
|
3
3
|
path '/user', singleton: true
|
4
4
|
|
5
5
|
require_relative 'user/app'
|
6
|
+
require_relative 'user/reseller'
|
6
7
|
require_relative 'user/supplier'
|
7
8
|
|
8
9
|
collection :apps, User::App
|
10
|
+
collection :resellers, User::Reseller
|
9
11
|
collection :suppliers, User::Supplier
|
10
12
|
|
11
13
|
association :token, Tickethub::Token
|
@@ -17,6 +19,17 @@ module Tickethub
|
|
17
19
|
new nil, Tickethub::Response.new(err.response).decoded
|
18
20
|
end
|
19
21
|
|
22
|
+
def self.reset(email)
|
23
|
+
Tickethub.endpoint['/user/reset'].post email: email
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.verify(attributes)
|
27
|
+
response = Tickethub.endpoint['/user/verify'].post(attributes)
|
28
|
+
self[email: response.decoded['email'], password: attributes['password']]
|
29
|
+
rescue Tickethub::ResourceInvalid => err
|
30
|
+
new nil, Tickethub::Response.new(err.response).decoded
|
31
|
+
end
|
32
|
+
|
20
33
|
def self.[](attributes)
|
21
34
|
token = if attributes[:email]
|
22
35
|
Tickethub.endpoint['/user/token'].post(grant_type: 'password',
|
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.31
|
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-07-
|
11
|
+
date: 2015-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -105,6 +105,9 @@ files:
|
|
105
105
|
- lib/tickethub/formats/json_format.rb
|
106
106
|
- lib/tickethub/helpers.rb
|
107
107
|
- lib/tickethub/request.rb
|
108
|
+
- lib/tickethub/reseller.rb
|
109
|
+
- lib/tickethub/reseller/channel.rb
|
110
|
+
- lib/tickethub/reseller/product.rb
|
108
111
|
- lib/tickethub/resource.rb
|
109
112
|
- lib/tickethub/response.rb
|
110
113
|
- lib/tickethub/response/headers.rb
|
@@ -132,6 +135,7 @@ files:
|
|
132
135
|
- lib/tickethub/supplier/message/sms.rb
|
133
136
|
- lib/tickethub/supplier/option.rb
|
134
137
|
- lib/tickethub/supplier/order.rb
|
138
|
+
- lib/tickethub/supplier/override.rb
|
135
139
|
- lib/tickethub/supplier/payment.rb
|
136
140
|
- lib/tickethub/supplier/payment/cash.rb
|
137
141
|
- lib/tickethub/supplier/payment/complimentary.rb
|
@@ -163,6 +167,7 @@ files:
|
|
163
167
|
- lib/tickethub/token.rb
|
164
168
|
- lib/tickethub/user.rb
|
165
169
|
- lib/tickethub/user/app.rb
|
170
|
+
- lib/tickethub/user/reseller.rb
|
166
171
|
- lib/tickethub/user/supplier.rb
|
167
172
|
- lib/tickethub/version.rb
|
168
173
|
- tickethub.gemspec
|