class Multiwoven::Integrations::Source::SalesforceConsumerGoodsCloud::Client

def read(sync_config)

def read(sync_config)
  connection_config = sync_config.source.connection_specification.with_indifferent_access
  initialize_client(connection_config)
  query = sync_config.model.query
  query = "#{query} LIMIT #{sync_config.limit}" unless sync_config.limit.nil?
  queried_data = @client.query(query)
  results = queried_data.map do |record|
    flatten_nested_hash(record)
  end
  results.map do |row|
    RecordMessage.new(data: row, emitted_at: Time.now.to_i).to_multiwoven_message
  end
rescue StandardError => e
  handle_exception(e, {
                     context: "SALESFORCE:CONSUMER:GOODS:ClOUD:WRITE:EXCEPTION",
                     type: "error",
                     sync_id: sync_config.sync_id,
                     sync_run_id: sync_config.sync_run_id
                   })
end