Sha256: 489701ae0080575e6ee57fed677b34ce5fca4c2ce9107b94ed652c79423d578c

Contents?: true

Size: 1.25 KB

Versions: 28

Compression:

Stored size: 1.25 KB

Contents

module ActiveFulfillment
  class Service

    include ActiveUtils::RequiresParameters
    include ActiveUtils::PostsData

    class_attribute :logger

    def initialize(options = {})
      check_test_mode(options)

      @options = {}
      @options.update(options)
    end

    def test_mode?
      false
    end

    def test?
      @options[:test] || Base.mode == :test
    end

    def valid_credentials?
      true
    end

    # API Requirements for Implementors
    def fulfill(order_id, shipping_address, line_items, options = {})
      raise NotImplementedError.new("Subclasses must implement")
    end

    def fetch_stock_levels(options = {})
      raise NotImplementedError.new("Subclasses must implement")
    end

    def fetch_tracking_numbers(order_ids, options = {})
      response = fetch_tracking_data(order_ids, options)
      response.params.delete('tracking_companies')
      response.params.delete('tracking_urls')
      response
    end

    def fetch_tracking_data(order_ids, options = {})
      raise NotImplementedError.new("Subclasses must implement")
    end

    private

    def check_test_mode(options)
      if options[:test] and not test_mode?
        raise ArgumentError, 'Test mode is not supported by this gateway'
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
active_fulfillment-3.2.11 lib/active_fulfillment/service.rb
active_fulfillment-3.2.10 lib/active_fulfillment/service.rb
active_fulfillment-3.2.8 lib/active_fulfillment/service.rb
active_fulfillment-3.2.7 lib/active_fulfillment/service.rb
active_fulfillment-3.2.6 lib/active_fulfillment/service.rb
active_fulfillment-3.2.5 lib/active_fulfillment/service.rb
active_fulfillment-3.2.4 lib/active_fulfillment/service.rb
active_fulfillment-3.2.3 lib/active_fulfillment/service.rb
active_fulfillment-3.2.2 lib/active_fulfillment/service.rb
active_fulfillment-3.2.1 lib/active_fulfillment/service.rb
active_fulfillment-3.2.0 lib/active_fulfillment/service.rb
active_fulfillment-3.1.1 lib/active_fulfillment/service.rb
active_fulfillment-3.1.0 lib/active_fulfillment/service.rb
active_fulfillment-3.0.8 lib/active_fulfillment/service.rb
active_fulfillment-3.0.7 lib/active_fulfillment/service.rb
active_fulfillment-3.0.6 lib/active_fulfillment/service.rb
active_fulfillment-3.0.5 lib/active_fulfillment/service.rb
active_fulfillment-3.0.4 lib/active_fulfillment/service.rb
active_fulfillment-3.0.3 lib/active_fulfillment/service.rb
active_fulfillment-3.0.2 lib/active_fulfillment/service.rb