tickethub 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/Gemfile +4 -0
  4. data/lib/tickethub/address.rb +5 -0
  5. data/lib/tickethub/app/package.rb +9 -0
  6. data/lib/tickethub/app/subscription.rb +11 -0
  7. data/lib/tickethub/app.rb +36 -0
  8. data/lib/tickethub/category.rb +7 -0
  9. data/lib/tickethub/collection.rb +150 -0
  10. data/lib/tickethub/connection.rb +140 -0
  11. data/lib/tickethub/contact.rb +5 -0
  12. data/lib/tickethub/endpoint.rb +36 -0
  13. data/lib/tickethub/errors.rb +34 -0
  14. data/lib/tickethub/exceptions.rb +73 -0
  15. data/lib/tickethub/formats/form_format.rb +17 -0
  16. data/lib/tickethub/formats/json_format.rb +25 -0
  17. data/lib/tickethub/formats.rb +35 -0
  18. data/lib/tickethub/helpers.rb +108 -0
  19. data/lib/tickethub/request.rb +130 -0
  20. data/lib/tickethub/resource.rb +279 -0
  21. data/lib/tickethub/response/headers.rb +31 -0
  22. data/lib/tickethub/response.rb +49 -0
  23. data/lib/tickethub/supplier/answer.rb +11 -0
  24. data/lib/tickethub/supplier/app.rb +9 -0
  25. data/lib/tickethub/supplier/bill.rb +11 -0
  26. data/lib/tickethub/supplier/booking.rb +39 -0
  27. data/lib/tickethub/supplier/card.rb +11 -0
  28. data/lib/tickethub/supplier/coupon.rb +14 -0
  29. data/lib/tickethub/supplier/customer.rb +15 -0
  30. data/lib/tickethub/supplier/element.rb +11 -0
  31. data/lib/tickethub/supplier/fee.rb +15 -0
  32. data/lib/tickethub/supplier/gateway/handpoint.rb +8 -0
  33. data/lib/tickethub/supplier/gateway/ideal.rb +8 -0
  34. data/lib/tickethub/supplier/gateway/paypal.rb +8 -0
  35. data/lib/tickethub/supplier/gateway/stripe.rb +8 -0
  36. data/lib/tickethub/supplier/gateway.rb +16 -0
  37. data/lib/tickethub/supplier/invoice.rb +7 -0
  38. data/lib/tickethub/supplier/message/email.rb +8 -0
  39. data/lib/tickethub/supplier/message/sms.rb +8 -0
  40. data/lib/tickethub/supplier/message.rb +20 -0
  41. data/lib/tickethub/supplier/option.rb +18 -0
  42. data/lib/tickethub/supplier/order.rb +51 -0
  43. data/lib/tickethub/supplier/package.rb +9 -0
  44. data/lib/tickethub/supplier/payment/card.rb +18 -0
  45. data/lib/tickethub/supplier/payment/cash.rb +8 -0
  46. data/lib/tickethub/supplier/payment/credit.rb +8 -0
  47. data/lib/tickethub/supplier/payment/direct.rb +8 -0
  48. data/lib/tickethub/supplier/payment/gratuity.rb +8 -0
  49. data/lib/tickethub/supplier/payment.rb +34 -0
  50. data/lib/tickethub/supplier/product.rb +54 -0
  51. data/lib/tickethub/supplier/question.rb +11 -0
  52. data/lib/tickethub/supplier/rate.rb +16 -0
  53. data/lib/tickethub/supplier/receipt.rb +11 -0
  54. data/lib/tickethub/supplier/reseller.rb +36 -0
  55. data/lib/tickethub/supplier/scan.rb +17 -0
  56. data/lib/tickethub/supplier/season.rb +16 -0
  57. data/lib/tickethub/supplier/subscription.rb +11 -0
  58. data/lib/tickethub/supplier/tax.rb +16 -0
  59. data/lib/tickethub/supplier/template.rb +11 -0
  60. data/lib/tickethub/supplier/ticket.rb +25 -0
  61. data/lib/tickethub/supplier/tier.rb +20 -0
  62. data/lib/tickethub/supplier/user.rb +9 -0
  63. data/lib/tickethub/supplier/variant.rb +10 -0
  64. data/lib/tickethub/supplier/voucher.rb +23 -0
  65. data/lib/tickethub/supplier.rb +86 -0
  66. data/lib/tickethub/token.rb +9 -0
  67. data/lib/tickethub/user/app.rb +5 -0
  68. data/lib/tickethub/user/supplier.rb +5 -0
  69. data/lib/tickethub/user.rb +38 -0
  70. data/lib/tickethub/version.rb +3 -0
  71. data/lib/tickethub.rb +26 -0
  72. data/tickethub.gemspec +25 -0
  73. metadata +209 -0
@@ -0,0 +1,86 @@
1
+ module Tickethub
2
+ class Supplier < Resource
3
+ path '/supplier', singleton: true
4
+
5
+ require_relative 'supplier/bill'
6
+ require_relative 'supplier/gateway'
7
+ require_relative 'supplier/customer'
8
+ require_relative 'supplier/template'
9
+ require_relative 'supplier/order'
10
+ require_relative 'supplier/booking'
11
+ require_relative 'supplier/reseller'
12
+ require_relative 'supplier/ticket'
13
+ require_relative 'supplier/product'
14
+ require_relative 'supplier/subscription'
15
+ require_relative 'supplier/season'
16
+ require_relative 'supplier/option'
17
+ require_relative 'supplier/variant'
18
+ require_relative 'supplier/tier'
19
+ require_relative 'supplier/voucher'
20
+ require_relative 'supplier/rate'
21
+ require_relative 'supplier/invoice'
22
+ require_relative 'supplier/payment'
23
+ require_relative 'supplier/user'
24
+ require_relative 'supplier/question'
25
+ require_relative 'supplier/answer'
26
+ require_relative 'supplier/tax'
27
+ require_relative 'supplier/fee'
28
+ require_relative 'supplier/message'
29
+
30
+ require_relative 'contact'
31
+ require_relative 'token'
32
+
33
+ collection :bills, Bill
34
+ collection :gateways, Gateway
35
+ collection :customers, Customer
36
+ collection :templates, Template
37
+ collection :orders, Order
38
+ collection :bookings, Booking
39
+ collection :resellers, Reseller
40
+ collection :tickets, Ticket
41
+ collection :products, Product
42
+ collection :subscriptions, Subscription
43
+ collection :seasons, Season
44
+ collection :options, Option
45
+ collection :variants, Variant
46
+ collection :tiers, Tier
47
+ collection :vouchers, Voucher
48
+ collection :rates, Rate
49
+ collection :invoices, Invoice
50
+ collection :coupons, Coupon
51
+ collection :payments, Payment
52
+ collection :users, User
53
+ collection :questions, Question
54
+ collection :answers, Answer
55
+ collection :taxes, Tax
56
+ collection :fees, Fee
57
+ collection :messages, Message
58
+
59
+ association :contact, Tickethub::Contact
60
+ association :token, Tickethub::Token
61
+
62
+ attribute :country, type: :country
63
+ attribute :currency, type: :currency
64
+
65
+ def self.[](attributes)
66
+ token = attributes[:token].is_a?(String) ? attributes[:token]
67
+ : attributes[:token][:access_token]
68
+ self.new Tickethub.endpoint['/supplier', auth_type: :bearer, password: token]
69
+ end
70
+
71
+ def initialize(endpoint, attributes = nil)
72
+ attributes ||= endpoint.get
73
+
74
+ if attributes['token']
75
+ endpoint = Tickethub.endpoint['/supplier', {
76
+ auth_type: :bearer, password: attributes['token']['access_token'] }]
77
+ end
78
+
79
+ super(endpoint, attributes)
80
+ end
81
+
82
+ def settings
83
+ @endpoint[:settings].get
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,9 @@
1
+ module Tickethub
2
+ class Token < Resource
3
+ path '/token', singleton: true
4
+
5
+ def can?(scope)
6
+ self.scope.member? scope.to_s
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ module Tickethub
2
+ class User::App < Tickethub::App
3
+ path '/user/apps'
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Tickethub
2
+ class User::Supplier < Tickethub::Supplier
3
+ path '/user/suppliers'
4
+ end
5
+ end
@@ -0,0 +1,38 @@
1
+ module Tickethub
2
+ class User < Resource
3
+ path '/user', singleton: true
4
+
5
+ require_relative 'user/app'
6
+ require_relative 'user/supplier'
7
+
8
+ collection :apps, User::App
9
+ collection :suppliers, User::Supplier
10
+
11
+ association :token, Tickethub::Token
12
+
13
+ def self.create(attributes)
14
+ response = Tickethub.endpoint['/user'].post(attributes)
15
+ self[attributes.slice 'email', 'password']
16
+ rescue Tickethub::ResourceInvalid => err
17
+ new nil, Tickethub::Response.new(err.response).decoded
18
+ end
19
+
20
+ def self.[](attributes)
21
+ token = if attributes[:email]
22
+ Tickethub.endpoint['/user/token'].post(grant_type: 'password',
23
+ username: attributes[:email], password: attributes[:password])
24
+ .decoded['access_token']
25
+ else
26
+ attributes[:token].is_a?(String) ? attributes[:token]
27
+ : attributes[:token][:access_token]
28
+ end
29
+
30
+ endpoint = Tickethub.endpoint['/user', auth_type: :bearer, password: token]
31
+ self.new endpoint
32
+ end
33
+
34
+ def full_name
35
+ [first_name, last_name].reject(&:nil?).join ' '
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,3 @@
1
+ module Tickethub
2
+ VERSION = '0.0.1'
3
+ end
data/lib/tickethub.rb ADDED
@@ -0,0 +1,26 @@
1
+ module Tickethub
2
+
3
+ def self.endpoint
4
+ Endpoint.new 'https://api.tickethub.io/',
5
+ format: :json, headers: { 'Accept-Version' => 'v1', 'Accept' => 'application/json' }
6
+ end
7
+
8
+ require_relative 'tickethub/helpers'
9
+
10
+ require_relative 'tickethub/connection'
11
+ require_relative 'tickethub/request'
12
+ require_relative 'tickethub/response'
13
+ require_relative 'tickethub/formats'
14
+ require_relative 'tickethub/exceptions'
15
+ require_relative 'tickethub/endpoint'
16
+
17
+ require_relative 'tickethub/resource'
18
+ require_relative 'tickethub/collection'
19
+ require_relative 'tickethub/errors'
20
+
21
+ require_relative 'tickethub/token'
22
+ require_relative 'tickethub/supplier'
23
+ require_relative 'tickethub/app'
24
+ require_relative 'tickethub/user'
25
+ require_relative 'tickethub/category'
26
+ end
data/tickethub.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'tickethub/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "tickethub"
7
+ spec.version = Tickethub::VERSION
8
+ spec.authors = ["Oliver Morgan"]
9
+ spec.email = ["olly@tickethub.io"]
10
+ spec.description = %q{API client for tickethub.io}
11
+ spec.summary = %q{API client for tickethub.io}
12
+ spec.homepage = "https://github.com/ollym/tickethub-ruby"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency 'bundler', '~> 1.3'
21
+ spec.add_dependency 'timezone', '~> 0.3', '>= 0.3.2'
22
+ spec.add_dependency 'money', '~> 6.1', '>= 6.1.1'
23
+ spec.add_dependency 'countries', '~> 0.9', '>= 0.9.3'
24
+ spec.add_dependency 'iso8601-basic', '~> 0.1', '>= 0.1.0'
25
+ end
metadata ADDED
@@ -0,0 +1,209 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tickethub
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Oliver Morgan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: timezone
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.3'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 0.3.2
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '0.3'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 0.3.2
47
+ - !ruby/object:Gem::Dependency
48
+ name: money
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '6.1'
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 6.1.1
57
+ type: :runtime
58
+ prerelease: false
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '6.1'
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 6.1.1
67
+ - !ruby/object:Gem::Dependency
68
+ name: countries
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: '0.9'
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: 0.9.3
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '0.9'
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: 0.9.3
87
+ - !ruby/object:Gem::Dependency
88
+ name: iso8601-basic
89
+ requirement: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - "~>"
92
+ - !ruby/object:Gem::Version
93
+ version: '0.1'
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 0.1.0
97
+ type: :runtime
98
+ prerelease: false
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.1'
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: 0.1.0
107
+ description: API client for tickethub.io
108
+ email:
109
+ - olly@tickethub.io
110
+ executables: []
111
+ extensions: []
112
+ extra_rdoc_files: []
113
+ files:
114
+ - ".gitignore"
115
+ - Gemfile
116
+ - lib/tickethub.rb
117
+ - lib/tickethub/address.rb
118
+ - lib/tickethub/app.rb
119
+ - lib/tickethub/app/package.rb
120
+ - lib/tickethub/app/subscription.rb
121
+ - lib/tickethub/category.rb
122
+ - lib/tickethub/collection.rb
123
+ - lib/tickethub/connection.rb
124
+ - lib/tickethub/contact.rb
125
+ - lib/tickethub/endpoint.rb
126
+ - lib/tickethub/errors.rb
127
+ - lib/tickethub/exceptions.rb
128
+ - lib/tickethub/formats.rb
129
+ - lib/tickethub/formats/form_format.rb
130
+ - lib/tickethub/formats/json_format.rb
131
+ - lib/tickethub/helpers.rb
132
+ - lib/tickethub/request.rb
133
+ - lib/tickethub/resource.rb
134
+ - lib/tickethub/response.rb
135
+ - lib/tickethub/response/headers.rb
136
+ - lib/tickethub/supplier.rb
137
+ - lib/tickethub/supplier/answer.rb
138
+ - lib/tickethub/supplier/app.rb
139
+ - lib/tickethub/supplier/bill.rb
140
+ - lib/tickethub/supplier/booking.rb
141
+ - lib/tickethub/supplier/card.rb
142
+ - lib/tickethub/supplier/coupon.rb
143
+ - lib/tickethub/supplier/customer.rb
144
+ - lib/tickethub/supplier/element.rb
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
+ - lib/tickethub/supplier/invoice.rb
152
+ - lib/tickethub/supplier/message.rb
153
+ - lib/tickethub/supplier/message/email.rb
154
+ - lib/tickethub/supplier/message/sms.rb
155
+ - lib/tickethub/supplier/option.rb
156
+ - lib/tickethub/supplier/order.rb
157
+ - lib/tickethub/supplier/package.rb
158
+ - lib/tickethub/supplier/payment.rb
159
+ - lib/tickethub/supplier/payment/card.rb
160
+ - lib/tickethub/supplier/payment/cash.rb
161
+ - lib/tickethub/supplier/payment/credit.rb
162
+ - lib/tickethub/supplier/payment/direct.rb
163
+ - lib/tickethub/supplier/payment/gratuity.rb
164
+ - lib/tickethub/supplier/product.rb
165
+ - lib/tickethub/supplier/question.rb
166
+ - lib/tickethub/supplier/rate.rb
167
+ - lib/tickethub/supplier/receipt.rb
168
+ - lib/tickethub/supplier/reseller.rb
169
+ - lib/tickethub/supplier/scan.rb
170
+ - lib/tickethub/supplier/season.rb
171
+ - lib/tickethub/supplier/subscription.rb
172
+ - lib/tickethub/supplier/tax.rb
173
+ - lib/tickethub/supplier/template.rb
174
+ - lib/tickethub/supplier/ticket.rb
175
+ - lib/tickethub/supplier/tier.rb
176
+ - lib/tickethub/supplier/user.rb
177
+ - lib/tickethub/supplier/variant.rb
178
+ - lib/tickethub/supplier/voucher.rb
179
+ - lib/tickethub/token.rb
180
+ - lib/tickethub/user.rb
181
+ - lib/tickethub/user/app.rb
182
+ - lib/tickethub/user/supplier.rb
183
+ - lib/tickethub/version.rb
184
+ - tickethub.gemspec
185
+ homepage: https://github.com/ollym/tickethub-ruby
186
+ licenses:
187
+ - MIT
188
+ metadata: {}
189
+ post_install_message:
190
+ rdoc_options: []
191
+ require_paths:
192
+ - lib
193
+ required_ruby_version: !ruby/object:Gem::Requirement
194
+ requirements:
195
+ - - ">="
196
+ - !ruby/object:Gem::Version
197
+ version: '0'
198
+ required_rubygems_version: !ruby/object:Gem::Requirement
199
+ requirements:
200
+ - - ">="
201
+ - !ruby/object:Gem::Version
202
+ version: '0'
203
+ requirements: []
204
+ rubyforge_project:
205
+ rubygems_version: 2.2.1
206
+ signing_key:
207
+ specification_version: 4
208
+ summary: API client for tickethub.io
209
+ test_files: []