Class: Multiwoven::Integrations::Destination::GoogleSheets::Client

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

Overview

rubocop:disable Metrics/ClassLength

Constant Summary collapse

MAX_CHUNK_SIZE =
10_000

Instance Method Summary collapse

Instance Method Details

#check_connection(connection_config) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/multiwoven/integrations/destination/google_sheets/client.rb', line 12

def check_connection(connection_config)
  authorize_client(connection_config)
  fetch_google_spread_sheets(connection_config)
  success_status
rescue StandardError => e
  handle_exception("GOOGLE_SHEETS:CRM:DISCOVER:EXCEPTION", "error", e)
  failure_status(e)
end

#discover(connection_config) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/multiwoven/integrations/destination/google_sheets/client.rb', line 21

def discover(connection_config)
  authorize_client(connection_config)
  spreadsheets = fetch_google_spread_sheets(connection_config)
  catalog = build_catalog_from_spreadsheets(spreadsheets, connection_config)
  catalog.to_multiwoven_message
rescue StandardError => e
  handle_exception("GOOGLE_SHEETS:CRM:DISCOVER:EXCEPTION", "error", e)
end

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



30
31
32
33
34
35
# File 'lib/multiwoven/integrations/destination/google_sheets/client.rb', line 30

def write(sync_config, records, action = "create")
  setup_write_environment(sync_config, action)
  process_record_chunks(records, sync_config)
rescue StandardError => e
  handle_exception("GOOGLE_SHEETS:CRM:WRITE:EXCEPTION", "error", e)
end