centaman 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,26 @@
1
+ module Centaman
2
+ class Object::BookingType < Centaman::Object
3
+ def json
4
+ {
5
+ booking_type_id: booking_type_id,
6
+ booking_description: booking_description
7
+ }
8
+ end
9
+
10
+ # rubocop:disable Metrics/MethodLength
11
+ def attributes
12
+ [
13
+ Centaman::Attribute.new(
14
+ centaman_key: 'BookingTypeId',
15
+ app_key: :booking_type_id,
16
+ type: :integer
17
+ ),
18
+ Centaman::Attribute.new(
19
+ centaman_key: 'BookingDescription',
20
+ app_key: :booking_description,
21
+ type: :string
22
+ ),
23
+ ]
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,32 @@
1
+ module Centaman
2
+ class Object::Capacity < Centaman::Object
3
+ attr_accessor :sold_out
4
+
5
+ # rubocop:disable Metrics/MethodLength
6
+ def attributes
7
+ [
8
+ Centaman::Attribute.new(
9
+ centaman_key: 'TimedTicketTypeId',
10
+ app_key: :booking_time_id,
11
+ type: :integer
12
+ ),
13
+ Centaman::Attribute.new(
14
+ centaman_key: 'TimedTicketTypeDescription',
15
+ app_key: :booking_time_description,
16
+ type: :integer
17
+ ),
18
+ Centaman::Attribute.new(
19
+ centaman_key: 'Capacity',
20
+ app_key: :capacity,
21
+ type: :integer
22
+ ),
23
+ Centaman::Attribute.new(
24
+ centaman_key: 'vacancy',
25
+ app_key: :vacancy,
26
+ type: :integer
27
+ )
28
+ ]
29
+ end
30
+ # rubocop:enable Metrics/MethodLength
31
+ end
32
+ end
@@ -0,0 +1,37 @@
1
+ module Centaman
2
+ class Object::CouponCheck < Centaman::Object
3
+ attr_reader :effects
4
+
5
+ def after_init(args = {})
6
+ define_effects(args)
7
+ end
8
+
9
+ def define_effects(args)
10
+ @effects = args['Effects'].map do |effect_hash|
11
+ Centaman::Object::Effect.new(effect_hash)
12
+ end
13
+ end
14
+
15
+ # rubocop:disable Metrics/MethodLength
16
+ def attributes
17
+ [
18
+ Centaman::Attribute.new(
19
+ centaman_key: 'CouponCode',
20
+ app_key: :coupon_code,
21
+ type: :integer
22
+ ),
23
+ Centaman::Attribute.new(
24
+ centaman_key: 'LimitedUse',
25
+ app_key: :limited_use,
26
+ type: :boolean
27
+ ),
28
+ Centaman::Attribute.new(
29
+ centaman_key: 'UsesRemaining',
30
+ app_key: :uses_remaining,
31
+ type: :integer
32
+ )
33
+ ]
34
+ end
35
+ # rubocop:enable Metrics/MethodLength
36
+ end
37
+ end
@@ -0,0 +1,40 @@
1
+ module Centaman
2
+ class Object::Customer < Centaman::Object
3
+ attr_reader :phone
4
+ # rubocop:disable Metrics/MethodLength
5
+ def after_init(args)
6
+ @phone = args["Address"]["HomePhone"]
7
+ end
8
+
9
+ def attributes
10
+ [
11
+ Centaman::Attribute.new(
12
+ centaman_key: 'MemberCode',
13
+ app_key: :member_code,
14
+ type: :integer
15
+ ),
16
+ Centaman::Attribute.new(
17
+ centaman_key: 'MemberNumber',
18
+ app_key: :member_number,
19
+ type: :integer
20
+ ),
21
+ Centaman::Attribute.new(
22
+ centaman_key: 'FirstName',
23
+ app_key: :first_name,
24
+ type: :string
25
+ ),
26
+ Centaman::Attribute.new(
27
+ centaman_key: 'LastName',
28
+ app_key: :last_name,
29
+ type: :string
30
+ ),
31
+ Centaman::Attribute.new(
32
+ centaman_key: 'Email',
33
+ app_key: :email,
34
+ type: :string
35
+ ),
36
+ ]
37
+ end
38
+ # rubocop:enable Metrics/MethodLength
39
+ end
40
+ end
@@ -0,0 +1,55 @@
1
+ module Centaman
2
+ class Object::Effect < Centaman::Object
3
+ # rubocop:disable Metrics/MethodLength
4
+ def attributes
5
+ [
6
+ Centaman::Attribute.new(
7
+ centaman_key: 'Valid',
8
+ app_key: :valid,
9
+ type: :boolean
10
+ ),
11
+ Centaman::Attribute.new(
12
+ centaman_key: 'ProductType',
13
+ app_key: :product_type,
14
+ type: :string
15
+ ),
16
+ Centaman::Attribute.new(
17
+ centaman_key: 'ProductCode',
18
+ app_key: :product_code,
19
+ type: :integer
20
+ ),
21
+ Centaman::Attribute.new(
22
+ centaman_key: 'EffectType',
23
+ app_key: :effect_type,
24
+ type: :string
25
+ ),
26
+ Centaman::Attribute.new(
27
+ centaman_key: 'Amount',
28
+ app_key: :amount,
29
+ type: :float
30
+ ),
31
+ Centaman::Attribute.new(
32
+ centaman_key: 'ReasonInvalid',
33
+ app_key: :reason_invalid,
34
+ type: :string
35
+ ),
36
+ Centaman::Attribute.new(
37
+ centaman_key: 'ValidFrom',
38
+ app_key: :valid_from,
39
+ type: :datetime
40
+ ),
41
+ Centaman::Attribute.new(
42
+ centaman_key: 'ValidUntil',
43
+ app_key: :valid_until,
44
+ type: :datetime
45
+ ),
46
+ Centaman::Attribute.new(
47
+ centaman_key: 'WaiveTicketFee',
48
+ app_key: :waive_ticket_fee,
49
+ type: :boolean
50
+ )
51
+ ]
52
+ end
53
+ # rubocop:enable Metrics/MethodLength
54
+ end
55
+ end
@@ -0,0 +1,72 @@
1
+ module Centaman
2
+ class Object::Extra < Centaman::Object
3
+ attr_accessor :quantity
4
+
5
+ def after_init(_args = {})
6
+ @quantity = 0
7
+ end
8
+
9
+ def price
10
+ @price ||= tax_inclusive ? calculate_price_before_tax : price_including_tax
11
+ end
12
+
13
+ def calculate_price_before_tax
14
+ p = price_including_tax / (1 + tax_percentage / 100)
15
+ p.round(2)
16
+ end
17
+
18
+ def json
19
+ {
20
+ id: id,
21
+ description: description,
22
+ quantity: quantity,
23
+ price: price,
24
+ deposit_percentage: deposit_percentage,
25
+ tax_inclusive: tax_inclusive,
26
+ tax_percentage: tax_percentage
27
+ }
28
+ end
29
+
30
+ def description
31
+ @extra_description.gsub!('Bar Package Cocktail Cruises', 'Bar Package')
32
+ @description = @extra_description
33
+ end
34
+
35
+ # rubocop:disable Metrics/MethodLength
36
+ def attributes
37
+ [
38
+ Centaman::Attribute.new(
39
+ centaman_key: 'ExtraId',
40
+ app_key: :id,
41
+ type: :integer
42
+ ),
43
+ Centaman::Attribute.new(
44
+ centaman_key: 'ExtraDescription',
45
+ app_key: :extra_description,
46
+ type: :string
47
+ ),
48
+ Centaman::Attribute.new(
49
+ centaman_key: 'ExtraPrice',
50
+ app_key: :price_including_tax,
51
+ type: :float
52
+ ),
53
+ Centaman::Attribute.new(
54
+ centaman_key: 'DepositPercentage',
55
+ app_key: :deposit_percentage,
56
+ type: :float
57
+ ),
58
+ Centaman::Attribute.new(
59
+ centaman_key: 'IsTaxInclusive',
60
+ app_key: :tax_inclusive,
61
+ type: :boolean
62
+ ),
63
+ Centaman::Attribute.new(
64
+ centaman_key: 'TaxPercentage',
65
+ app_key: :tax_percentage,
66
+ type: :float
67
+ )
68
+ ]
69
+ end
70
+ # rubocop:enable Metrics/MethodLength
71
+ end
72
+ end
@@ -0,0 +1,75 @@
1
+ module Centaman
2
+ class Object::GiftTicket < Centaman::Object
3
+ # rubocop:disable Metrics/MethodLength
4
+ def attributes
5
+ [
6
+ Centaman::Attribute.new(
7
+ centaman_key: 'TicketID',
8
+ app_key: :id,
9
+ type: :integer
10
+ ),
11
+ Centaman::Attribute.new(
12
+ centaman_key: 'TicketDescription',
13
+ app_key: :description,
14
+ type: :string
15
+ ),
16
+ Centaman::Attribute.new(
17
+ centaman_key: 'DepartmentID',
18
+ app_key: :department_id,
19
+ type: :integer
20
+ ),
21
+ Centaman::Attribute.new(
22
+ centaman_key: 'DepartmentName',
23
+ app_key: :department_name,
24
+ type: :string
25
+ ),
26
+ Centaman::Attribute.new(
27
+ centaman_key: 'TicketMinimumQuantity',
28
+ app_key: :minimum_quantity,
29
+ type: :integer
30
+ ),
31
+ Centaman::Attribute.new(
32
+ centaman_key: 'TicketMaximumQuantity',
33
+ app_key: :maximum_quantity,
34
+ type: :integer
35
+ ),
36
+ Centaman::Attribute.new(
37
+ centaman_key: 'TicketValidity',
38
+ app_key: :validity,
39
+ type: :datetime
40
+ ),
41
+ Centaman::Attribute.new(
42
+ centaman_key: 'TicketNormalPrice',
43
+ app_key: :normal_price,
44
+ type: :float
45
+ ),
46
+ Centaman::Attribute.new(
47
+ centaman_key: 'TicketWebPrice',
48
+ app_key: :web_price,
49
+ type: :float
50
+ ),
51
+ Centaman::Attribute.new(
52
+ centaman_key: 'TaxInclusive',
53
+ app_key: :tax_inclusive,
54
+ type: :boolean
55
+ ),
56
+ Centaman::Attribute.new(
57
+ centaman_key: 'TaxPercentage',
58
+ app_key: :tax_percentage,
59
+ type: :float
60
+ ),
61
+ Centaman::Attribute.new(
62
+ centaman_key: 'CouponRequired',
63
+ app_key: :coupon_required,
64
+ type: :boolean
65
+ ),
66
+ Centaman::Attribute.new(
67
+ centaman_key: 'ShowTicket',
68
+ app_key: :show_ticke,
69
+ type: :boolean
70
+ ),
71
+ ]
72
+ end
73
+ # rubocop:enable Metrics/MethodLength
74
+ end
75
+ end
@@ -0,0 +1,66 @@
1
+ class Centaman::Object::PurchasedTicket < Centaman::Object
2
+ def attributes
3
+ [
4
+ Centaman::Attribute.new(
5
+ centaman_key: "ItemDescription",
6
+ app_key: :item_description,
7
+ type: :string
8
+ ),
9
+ Centaman::Attribute.new(
10
+ centaman_key: "ItemDescription",
11
+ app_key: :display_age_group,
12
+ type: :display_age_group
13
+ ),
14
+ Centaman::Attribute.new(
15
+ centaman_key: "ItemCode",
16
+ app_key: :item_code,
17
+ type: :string
18
+ ),
19
+ Centaman::Attribute.new(
20
+ centaman_key: "Quantity",
21
+ app_key: :quantity,
22
+ type: :integer
23
+ ),
24
+ Centaman::Attribute.new(
25
+ centaman_key: "ItemCost",
26
+ app_key: :item_cost,
27
+ type: :float
28
+ ),
29
+ Centaman::Attribute.new(
30
+ centaman_key: "TotalPaid",
31
+ app_key: :total_paid,
32
+ type: :float
33
+ ),
34
+ Centaman::Attribute.new(
35
+ centaman_key: "TaxPaid",
36
+ app_key: :tax_paid,
37
+ type: :float
38
+ ),
39
+ Centaman::Attribute.new(
40
+ centaman_key: "Barcode",
41
+ app_key: :barcode,
42
+ type: :string
43
+ ),
44
+ Centaman::Attribute.new(
45
+ centaman_key: "AttendeeName",
46
+ app_key: :attendee_name,
47
+ type: :string
48
+ ),
49
+ Centaman::Attribute.new(
50
+ centaman_key: "IsExtraItem",
51
+ app_key: :is_extra_item,
52
+ type: :boolean
53
+ ),
54
+ Centaman::Attribute.new(
55
+ centaman_key: "CouponCode",
56
+ app_key: :coupon_code,
57
+ type: :string
58
+ ),
59
+ Centaman::Attribute.new(
60
+ centaman_key: "CostRateId",
61
+ app_key: :cost_rate_id,
62
+ type: :string
63
+ ),
64
+ ]
65
+ end
66
+ end
@@ -0,0 +1,79 @@
1
+ module Centaman
2
+ class Object::TicketType < Centaman::Object
3
+ attr_reader :price, :discount
4
+ attr_accessor :quantity
5
+
6
+ def price
7
+ @price ||= begin
8
+ p = price_including_tax / (1 + tax_percentage / 100)
9
+ p = p + discount
10
+ p.round(2)
11
+ end
12
+ end
13
+
14
+ def discount
15
+ @discount ||= Centaman::Service::TicketType::DISCOUNT
16
+ end
17
+
18
+ def adult?
19
+ age_group == "adult"
20
+ end
21
+
22
+ # rubocop:disable Metrics/MethodLength
23
+ def attributes
24
+ [
25
+ Centaman::Attribute.new(
26
+ centaman_key: "TicketId",
27
+ app_key: :id,
28
+ type: :integer
29
+ ),
30
+ Centaman::Attribute.new(
31
+ centaman_key: "TicketDescription",
32
+ app_key: :description,
33
+ type: :string
34
+ ),
35
+ Centaman::Attribute.new(
36
+ centaman_key: "TicketPrice",
37
+ app_key: :price_including_tax,
38
+ type: :float
39
+ ),
40
+ Centaman::Attribute.new(
41
+ centaman_key: "TicketBookingFee",
42
+ app_key: :booking_fee,
43
+ type: :float
44
+ ),
45
+ Centaman::Attribute.new(
46
+ centaman_key: "TicketFeeItemId",
47
+ app_key: :fee_item_id,
48
+ type: :integer
49
+ ),
50
+ Centaman::Attribute.new(
51
+ centaman_key: "DepositPercentage",
52
+ app_key: :deposit_percentage,
53
+ type: :float
54
+ ),
55
+ Centaman::Attribute.new(
56
+ centaman_key: "IsTaxInclusive",
57
+ app_key: :is_tax_inclusive,
58
+ type: :boolean
59
+ ),
60
+ Centaman::Attribute.new(
61
+ centaman_key: "TaxPercentage",
62
+ app_key: :tax_percentage,
63
+ type: :float
64
+ ),
65
+ Centaman::Attribute.new(
66
+ centaman_key: "TicketDescription",
67
+ app_key: :age_group,
68
+ type: :age_group
69
+ ),
70
+ Centaman::Attribute.new(
71
+ centaman_key: "TicketDescription",
72
+ app_key: :display_age_group,
73
+ type: :display_age_group
74
+ ),
75
+ ]
76
+ end
77
+ # rubocop:enable Metrics/MethodLength
78
+ end
79
+ end