Class: Centaman::Service::Extra

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

Constant Summary

Constants inherited from Centaman::Service

DEFAULT_TIMEOUT_TIME

Constants inherited from Wrapper

Wrapper::FIXIE

Instance Attribute Summary collapse

Attributes inherited from Wrapper

#api_password, #api_token, #api_username

Instance Method Summary collapse

Methods included from JsonWrapper

#additional_hash_to_serialize_after_response, #build_object, #build_objects

Methods inherited from Centaman::Service

#after_post, #fetch_all, #payload, #payload_key, #post, #wrap_request_in_case_of_timeout

Methods inherited from Wrapper

#generate_token, #headers, #initialize, #options_hash

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

Instance Method Details

#after_init(args) ⇒ Object



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

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

#endpointObject



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

def endpoint
  '/ticket_services/TimedTicketExtra'
end

#object_classObject



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

def object_class
  Centaman::Object::Extra
end

#objectsObject



39
40
41
# File 'lib/centaman/service/extra.rb', line 39

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

#optionsObject



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

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

#require_argsObject



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

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

#sample_responseObject



29
30
31
32
33
34
35
36
37
# File 'lib/centaman/service/extra.rb', line 29

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