Sha256: 3b5a0ae063073107a015b93aa4760beeded03d4e3284cf7582f4e40190c29b37

Contents?: true

Size: 965 Bytes

Versions: 4

Compression:

Stored size: 965 Bytes

Contents

module NetSuite
  module Support
    module Requests

      def self.included(base)
        base.send(:extend, ClassMethods)
      end

      module ClassMethods

        def call(*args)
          new(*args).call
        end

      end

      def call
        @response = request
        build_response
      end

      private

      def request
        raise NotImplementedError, 'Please implement a #request method'
      end

      def build_response
        Response.new(success: success?, header: response_header, body: response_body, errors: response_errors)
      end

      def success?
        raise NotImplementedError, 'Please implement a #success? method'
      end

      # Only care about headers in Search class for now
      def response_header
        nil
      end

      def response_errors
        nil
      end

      def response_body
        raise NotImplementedError, 'Please implement a #response_body method'
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
netsuite-0.2.4 lib/netsuite/support/requests.rb
netsuite-0.2.3 lib/netsuite/support/requests.rb
netsuite-0.2.2 lib/netsuite/support/requests.rb
netsuite-0.2.1 lib/netsuite/support/requests.rb