Sha256: 16c2946847f0155230275935b6b5a4afaf190d751e73e8f515eb8a0baced5636

Contents?: true

Size: 941 Bytes

Versions: 54

Compression:

Stored size: 941 Bytes

Contents

module Centaman
  class Service::Capacity < Centaman::Service
    include Centaman::JsonWrapper
    attr_reader :booking_time_id, :start_date

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

    def endpoint
      '/ticket_services/TimedTicketType'
    end

    def object_class
      Centaman::Object::Capacity
    end

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

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

    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
  end
end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
centaman-5.0.3 lib/centaman/service/capacity.rb
centaman-5.0.2 lib/centaman/service/capacity.rb
centaman-5.0.1 lib/centaman/service/capacity.rb
centaman-5.0.0 lib/centaman/service/capacity.rb
centaman-4.0.5 lib/centaman/service/capacity.rb
centaman-4.0.4 lib/centaman/service/capacity.rb
centaman-4.0.3 lib/centaman/service/capacity.rb
centaman-4.0.2 lib/centaman/service/capacity.rb
centaman-4.0.1 lib/centaman/service/capacity.rb
centaman-3.1.2 lib/centaman/service/capacity.rb
centaman-3.1.1 lib/centaman/service/capacity.rb
centaman-3.1.0 lib/centaman/service/capacity.rb
centaman-3.0.0 lib/centaman/service/capacity.rb
centaman-2.1.0 lib/centaman/service/capacity.rb
centaman-2.0.0 lib/centaman/service/capacity.rb
centaman-1.0.0 lib/centaman/service/capacity.rb
centaman-0.2.3 lib/centaman/service/capacity.rb
centaman-0.2.2 lib/centaman/service/capacity.rb
centaman-0.2.1 lib/centaman/service/capacity.rb
centaman-0.2.0 lib/centaman/service/capacity.rb