multiwoven-integrations 0.1.47 → 0.1.49
Sign up to get free protection for your applications and to get access to all the features.
- 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 +21 -124
- 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: 96d535997b9e775eb4f677ba0be5722ee3aaa88f3226a6fa3b4aef24fb949ffe
|
4
|
+
data.tar.gz: a1c0be33b6c70efadb6c4bed8016a8b8c65cbb66ef430194d50cd0220b325559
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 406892b62ca959ec83fd237568a6d5475f51656d1083b54ac87ff1c08a4cbb49ffc5eca436694e30514c6280cbb943ad8b66f894cb549d4241bacb6e10895fd3
|
7
|
+
data.tar.gz: bc3bf83c198472ef8af07f6763a02e31b8abc7742bf3b5f0fff3483094526870f88ad5f88df6291301eec3e207541e62a84d249f6c5df861ffc7debdea35db18
|
@@ -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
|