Class: Etl::Integrations::Destination::SalesforceConsumerGoodsCloud::Client

Inherits:
DestinationConnector
  • Object
show all
Includes:
Core::RateLimiter
Defined in:
lib/etl/integrations/destination/salesforce_consumer_goods_cloud/client.rb

Instance Method Summary collapse

Instance Method Details

#check_connection(connection_config) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/etl/integrations/destination/salesforce_consumer_goods_cloud/client.rb', line 17

def check_connection(connection_config)
  connection_config = connection_config.with_indifferent_access
  initialize_client(connection_config)
  authenticate_client
  success_status
rescue StandardError => e
  failure_status(e)
end

#discover(connection_config) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/etl/integrations/destination/salesforce_consumer_goods_cloud/client.rb', line 26

def discover(connection_config)
  connection_config = connection_config.with_indifferent_access
  initialize_client(connection_config)
  catalog = build_catalog(load_catalog.with_indifferent_access)
  streams = catalog[:streams]
  SALESFORCE_OBJECTS.each do |object|
    object_description = @client.describe(object)
    streams << JSON.parse(SchemaHelper.create_json_schema_for_object(object_description).to_json)
  end
  catalog.to_multiwoven_message
rescue StandardError => e
  handle_exception("SALESFORCE:CONSUMER:GOODS:ClOUD:DISCOVER:EXCEPTION", "error", e)
end

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



40
41
42
43
44
45
46
# File 'lib/etl/integrations/destination/salesforce_consumer_goods_cloud/client.rb', line 40

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