tickethub 0.0.1

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.
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,15 @@
1
+ require_relative '../resource'
2
+
3
+ module Tickethub
4
+ class Supplier::Customer < Resource
5
+ path '/supplier/customers'
6
+
7
+ require_relative 'booking'
8
+ require_relative 'ticket'
9
+ require_relative 'message'
10
+
11
+ collection :bookings, Supplier::Booking
12
+ collection :tickets, Supplier::Ticket
13
+ collection :messages, Supplier::Message
14
+ end
15
+ end
@@ -0,0 +1,11 @@
1
+ require_relative '../resource'
2
+
3
+ module Tickethub
4
+ class Supplier::Element < Resource
5
+ path '/supplier/elements'
6
+
7
+ require_relative 'template'
8
+
9
+ association :template, Supplier::Template
10
+ end
11
+ end
@@ -0,0 +1,15 @@
1
+ require_relative '../resource'
2
+
3
+ module Tickethub
4
+ class Supplier::Fee < Resource
5
+ path '/supplier/fees'
6
+
7
+ require_relative 'tax'
8
+ require_relative 'booking'
9
+
10
+ association :tax, Supplier::Tax
11
+ association :booking, Supplier::Booking
12
+
13
+ attribute :amount, type: :money
14
+ end
15
+ end
@@ -0,0 +1,8 @@
1
+ require_relative '../gateway'
2
+
3
+ module Tickethub
4
+ class Supplier::Gateway::Handpoint < Supplier::Gateway
5
+ polymorphic 'handpoint', attribute: :type
6
+ path '/supplier/gateways/handpoint'
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require_relative '../gateway'
2
+
3
+ module Tickethub
4
+ class Supplier::Gateway::Ideal < Supplier::Gateway
5
+ polymorphic 'ideal', attribute: :type
6
+ path '/supplier/gateways/ideal'
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require_relative '../gateway'
2
+
3
+ module Tickethub
4
+ class Supplier::Gateway::Paypal < Supplier::Gateway
5
+ polymorphic 'paypal', attribute: :type
6
+ path '/supplier/gateways/paypal'
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require_relative '../gateway'
2
+
3
+ module Tickethub
4
+ class Supplier::Gateway::Stripe < Supplier::Gateway
5
+ polymorphic 'stripe', attribute: :type
6
+ path '/supplier/gateways/stripe'
7
+ end
8
+ end
@@ -0,0 +1,16 @@
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
@@ -0,0 +1,7 @@
1
+ require_relative '../resource'
2
+
3
+ module Tickethub
4
+ class Supplier::Invoice < Resource
5
+ path '/supplier/invoices'
6
+ end
7
+ end
@@ -0,0 +1,8 @@
1
+ require_relative '../message'
2
+
3
+ module Tickethub
4
+ class Supplier::Message::Email < Supplier::Message
5
+ polymorphic 'email', attribute: :type
6
+ path '/supplier/messages/email'
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require_relative '../message'
2
+
3
+ module Tickethub
4
+ class Supplier::Message::SMS < Supplier::Message
5
+ polymorphic 'sms', attribute: :type
6
+ path '/supplier/messages/sms'
7
+ end
8
+ end
@@ -0,0 +1,20 @@
1
+ require_relative '../resource'
2
+
3
+ module Tickethub
4
+ class Supplier::Message < Resource
5
+ path '/supplier/messages'
6
+
7
+ require_relative 'user'
8
+ require_relative 'message/email'
9
+ require_relative 'message/sms'
10
+
11
+ association :user, Supplier::User
12
+
13
+ attribute :created_at, type: :datetime
14
+ attribute :updated_at, type: :datetime
15
+
16
+ def replies
17
+ @replies ||= Tickethub::Collection.new @endpoint[:replies].get
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,18 @@
1
+ require_relative '../resource'
2
+
3
+ module Tickethub
4
+ class Supplier::Option < Resource
5
+ path '/supplier/options'
6
+
7
+ scope :dates, -> (params) { @endpoint[:dates, params: params].get.decoded }
8
+ scope :active
9
+
10
+ require_relative 'season'
11
+
12
+ association :season, Supplier::Season
13
+
14
+ attribute :time, type: :time
15
+ attribute :total, type: :money
16
+ attribute :currency, type: :currency
17
+ end
18
+ end
@@ -0,0 +1,51 @@
1
+ require_relative '../resource'
2
+
3
+ module Tickethub
4
+ class Supplier::Order < Resource
5
+ path '/supplier/orders'
6
+
7
+ require_relative 'customer'
8
+ require_relative 'booking'
9
+ require_relative 'payment'
10
+
11
+ require_relative 'reseller'
12
+ require_relative 'customer'
13
+
14
+ require_relative 'app'
15
+ require_relative 'user'
16
+ require_relative 'answer'
17
+ require_relative 'message'
18
+
19
+ require_relative '../address'
20
+
21
+ collection :bookings, Supplier::Booking
22
+ collection :payments, Supplier::Payment
23
+ collection :messages, Supplier::Message
24
+ collection :answers, Supplier::Answer
25
+
26
+ association :reseller, Supplier::Reseller
27
+ association :customer, Supplier::Customer
28
+
29
+ association :app, Supplier::App
30
+ association :user, Supplier::User
31
+
32
+ association :address, Tickethub::Address
33
+
34
+ attribute :total, type: :money
35
+ attribute :balance, type: :money
36
+ attribute :currency, type: :currency
37
+
38
+ attribute :expires_at, type: :datetime
39
+ attribute :confirmed_at, type: :datetime
40
+ attribute :created_at, type: :datetime
41
+ attribute :updated_at, type: :datetime
42
+
43
+ def restore
44
+ self.load @endpoint[:restore].post
45
+ end
46
+
47
+ def confirm
48
+ self.load @endpoint[:confirm].post
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,9 @@
1
+ module Tickethub
2
+ class Supplier::Package < Resource
3
+ path '/packages'
4
+
5
+ require_relative 'app'
6
+
7
+ association :app, Supplier::App
8
+ end
9
+ end
@@ -0,0 +1,18 @@
1
+ require_relative '../payment'
2
+
3
+ module Tickethub
4
+ class Supplier::Payment::Card < Supplier::Payment
5
+ polymorphic 'card', attribute: :type
6
+ path '/supplier/payments/card'
7
+
8
+ require_relative '../card'
9
+ require_relative '../gateway'
10
+
11
+ require_relative '../../address'
12
+
13
+ association :card, Supplier::Card
14
+ association :gateway, Supplier::Gateway
15
+
16
+ association :address, Tickethub::Address
17
+ end
18
+ end
@@ -0,0 +1,8 @@
1
+ require_relative '../payment'
2
+
3
+ module Tickethub
4
+ class Supplier::Payment::Cash < Supplier::Payment
5
+ polymorphic 'cash', attribute: :type
6
+ path '/supplier/payments/cash'
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require_relative '../payment'
2
+
3
+ module Tickethub
4
+ class Supplier::Payment::Credit < Supplier::Payment
5
+ polymorphic 'credit', attribute: :type
6
+ path '/supplier/payments/credit'
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require_relative '../payment'
2
+
3
+ module Tickethub
4
+ class Supplier::Payment::Direct < Supplier::Payment
5
+ polymorphic 'direct', attribute: :type
6
+ path '/supplier/payments/direct'
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require_relative '../payment'
2
+
3
+ module Tickethub
4
+ class Supplier::Payment::Gratuity < Supplier::Payment
5
+ polymorphic 'gratuity', attribute: :type
6
+ path '/supplier/payments/gratuity'
7
+ end
8
+ end
@@ -0,0 +1,34 @@
1
+ require_relative '../resource'
2
+
3
+ module Tickethub
4
+ class Supplier::Payment < Resource
5
+ path '/supplier/payments'
6
+
7
+ require_relative 'payment/card'
8
+ require_relative 'payment/cash'
9
+ require_relative 'payment/credit'
10
+ require_relative 'payment/direct'
11
+ require_relative 'payment/gratuity'
12
+
13
+ require_relative 'order'
14
+ require_relative 'user'
15
+
16
+ association :order, Supplier::Order
17
+ association :user, Supplier::User
18
+
19
+ attribute :amount, type: :money
20
+ attribute :refunded, type: :money
21
+ attribute :currency, type: :currency
22
+ attribute :refunded_at, type: :datetime
23
+ attribute :created_at, type: :datetime
24
+ attribute :updated_at, type: :datetime
25
+
26
+ def refund(attributes)
27
+ self.load @endpoint[:refund].post(attributes).decoded
28
+ return true
29
+ rescue Tickethub::ResourceInvalid => err
30
+ self.load Tickethub::Response.new(err.response).decoded
31
+ return false
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,54 @@
1
+ require 'date'
2
+ require_relative '../resource'
3
+ require_relative '../collection'
4
+
5
+ module Tickethub
6
+ class Supplier::Product < Resource
7
+ path '/supplier/products'
8
+
9
+ require_relative '../contact'
10
+ require_relative '../address'
11
+
12
+ require_relative 'booking'
13
+ require_relative 'voucher'
14
+ require_relative 'ticket'
15
+ require_relative 'option'
16
+ require_relative 'tier'
17
+ require_relative 'variant'
18
+ require_relative 'season'
19
+ require_relative 'rate'
20
+ require_relative 'coupon'
21
+ require_relative 'reseller'
22
+ require_relative 'question'
23
+ require_relative 'answer'
24
+ require_relative 'tax'
25
+
26
+ collection :bookings, Supplier::Booking
27
+ collection :vouchers, Supplier::Voucher
28
+ collection :tickets, Supplier::Ticket
29
+ collection :tiers, Supplier::Tier
30
+ collection :variants, Supplier::Variant
31
+ collection :seasons, Supplier::Season
32
+ collection :coupons, Supplier::Coupon
33
+ collection :rates, Supplier::Rate
34
+ collection :questions, Supplier::Question
35
+ collection :answers, Supplier::Answer
36
+ collection :taxes, Supplier::Tax
37
+
38
+ collection :options, Supplier::Option do
39
+ def dates(from, to, booking = {})
40
+ @endpoint[:dates].get(from: from, to: to, booking: booking).decoded
41
+ end
42
+ end
43
+
44
+ association :contact, Tickethub::Contact
45
+ association :address, Tickethub::Address
46
+
47
+ attribute :time_zone, type: :timezone
48
+ attribute :currency, type: :currency
49
+
50
+ def resellers
51
+ Collection.new @endpoint['/supplier/resellers'], Supplier::Reseller, filters: { products: [id] }
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,11 @@
1
+ require_relative '../resource'
2
+
3
+ module Tickethub
4
+ class Supplier::Question < Resource
5
+ path '/supplier/questions'
6
+
7
+ require_relative 'answer'
8
+
9
+ collection :answers, Supplier::Answer
10
+ end
11
+ end
@@ -0,0 +1,16 @@
1
+ require_relative '../resource'
2
+
3
+ module Tickethub
4
+ class Supplier::Rate < Resource
5
+ path '/supplier/rates'
6
+
7
+ require_relative 'product'
8
+ require_relative 'reseller'
9
+ require_relative 'voucher'
10
+
11
+ collection :resellers, Supplier::Reseller
12
+ collection :vouchers, Supplier::Voucher
13
+
14
+ association :product, Supplier::Product
15
+ end
16
+ end
@@ -0,0 +1,11 @@
1
+ require_relative '../resource'
2
+
3
+ module Tickethub
4
+ class Supplier::Receipt < Resource
5
+ path '/supplier/receipts'
6
+
7
+ require_relative 'bill'
8
+
9
+ association :bill, Supplier::Bill
10
+ end
11
+ end
@@ -0,0 +1,36 @@
1
+ require_relative '../resource'
2
+
3
+ module Tickethub
4
+ class Supplier::Reseller < Resource
5
+ path '/supplier/resellers'
6
+
7
+ require_relative 'invoice'
8
+ require_relative 'voucher'
9
+ require_relative 'product'
10
+ require_relative 'message'
11
+ require_relative 'rate'
12
+
13
+ require_relative '../contact'
14
+ require_relative '../address'
15
+
16
+ collection :invoices, Supplier::Invoice
17
+ collection :vouchers, Supplier::Voucher
18
+ collection :products, Supplier::Product
19
+ collection :messages, Supplier::Message
20
+ collection :rates, Supplier::Rate
21
+
22
+ association :contact, Tickethub::Contact
23
+ association :address, Tickethub::Address
24
+
25
+ attribute :period, type: :duration
26
+ attribute :notice, type: :duration
27
+ attribute :currency, type: :currency
28
+
29
+ attribute :limit, type: :money
30
+ attribute :balance, type: :money
31
+ attribute :overdue, type: :money
32
+
33
+ attribute :next_invoice_date, type: :date
34
+ attribute :first_invoice_date, type: :date
35
+ end
36
+ end
@@ -0,0 +1,17 @@
1
+ require_relative '../resource'
2
+
3
+ module Tickethub
4
+ class Supplier::Scan < Resource
5
+ path '/supplier/scans'
6
+
7
+ require_relative 'scan'
8
+ require_relative 'user'
9
+
10
+ association :scan, Supplier::Scan
11
+ association :user, Supplier::User
12
+
13
+ attribute :at, type: :datetime
14
+ attribute :updated_at, type: :datetime
15
+ attribute :created_at, type: :datetime
16
+ end
17
+ end
@@ -0,0 +1,16 @@
1
+ require_relative '../resource'
2
+
3
+ module Tickethub
4
+ class Supplier::Season < Resource
5
+ path '/supplier/seasons'
6
+
7
+ require_relative 'option'
8
+ require_relative 'product'
9
+
10
+ collection :options, Supplier::Option
11
+ association :product, Supplier::Product
12
+
13
+ attribute :starts_on, type: :date
14
+ attribute :ends_on, type: :date
15
+ end
16
+ end
@@ -0,0 +1,11 @@
1
+ require_relative '../resource'
2
+
3
+ module Tickethub
4
+ class Supplier::Subscription < Resource
5
+ path '/supplier/subscriptions'
6
+
7
+ require_relative 'package'
8
+
9
+ association :package, Supplier::Package
10
+ end
11
+ end
@@ -0,0 +1,16 @@
1
+ require_relative '../resource'
2
+
3
+ module Tickethub
4
+ class Supplier::Tax < Resource
5
+ path '/supplier/taxes'
6
+
7
+ require_relative 'fee'
8
+ require_relative 'product'
9
+
10
+ association :product, Supplier::Product
11
+ collection :fees, Supplier::Fee
12
+
13
+ attribute :updated_at, type: :datetime
14
+ attribute :created_at, type: :datetime
15
+ end
16
+ end
@@ -0,0 +1,11 @@
1
+ require_relative '../resource'
2
+
3
+ module Tickethub
4
+ class Supplier::Template < Resource
5
+ path '/supplier/templates'
6
+
7
+ require_relative 'element'
8
+
9
+ collection :elements, Supplier::Element
10
+ end
11
+ end
@@ -0,0 +1,25 @@
1
+ require 'date'
2
+ require_relative '../resource'
3
+
4
+ module Tickethub
5
+ class Supplier::Ticket < Resource
6
+ path '/supplier/tickets'
7
+
8
+ require_relative 'booking'
9
+ require_relative 'tier'
10
+ require_relative 'voucher'
11
+ require_relative 'scan'
12
+
13
+ association :booking, Supplier::Booking
14
+ association :tier, Supplier::Tier
15
+ association :voucher, Supplier::Voucher
16
+
17
+ collection :scans, Supplier::Scan
18
+
19
+ attribute :price, type: :money
20
+ attribute :interval, type: :duration
21
+ attribute :expires_at, type: :datetime
22
+ attribute :updated_at, type: :datetime
23
+ attribute :created_at, type: :datetime
24
+ end
25
+ end
@@ -0,0 +1,20 @@
1
+ require_relative '../resource'
2
+
3
+ module Tickethub
4
+ class Supplier::Tier < Resource
5
+ path '/supplier/tiers'
6
+
7
+ require_relative 'product'
8
+
9
+ association :product, Supplier::Product
10
+
11
+ attribute :price, type: :money
12
+ attribute :currency, type: :currency
13
+
14
+ attribute :notice, type: :duration
15
+ attribute :period, type: :duration
16
+
17
+ attribute :interval, type: :duration
18
+ attribute :duration, type: :duration
19
+ end
20
+ end
@@ -0,0 +1,9 @@
1
+ module Tickethub
2
+ class Supplier::User < Resource
3
+ path '/supplier/users'
4
+
5
+ def full_name
6
+ [first_name, last_name].reject(&:nil?).join ' '
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ require_relative '../resource'
2
+
3
+ module Tickethub
4
+ class Supplier::Variant < Resource
5
+ path '/supplier/variants'
6
+
7
+ require_relative 'product'
8
+ association :product, Supplier::Product
9
+ end
10
+ end
@@ -0,0 +1,23 @@
1
+ require_relative '../resource'
2
+
3
+ module Tickethub
4
+ class Supplier::Voucher < Resource
5
+ path '/supplier/vouchers'
6
+
7
+ require_relative 'reseller'
8
+ require_relative 'ticket'
9
+ require_relative 'tier'
10
+ require_relative 'rate'
11
+
12
+ association :reseller, Supplier::Reseller
13
+ association :ticket, Supplier::Ticket
14
+ association :tier, Supplier::Tier
15
+ association :rate, Supplier::Rate
16
+
17
+ attribute :valid_from, type: :date
18
+ attribute :expires_on, type: :date
19
+
20
+ attribute :created_at, type: :datetime
21
+ attribute :updated_at, type: :datetime
22
+ end
23
+ end