Class: Multiwoven::Integrations::Source::GoogleDrive::Client

Inherits:
SourceConnector
  • Object
show all
Defined in:
lib/multiwoven/integrations/source/google_drive/client.rb

Instance Method Summary collapse

Instance Method Details

#check_connection(connection_config) ⇒ Object



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

def check_connection(connection_config)
  connection_config = connection_config.with_indifferent_access
  client = create_connection(connection_config)
  build_query(client)
  success_status
rescue StandardError => e
  failure_status(e)
end

#discover(_connection_config) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/multiwoven/integrations/source/google_drive/client.rb', line 21

def discover(_connection_config)
  catalog_json = read_json(CATALOG_SPEC_PATH)
  catalog = build_catalog(catalog_json)
  catalog.to_multiwoven_message
rescue StandardError => e
  handle_exception(e, {
                     context: "GOOGLE_DRIVE:DISCOVER:EXCEPTION",
                     type: "error"
                   })
end

#read(sync_config) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/multiwoven/integrations/source/google_drive/client.rb', line 32

def read(sync_config)
  connection_config = sync_config.source.connection_specification.with_indifferent_access
  client = create_connection(connection_config)
  query = sync_config.model.query
  query = batched_query(query, sync_config.limit, sync_config.offset) unless sync_config.limit.nil? && sync_config.offset.nil?
  records = query(client, query)
  analyze_expenses(client, records)
rescue StandardError => e
  handle_exception(e, {
                     context: "GOOGLE_DRIVE:READ:EXCEPTION",
                     type: "error",
                     sync_id: sync_config.sync_id,
                     sync_run_id: sync_config.sync_run_id
                   })
end