multiwoven-integrations 0.1.46 → 0.1.48

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9d5c2974ca47dcb890b63d5cecc36dda1aa8ccb5aa18f47bd5290e0c93404cf1
4
- data.tar.gz: 50f189b498ec3ea5c9231a1f6736997e1beaebd0f34334592495e13081aca1a8
3
+ metadata.gz: f070f9727eba1e360878e33850045dfe4b508f351d91cb6fa3e6ae46edda8ad7
4
+ data.tar.gz: 425485c695c2803835c98549695d343d63db2c5d388328dc983759a50fdd63ee
5
5
  SHA512:
6
- metadata.gz: 382240e745a2e409d9892b714176f049f2b4b3f3e5a87b5c115db298dc3ab584bb3cafb2cb107f90e6adb3f17e09b3471b968f5ce26d6c019cffcd9a257cf1b7
7
- data.tar.gz: 2c9e92a298cfab8e4287ebaa8e38c3d25a2d07e6cfffcea3785a73586abd1a7ad1f58ab5d5ee3f64005c2d08c0a5374fc03fcb6c84968db3af2c77301cd20226
6
+ metadata.gz: ae737e08dbae12d4cea2c51082684f5dcfa1d50d75100252bcaaf3171922d185072ad5894a9546f695a22b3b8112b176fb8f6a1d9caa3a8614240243188373a8
7
+ data.tar.gz: 7d1adab5630abc8fb506391f49476b285f6753f79f8b779bf87db87ffb918c5e794dba28ee419b19629ea6f87ed93040bd81af787e92fc02f2cebef6d058dfd1
@@ -3,7 +3,7 @@
3
3
  "name": "Postgresql",
4
4
  "title": "PostgreSQL",
5
5
  "connector_type": "destination",
6
- "category": "Data Warehouse",
6
+ "category": "Database",
7
7
  "documentation_url": "https://docs.mutliwoven.com",
8
8
  "github_issue_label": "destination-postgresql",
9
9
  "icon": "icon.svg",
@@ -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(_connection_config = nil)
25
- catalog = build_catalog(load_catalog)
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(oauth_token: config[:access_token],
44
- refresh_token: config[:refresh_token],
45
- instance_url: config[:instance_url],
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 = "#{@action}!"
73
- args = build_args(@action, stream_name, record)
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