Class: Connectors::Example::Connector

Inherits:
Base::Connector show all
Defined in:
lib/connectors/example/connector.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base::Connector

#do_health_check!, #is_healthy?

Constructor Details

#initialize(configuration: {}) ⇒ Connector

Returns a new instance of Connector.



32
33
34
# File 'lib/connectors/example/connector.rb', line 32

def initialize(configuration: {})
  super
end

Class Method Details

.configurable_fieldsObject



23
24
25
26
27
28
29
30
# File 'lib/connectors/example/connector.rb', line 23

def self.configurable_fields
  {
    'foo' => {
      'label' => 'Foo',
      'value' => nil
    }
  }
end

.display_nameObject



19
20
21
# File 'lib/connectors/example/connector.rb', line 19

def self.display_name
  'Example Connector'
end

.service_typeObject



15
16
17
# File 'lib/connectors/example/connector.rb', line 15

def self.service_type
  'example'
end

Instance Method Details

#do_health_checkObject



36
37
38
39
40
41
# File 'lib/connectors/example/connector.rb', line 36

def do_health_check
  # Do the health check by trying to access 3rd-party system just to verify that everything is set up properly.
  #
  # To emulate unhealthy 3rd-party system situation, uncomment the following line:
  # raise 'something went wrong'
end

#yield_documentsObject



43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/connectors/example/connector.rb', line 43

def yield_documents
  attachments = [
    File.open('./lib/connectors/example/example_attachments/first_attachment.txt'),
    File.open('./lib/connectors/example/example_attachments/second_attachment.txt'),
    File.open('./lib/connectors/example/example_attachments/third_attachment.txt')
  ]

  attachments.each_with_index do |att, index|
    data = { id: (index + 1).to_s, name: "example document #{index + 1}", _attachment: File.read(att) }
    yield data
  end
end