multiwoven-integrations 0.1.47 → 0.1.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/multiwoven/integrations/destination/salesforce_consumer_goods_cloud/client.rb +16 -19
- data/lib/multiwoven/integrations/destination/salesforce_consumer_goods_cloud/config/catalog.json +1 -2037
- data/lib/multiwoven/integrations/destination/salesforce_consumer_goods_cloud/config/spec.json +15 -9
- data/lib/multiwoven/integrations/destination/salesforce_consumer_goods_cloud/schema_helper.rb +130 -0
- data/lib/multiwoven/integrations/rollout.rb +1 -1
- data/lib/multiwoven/integrations/source/salesforce_consumer_goods_cloud/client.rb +6 -120
- data/lib/multiwoven/integrations/source/salesforce_consumer_goods_cloud/schema_helper.rb +130 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f070f9727eba1e360878e33850045dfe4b508f351d91cb6fa3e6ae46edda8ad7
|
4
|
+
data.tar.gz: 425485c695c2803835c98549695d343d63db2c5d388328dc983759a50fdd63ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae737e08dbae12d4cea2c51082684f5dcfa1d50d75100252bcaaf3171922d185072ad5894a9546f695a22b3b8112b176fb8f6a1d9caa3a8614240243188373a8
|
7
|
+
data.tar.gz: 7d1adab5630abc8fb506391f49476b285f6753f79f8b779bf87db87ffb918c5e794dba28ee419b19629ea6f87ed93040bd81af787e92fc02f2cebef6d058dfd1
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "stringio"
|
4
|
+
require_relative "schema_helper"
|
4
5
|
|
5
6
|
module Multiwoven
|
6
7
|
module Integrations
|
@@ -9,6 +10,7 @@ module Multiwoven
|
|
9
10
|
include Multiwoven::Integrations::Core
|
10
11
|
|
11
12
|
API_VERSION = "59.0"
|
13
|
+
SALESFORCE_OBJECTS = %w[Account User Visit RetailStore RecordType].freeze
|
12
14
|
|
13
15
|
class Client < DestinationConnector
|
14
16
|
prepend Multiwoven::Integrations::Core::RateLimiter
|
@@ -21,8 +23,15 @@ module Multiwoven
|
|
21
23
|
failure_status(e)
|
22
24
|
end
|
23
25
|
|
24
|
-
def discover(
|
25
|
-
|
26
|
+
def discover(connection_config)
|
27
|
+
connection_config = connection_config.with_indifferent_access
|
28
|
+
initialize_client(connection_config)
|
29
|
+
catalog = build_catalog(load_catalog.with_indifferent_access)
|
30
|
+
streams = catalog[:streams]
|
31
|
+
SALESFORCE_OBJECTS.each do |object|
|
32
|
+
object_description = @client.describe(object)
|
33
|
+
streams << JSON.parse(SchemaHelper.create_json_schema_for_object(object_description).to_json)
|
34
|
+
end
|
26
35
|
catalog.to_multiwoven_message
|
27
36
|
rescue StandardError => e
|
28
37
|
handle_exception("SALESFORCE:CONSUMER:GOODS:ClOUD:DISCOVER:EXCEPTION", "error", e)
|
@@ -40,12 +49,11 @@ module Multiwoven
|
|
40
49
|
|
41
50
|
def initialize_client(config)
|
42
51
|
config = config.with_indifferent_access
|
43
|
-
@client = Restforce.new(
|
44
|
-
|
45
|
-
|
52
|
+
@client = Restforce.new(username: config[:username],
|
53
|
+
password: config[:password] + config[:security_token],
|
54
|
+
host: config[:host],
|
46
55
|
client_id: config[:client_id],
|
47
56
|
client_secret: config[:client_secret],
|
48
|
-
authentication_callback: proc { |x| log_debug(x.to_s) },
|
49
57
|
api_version: API_VERSION)
|
50
58
|
end
|
51
59
|
|
@@ -69,22 +77,11 @@ module Multiwoven
|
|
69
77
|
end
|
70
78
|
|
71
79
|
def send_data_to_salesforce(stream_name, record = {})
|
72
|
-
method_name = "
|
73
|
-
args =
|
80
|
+
method_name = "upsert!"
|
81
|
+
args = [stream_name, "Id", record]
|
74
82
|
@client.send(method_name, *args)
|
75
83
|
end
|
76
84
|
|
77
|
-
def build_args(action, stream_name, record)
|
78
|
-
case action
|
79
|
-
when :upsert
|
80
|
-
[stream_name, record[:external_key], record]
|
81
|
-
when :destroy
|
82
|
-
[stream_name, record[:id]]
|
83
|
-
else
|
84
|
-
[stream_name, record]
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
85
|
def authenticate_client
|
89
86
|
@client.authenticate!
|
90
87
|
end
|