Class: Centaman::Service::TicketType

Inherits:
Centaman::Service show all
Includes:
JsonWrapper
Defined in:
lib/centaman/service/ticket_type.rb

Constant Summary collapse

DISCOUNT =
0.0

Constants inherited from Wrapper

Wrapper::DEFAULT_TIMEOUT_TIME

Instance Attribute Summary collapse

Attributes inherited from Wrapper

#api_password, #api_token, #api_url, #api_username, #proxie_host, #proxie_password, #proxie_port, #proxie_user

Instance Method Summary collapse

Methods included from JsonWrapper

#build_object, #final_object_class

Methods inherited from Centaman::Service

#after_post, #fetch_all, #post, #put

Methods inherited from Wrapper

#generate_token, #headers, #initialize, #options_hash, #payload, #payload_key, #proxy_hash, #wrap_request_in_case_of_timeout

Constructor Details

This class inherits a constructor from Centaman::Wrapper

Instance Attribute Details

#booking_time_idObject (readonly)

Returns the value of attribute booking_time_id.



6
7
8
# File 'lib/centaman/service/ticket_type.rb', line 6

def booking_time_id
  @booking_time_id
end

#cost_rate_idObject (readonly)

Returns the value of attribute cost_rate_id.



6
7
8
# File 'lib/centaman/service/ticket_type.rb', line 6

def cost_rate_id
  @cost_rate_id
end

Instance Method Details

#additional_hash_to_serialize_after_responseObject



36
37
38
39
40
# File 'lib/centaman/service/ticket_type.rb', line 36

def additional_hash_to_serialize_after_response
  {
    booking_time_id: booking_time_id
  }
end

#after_init(args) ⇒ Object



8
9
10
11
12
# File 'lib/centaman/service/ticket_type.rb', line 8

def after_init(args)
  @booking_time_id = args[:booking_time_id]
  @cost_rate_id = args[:cost_rate_id]
  require_args
end

#build_objects(resp) ⇒ Object



18
19
20
21
22
23
# File 'lib/centaman/service/ticket_type.rb', line 18

def build_objects(resp)
  ticket_types = super(resp)
  # need to trigger the price method to have it returned in json
  ticket_types.each(&:price)
  ticket_types
end

#endpointObject



14
15
16
# File 'lib/centaman/service/ticket_type.rb', line 14

def endpoint
  '/ticket_services/TimedTicket'
end

#object_classObject



25
26
27
# File 'lib/centaman/service/ticket_type.rb', line 25

def object_class
  Centaman::Object::TicketType
end

#objectsObject



42
43
44
# File 'lib/centaman/service/ticket_type.rb', line 42

def objects
  Rails.env.test? ? build_objects(sample_response) : super
end

#optionsObject



29
30
31
32
33
34
# File 'lib/centaman/service/ticket_type.rb', line 29

def options
  super + [
    { key: 'TimedTicketTypeId', value: booking_time_id },
    { key: 'CostRateId', value: cost_rate_id }
  ]
end

#require_argsObject

rubocop:enable Metrics/MethodLength



101
102
103
# File 'lib/centaman/service/ticket_type.rb', line 101

def require_args
  raise "booking_time_id is required for #{self.class.name}" if booking_time_id.nil?
end

#sample_responseObject

rubocop:disable Metrics/MethodLength



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/centaman/service/ticket_type.rb', line 47

def sample_response
  # when passing a timed_booking_time_id
  [
    {
      'TicketId'=>504,
      'TicketDescription'=>' Adult 19 64yrs online w tax 42 56 90m',
      'TicketPrice'=>42.56,
      'TicketBookingFee'=>0.0,
      'TicketFeeItemId'=>501,
      'DepositPercentage'=>100.0,
      'IsTaxInclusive'=>true,
      'TaxPercentage'=>12.0
    },
    {
      'TicketId'=>505,
      'TicketDescription'=>' Senior 65yrs online w tax 35 84 90m',
      'TicketPrice'=>35.84,
      'TicketBookingFee'=>0.0,
      'TicketFeeItemId'=>501,
      'DepositPercentage'=>100.0,
      'IsTaxInclusive'=>true,
      'TaxPercentage'=>12.0},
    {
      'TicketId'=>506,
      'TicketDescription'=>' Youth 7 18yrs online w tax 17 92 90m',
      'TicketPrice'=>17.92,
      'TicketBookingFee'=>0.0,
      'TicketFeeItemId'=>501,
      'DepositPercentage'=>100.0,
      'IsTaxInclusive'=>true,
      'TaxPercentage'=>12.0},
    {
      'TicketId'=>524,
      'TicketDescription'=>' Child 7years accompanying booking ',
      'TicketPrice'=>0.0,
      'TicketBookingFee'=>0.0,
      'TicketFeeItemId'=>501,
      'DepositPercentage'=>100.0,
      'IsTaxInclusive'=>true,
      'TaxPercentage'=>12.0},
    {
      'TicketId'=>630,
      'TicketDescription'=>'Percent Pound Two Adult Ticket Groupon Special ',
      'TicketPrice'=>85.12,
      'TicketBookingFee'=>0.0,
      'TicketFeeItemId'=>0,
      'DepositPercentage'=>100.0,
      'IsTaxInclusive'=>true,
      'TaxPercentage'=>12.0
    }
  ]
end