Class: Outhad::Integrations::Destination::SalesforceConsumerGoodsCloud::Client
- Inherits:
-
DestinationConnector
- Object
- DestinationConnector
- Outhad::Integrations::Destination::SalesforceConsumerGoodsCloud::Client
- Includes:
- Core::RateLimiter
- Defined in:
- lib/outhad/integrations/destination/salesforce_consumer_goods_cloud/client.rb
Instance Method Summary collapse
- #check_connection(connection_config) ⇒ Object
- #discover(connection_config) ⇒ Object
-
#initialize ⇒ Client
constructor
A new instance of Client.
- #write(sync_config, records, action = "create") ⇒ Object
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
18 19 20 21 22 23 24 25 |
# File 'lib/outhad/integrations/destination/salesforce_consumer_goods_cloud/client.rb', line 18 def initialize super @logger = Integrations::Service.logger Restforce.configure do |config| config.logger = @logger end Restforce.log = true end |
Instance Method Details
#check_connection(connection_config) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/outhad/integrations/destination/salesforce_consumer_goods_cloud/client.rb', line 27 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
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/outhad/integrations/destination/salesforce_consumer_goods_cloud/client.rb', line 36 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) rescue StandardError next end catalog. rescue StandardError => e handle_exception(e, { context: "SALESFORCE:CONSUMER:GOODS:ClOUD:DISCOVER:EXCEPTION", type: "error" }) end |
#write(sync_config, records, action = "create") ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/outhad/integrations/destination/salesforce_consumer_goods_cloud/client.rb', line 55 def write(sync_config, records, action = "create") @action = sync_config.stream.action || action @sync_config = sync_config initialize_client(sync_config.destination.connection_specification) process_records(records, sync_config.stream) 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 |