Class: Centaman::Service::Extra

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

Constant Summary

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, #build_objects, #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.



4
5
6
# File 'lib/centaman/service/extra.rb', line 4

def booking_time_id
  @booking_time_id
end

#cost_rate_idObject (readonly)

Returns the value of attribute cost_rate_id.



4
5
6
# File 'lib/centaman/service/extra.rb', line 4

def cost_rate_id
  @cost_rate_id
end

Instance Method Details

#additional_hash_to_serialize_after_responseObject



27
28
29
30
31
# File 'lib/centaman/service/extra.rb', line 27

def additional_hash_to_serialize_after_response
  {
    booking_time_id: booking_time_id
  }
end

#after_init(args) ⇒ Object



6
7
8
9
10
# File 'lib/centaman/service/extra.rb', line 6

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

#endpointObject



12
13
14
# File 'lib/centaman/service/extra.rb', line 12

def endpoint
  '/ticket_services/TimedTicketExtra'
end

#object_classObject



16
17
18
# File 'lib/centaman/service/extra.rb', line 16

def object_class
  Centaman::Object::Extra
end

#objectsObject



47
48
49
# File 'lib/centaman/service/extra.rb', line 47

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

#optionsObject



20
21
22
23
24
25
# File 'lib/centaman/service/extra.rb', line 20

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

#require_argsObject



33
34
35
# File 'lib/centaman/service/extra.rb', line 33

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

#sample_responseObject



37
38
39
40
41
42
43
44
45
# File 'lib/centaman/service/extra.rb', line 37

def sample_response
  [{
    'ExtraId' => 581,
    'ExtraDescription' => 'Bar Package Cocktail Cruises',
    'ExtraPrice' => 22.05,
    'DepositPercentage' => 100.0,
    'IsTaxInclusive' => true, 'TaxPercentage' => 10.25
  }]
end