Class: Etl::Integrations::Source::SalesforceConsumerGoodsCloud::Client
- Inherits:
-
SourceConnector
- Object
- SourceConnector
- Etl::Integrations::Source::SalesforceConsumerGoodsCloud::Client
- Includes:
- Core::RateLimiter
- Defined in:
- lib/etl/integrations/source/salesforce_consumer_goods_cloud/client.rb
Instance Method Summary collapse
- #check_connection(connection_config) ⇒ Object
- #discover(connection_config) ⇒ Object
- #read(sync_config) ⇒ Object
Methods included from Core::RateLimiter
Instance Method Details
#check_connection(connection_config) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/etl/integrations/source/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/source/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. rescue StandardError => e handle_exception("SALESFORCE:CONSUMER:GOODS:ClOUD:DISCOVER:EXCEPTION", "error", e) end |
#read(sync_config) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/etl/integrations/source/salesforce_consumer_goods_cloud/client.rb', line 40 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). end rescue StandardError => e handle_exception("SALESFORCE:CONSUMER:GOODS:ClOUD:WRITE:EXCEPTION", "error", e) end |