Sha256: 228faa8ce00cf3bd8ac773378447e0f6d32117f392123829cb8fb7512dca5a82

Contents?: true

Size: 1.98 KB

Versions: 29

Compression:

Stored size: 1.98 KB

Contents

# Faraday for making requests
require 'faraday'

module ApiClient

  module Connection

    class Abstract

      attr_accessor :endpoint, :handler, :options

      def initialize(endpoint, options = {})
        raise "Cannot instantiate abstract class" if self.class == ApiClient::Connection::Abstract
        @endpoint = endpoint
        @options  = options
        create_handler
      end

      def create_handler
      end

      #### ApiClient::Connection::Abstract#get
      # Performs a GET request
      # Accepts three parameters:
      #
      # * path - the path the request should go to
      # * data - (optional) the query, passed as a hash and converted into query params
      # * headers - (optional) headers sent along with the request
      #
      def get(path, data = {}, headers = {})
      end

      #### ApiClient::Connection::Abstract#post
      # Performs a POST request
      # Accepts three parameters:
      #
      # * path - the path request should go to
      # * data - (optional) data sent in the request
      # * headers - (optional) headers sent along in the request
      #
      def post(path, data = {}, headers = {})
      end

      #### ApiClient::Connection::Abstract#put
      # Performs a PUT request
      # Accepts three parameters:
      #
      # * path - the path request should go to
      # * data - (optional) data sent in the request
      # * headers - (optional) headers sent along in the request
      #
      def put(path, data = {}, headers = {})
      end

      #### FS::Connection#delete
      # Performs a DELETE request
      # Accepts three parameters:
      #
      # * path - the path request should go to
      # * data - (optional) the query, passed as a hash and converted into query params
      # * headers - (optional) headers sent along in the request
      #
      def delete(path, data = {}, headers = {})
      end

      def inspect
        "#<#{self.class} endpoint: \"#{endpoint}\">"
      end
      alias :to_s :inspect

    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
api_client-0.1.8 lib/api_client/connection/abstract.rb
api_client-0.1.7 lib/api_client/connection/abstract.rb
api_client-0.1.6 lib/api_client/connection/abstract.rb
api_client-0.1.5 lib/api_client/connection/abstract.rb
api_client-0.1.4 lib/api_client/connection/abstract.rb
api_client-0.1.3 lib/api_client/connection/abstract.rb
api_client-0.1.2 lib/api_client/connection/abstract.rb
api_client-0.1.1 lib/api_client/connection/abstract.rb
api_client-0.1.0 lib/api_client/connection/abstract.rb