class Multiwoven::Integrations::Destination::Slack::Client

def write(sync_config, records, action = "create")

def write(sync_config, records, action = "create")
  # Currently as we only create a message for each record in slack, we are not using actions.
  # This will be changed in future.
  @sync_config = sync_config
  @action = sync_config.stream.action || action
  connection_config = sync_config.destination.connection_specification.with_indifferent_access
  configure_slack(connection_config[:api_token])
  @client = ::Slack::Web::Client.new
  @channel_id = connection_config[:channel_id]
  process_records(records, sync_config.stream)
rescue StandardError => e
  handle_exception(e, {
                     context: "SLACK:WRITE:EXCEPTION",
                     type: "error",
                     sync_id: @sync_config.sync_id,
                     sync_run_id: @sync_config.sync_run_id
                   })
end