Class: Multiwoven::Integrations::Destination::Iterable::Client

Inherits:
DestinationConnector
  • Object
show all
Defined in:
lib/multiwoven/integrations/destination/iterable/client.rb

Constant Summary collapse

MAX_CHUNK_SIZE =
10

Instance Method Summary collapse

Instance Method Details

#check_connection(connection_config) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/multiwoven/integrations/destination/iterable/client.rb', line 10

def check_connection(connection_config)
  connection_config = connection_config.with_indifferent_access
  initialize_client(connection_config)
  channels = ::Iterable::Channels.new
  response = channels.all
  if response.success?
    success_status
  else
    failure_status(nil)
  end
rescue StandardError => e
  handle_exception(e, {
                     context: "ITERABLE:CHECK_CONNECTION:EXCEPTION",
                     type: "error"
                   })
  failure_status(e)
end

#discover(_connection_config = nil) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/multiwoven/integrations/destination/iterable/client.rb', line 28

def discover(_connection_config = nil)
  catalog = build_catalog(load_catalog)
  catalog.to_multiwoven_message
rescue StandardError => e
  handle_exception(
    "ITERABLE:DISCOVER:EXCEPTION",
    "error",
    e
  )
end

#write(sync_config, records, action = "create") ⇒ Object



39
40
41
42
43
44
45
46
# File 'lib/multiwoven/integrations/destination/iterable/client.rb', line 39

def write(sync_config, records, action = "create")
  @action = sync_config.stream.action || action
  connection_config = sync_config.destination.connection_specification.with_indifferent_access
  initialize_client(connection_config)
  process_records(records, sync_config.stream)
rescue StandardError => e
  handle_exception("ITERABLE:WRITE:EXCEPTION", "error", e)
end