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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 28513ad4d64c4b5a963c448af58969545ec4c195
4
- data.tar.gz: a345587d2fdd077a6bd18c952d3557b5e28abcea
3
+ metadata.gz: 07c9fbf4c9ee640bac8a02569679bdccec914a6d
4
+ data.tar.gz: 335943a4029d019d8188f20dedbf8ee37e78f224
5
5
  SHA512:
6
- metadata.gz: 3bfbe048e2d428b494a925cc710ada39370bc9f8fb2f262c0ecb4db33bf4869c9f058ca51af6d86b428ca12cb964bc208560e0d7673622d6bd2ac7f9a49a7c36
7
- data.tar.gz: 96c808bbcc1207ba2474cb64f12dfbae3d65e7d5dedadfc71131fa2edec8c3e2eedcc4f3cdf07492cbc521868ca53cc0c1f7c852b52dbdbf1f6ebcebebe7916d
6
+ metadata.gz: aafcc034f51534c2b5cc3f6fc62610f9888b0bf1cdb3de3d7e0ec4c8292b446430cc297674fe5621baf6edb91a6eb9a3b9444f4e5c4f8738e5d20bb589771915
7
+ data.tar.gz: 55a409843cd7c4bcad3cb3d5a1434923fa8a8fc980965017584a5ec53a5eedc4926101c447dcd5f4d8113293fe67e3f992951cc1f12730fa4a181c2fd11dc8d5
@@ -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
- endpoint = self.endpoint[@klass.path, CGI::escape(search)]
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
@@ -24,8 +24,8 @@ module Tickethub
24
24
  end
25
25
  end
26
26
 
27
- def url(params = {})
28
- params.any?? "#{@url}?#{Helpers.to_param(params)}" : @url
27
+ def uri
28
+ URI.parse @url
29
29
  end
30
30
 
31
31
  def request(params, options)
@@ -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
@@ -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
@@ -59,9 +59,5 @@ module Tickethub
59
59
 
60
60
  attribute :created_at, type: :datetime
61
61
  attribute :updated_at, type: :datetime
62
-
63
- def resellers
64
- Collection.new @endpoint['/supplier/resellers'], Supplier::Reseller, filters: { products: [id] }
65
- end
66
62
  end
67
63
  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 'rate'
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 :rates, Supplier::Rate
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
 
@@ -1,3 +1,5 @@
1
+ require_relative '../app'
2
+
1
3
  module Tickethub
2
4
  class User::App < Tickethub::App
3
5
  path '/user/apps'
@@ -0,0 +1,7 @@
1
+ require_relative '../reseller'
2
+
3
+ module Tickethub
4
+ class User::Reseller < Tickethub::Reseller
5
+ path '/user/resellers'
6
+ end
7
+ end
@@ -1,3 +1,5 @@
1
+ require_relative '../supplier'
2
+
1
3
  module Tickethub
2
4
  class User::Supplier < Tickethub::Supplier
3
5
  path '/user/suppliers'
@@ -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',
@@ -1,3 +1,3 @@
1
1
  module Tickethub
2
- VERSION = '0.3.30'
2
+ VERSION = '0.3.31'
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.30
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-14 00:00:00.000000000 Z
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