Class: Centaman::Service::Capacity

Inherits:
Centaman::Service show all
Includes:
JsonWrapper
Defined in:
lib/centaman/service/capacity.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/capacity.rb', line 4

def booking_time_id
  @booking_time_id
end

#start_dateObject (readonly)

Returns the value of attribute start_date.



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

def start_date
  @start_date
end

Instance Method Details

#after_init(args) ⇒ Object



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

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

#endpointObject



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

def endpoint
  '/ticket_services/TimedTicketType'
end

#object_classObject



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

def object_class
  Centaman::Object::Capacity
end

#objectsObject



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

def objects
  capacities = super
  capacities.each do |capacity|
    capacity.sold_out = capacity.vacancy <= 0
  end
  capacities
end

#optionsObject



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

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

#require_argsObject



35
36
37
38
# File 'lib/centaman/service/capacity.rb', line 35

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