Sha256: 5aed35002b6c326b854ac096c815c75bc5fa96eedea9d80ec2244e8b02641bd7

Contents?: true

Size: 1.57 KB

Versions: 7

Compression:

Stored size: 1.57 KB

Contents

module ActiveMerchant
  module Fulfillment
    class Service

      include RequiresParameters
      include PostsData

      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

      # 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_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

      def valid_credentials?
        raise NotImplementedError.new("Subclasses must implement")
      end

      def test_mode?
        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
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
active_fulfillment-2.1.6 lib/active_fulfillment/fulfillment/service.rb
active_fulfillment-2.1.5 lib/active_fulfillment/fulfillment/service.rb
active_fulfillment-2.1.4 lib/active_fulfillment/fulfillment/service.rb
active_fulfillment-2.1.3 lib/active_fulfillment/fulfillment/service.rb
active_fulfillment-2.1.2 lib/active_fulfillment/fulfillment/service.rb
active_fulfillment-2.1.1 lib/active_fulfillment/fulfillment/service.rb
active_fulfillment-2.1.0 lib/active_fulfillment/fulfillment/service.rb