Sha256: d296d6565da63d142bdb071b5e703d63e776007464363140b61ff20aa3f861a5

Contents?: true

Size: 1.23 KB

Versions: 4

Compression:

Stored size: 1.23 KB

Contents

require "shippinglogic/fedex/attributes"
require "shippinglogic/fedex/request"
require "shippinglogic/fedex/response"
require "shippinglogic/fedex/validation"

module Shippinglogic
  class FedEx
    class Service < Proxy
      include Attributes
      include HTTParty
      include Request
      include Response
      include Validation
      
      attr_accessor :base
      
      # Accepts the base service object as a single parameter so that we can access
      # authentication credentials and options.
      def initialize(base, attributes = {})
        self.base = base
        super
      end
      
      private
        # Allows the cached response to be reset, specifically when an attribute changes
        def reset_target
          @target = nil
        end
        
        # For each service you need to overwrite this method. This is where you make the call to fedex
        # and do your magic. See the child classes for examples on how to define this method. It is very
        # important that you cache the result into a variable to avoid uneccessary requests.
        def target
          raise ImplementationError.new("You need to implement a target method that the proxy class can delegate method calls to")
        end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
binarylogic-shippinglogic-1.1.0 lib/shippinglogic/fedex/service.rb
binarylogic-shippinglogic-1.1.1 lib/shippinglogic/fedex/service.rb
binarylogic-shippinglogic-1.1.2 lib/shippinglogic/fedex/service.rb
binarylogic-shippinglogic-1.1.3 lib/shippinglogic/fedex/service.rb