Sha256: a68ed12c92b7673b3af60493edcd353adfca4758d8898636731fa4e0fc3bc59e

Contents?: true

Size: 1.03 KB

Versions: 7

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

module Multiwoven
  module Integrations::Core
    class BaseConnector
      include Integrations::Protocol
      include Utils
      include Constants

      def connector_spec
        @connector_spec ||= begin
          spec_json = keys_to_symbols(read_json(CONNECTOR_SPEC_PATH)).to_json
          ConnectorSpecification.from_json(spec_json)
        end
      end

      def meta_data
        @meta_data ||= read_json(META_DATA_PATH).to_h
      end

      def check_connection(_connection_config)
        raise "Not implemented"
        # returns Protocol.ConnectionStatus
      end

      def discover(_connection_config)
        raise "Not implemented"
      end

      private

      def read_json(file_path)
        path = Object.const_source_location(self.class.to_s)[0]
        connector_folder = File.dirname(path)
        file_path = File.join(
          "#{connector_folder}/",
          file_path
        )
        file_contents = File.read(file_path)
        JSON.parse(file_contents)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
multiwoven-integrations-0.1.11 lib/multiwoven/integrations/core/base_connector.rb
multiwoven-integrations-0.1.10 lib/multiwoven/integrations/core/base_connector.rb
multiwoven-integrations-0.1.9 lib/multiwoven/integrations/core/base_connector.rb
multiwoven-integrations-0.1.8 lib/multiwoven/integrations/core/base_connector.rb
multiwoven-integrations-0.1.7 lib/multiwoven/integrations/core/base_connector.rb
multiwoven-integrations-0.1.6 lib/multiwoven/integrations/core/base_connector.rb
multiwoven-integrations-0.1.2 lib/multiwoven/integrations/core/base_connector.rb