Sha256: 64161801db7868c502fd8c2d87c7dce1e6b65064177f863d902ab86147aa7e16

Contents?: true

Size: 1.15 KB

Versions: 19

Compression:

Stored size: 1.15 KB

Contents

module Centaman
  class Service::Extra < Centaman::Service
    include Centaman::JsonWrapper
    attr_reader :booking_time_id, :cost_rate_id

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

    def endpoint
      '/ticket_services/TimedTicketExtra'
    end

    def object_class
      Centaman::Object::Extra
    end

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

    def additional_hash_to_serialize_after_response
      {
        booking_time_id: booking_time_id
      }
    end

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

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

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

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
centaman-8.0.0 lib/centaman/service/extra.rb
centaman-7.0.5 lib/centaman/service/extra.rb
centaman-7.0.4 lib/centaman/service/extra.rb
centaman-7.0.3 lib/centaman/service/extra.rb
centaman-7.0.2 lib/centaman/service/extra.rb
centaman-7.0.1 lib/centaman/service/extra.rb
centaman-7.0.0 lib/centaman/service/extra.rb
centaman-6.0.8 lib/centaman/service/extra.rb
centaman-6.0.7 lib/centaman/service/extra.rb
centaman-6.0.5 lib/centaman/service/extra.rb
centaman-6.0.4 lib/centaman/service/extra.rb
centaman-6.0.3 lib/centaman/service/extra.rb
centaman-6.0.2 lib/centaman/service/extra.rb
centaman-6.0.1 lib/centaman/service/extra.rb
centaman-6.0.0 lib/centaman/service/extra.rb
centaman-5.0.8 lib/centaman/service/extra.rb
centaman-5.0.7 lib/centaman/service/extra.rb
centaman-5.0.6 lib/centaman/service/extra.rb
centaman-5.0.5 lib/centaman/service/extra.rb