multiwoven-integrations 0.15.4 → 0.15.6

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: acac8b39dc55f791583c7d36c2a28b66e8612eb30fe64b82b95614a94396a73e
4
- data.tar.gz: 4daed0b62e0b2f8d5f804f21623901e418de57d677e30ba056a4632fd23d3e4d
3
+ metadata.gz: b96516483bf86d1169acbf3feb44446a1918cade906a4be0571fde16ec75fe9a
4
+ data.tar.gz: a87b331943e82a980693787e837aabe31fb612f341fd1b429469543607849f3f
5
5
  SHA512:
6
- metadata.gz: ff74811a333c2f0fcd1ad546c87a07dd0295dc24d5765b93010243b4f5174f455469538bcc994a417f40306e81463e767a935b4f76b01c9ff9d61c7e67c4cf3f
7
- data.tar.gz: 84f502f75b115f8e7ce89460a87f93cdaae331d50b3f187ecdde4756af6067173b7c45776dae743919bbd0d5bd5fb13955f4baf0f82aa6c6e760abeae50999c1
6
+ metadata.gz: a4f1e3f76f73d4acbb58274b779f3d49db3e61cc2c3d17eecd033535844fad1240d1398ab67d59bb654f3e3b722de4e75038efedaebfb4a01120092aa1e009d2
7
+ data.tar.gz: 1631f64f1f87abe6bed877ebd293241c958eea6ccb85712239a636dd4bfd967622f1917ed021dda602cb1365e0fb9eafe85bc74eaf28a86b6f9807a15dad3e7f
@@ -65,9 +65,10 @@ module Multiwoven
65
65
  properties = stream.json_schema[:properties]
66
66
  records.each do |record_object|
67
67
  record = extract_data(record_object, properties)
68
- request, response = *process_record(stream, record)
68
+ args = [stream.name, "Id", record]
69
+ response = send_data_to_salesforce(args)
69
70
  write_success += 1
70
- log_message_array << log_request_response("info", request, response)
71
+ log_message_array << log_request_response("info", args, response)
71
72
  rescue StandardError => e
72
73
  # TODO: add sync_id and sync_run_id to the logs
73
74
  handle_exception(e, {
@@ -77,31 +78,14 @@ module Multiwoven
77
78
  sync_run_id: @sync_config.sync_run_id
78
79
  })
79
80
  write_failure += 1
80
- log_message_array << log_request_response("error", request, e.message)
81
+ log_message_array << log_request_response("error", args, e.message)
81
82
  end
82
83
  tracking_message(write_success, write_failure, log_message_array)
83
84
  end
84
85
 
85
- def process_record(stream, record)
86
- send_data_to_salesforce(stream.name, record)
87
- end
88
-
89
- def send_data_to_salesforce(stream_name, record = {})
90
- method_name = "#{@action}!"
91
- args = build_args(@action, stream_name, record)
92
- response = @client.send(method_name, *args)
93
- [args, response]
94
- end
95
-
96
- def build_args(action, stream_name, record)
97
- case action
98
- when :upsert
99
- [stream_name, record[:external_key], record]
100
- when :destroy
101
- [stream_name, record[:id]]
102
- else
103
- [stream_name, record]
104
- end
86
+ def send_data_to_salesforce(args)
87
+ method_name = "upsert!"
88
+ @client.send(method_name, *args)
105
89
  end
106
90
 
107
91
  def authenticate_client
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Multiwoven
4
4
  module Integrations
5
- VERSION = "0.15.4"
5
+ VERSION = "0.15.6"
6
6
 
7
7
  ENABLED_SOURCES = %w[
8
8
  Snowflake
@@ -7,12 +7,12 @@ module Multiwoven::Integrations::Source
7
7
  def check_connection(connection_config)
8
8
  connection_config = connection_config.with_indifferent_access
9
9
  url_host = connection_config[:url_host]
10
+ http_method = connection_config[:http_method]
10
11
  headers = connection_config[:headers]
11
- response = Multiwoven::Integrations::Core::HttpClient.request(
12
- url_host,
13
- HTTP_GET,
14
- headers: headers
15
- )
12
+ payload = JSON.parse(connection_config[:request_format])
13
+ config = connection_config[:config]
14
+ config[:timeout] ||= 30
15
+ response = send_request(url_host, http_method, payload, headers, config)
16
16
  if success?(response)
17
17
  success_status
18
18
  else
@@ -60,7 +60,7 @@ module Multiwoven::Integrations::Source
60
60
  headers = connection_config[:headers]
61
61
  config = connection_config[:config]
62
62
  config[:timeout] ||= 30
63
- response = send_request(url_host, payload, headers, config)
63
+ response = send_request(url_host, HTTP_POST, payload, headers, config)
64
64
  process_response(response)
65
65
  rescue StandardError => e
66
66
  handle_exception(e, context: "HTTP MODEL:RUN_MODEL:EXCEPTION", type: "error")
@@ -75,10 +75,10 @@ module Multiwoven::Integrations::Source
75
75
  end
76
76
  end
77
77
 
78
- def send_request(url, payload, headers, config)
78
+ def send_request(url, http_method, payload, headers, config)
79
79
  Multiwoven::Integrations::Core::HttpClient.request(
80
80
  url,
81
- HTTP_POST,
81
+ http_method,
82
82
  payload: payload,
83
83
  headers: headers,
84
84
  config: config
@@ -8,15 +8,21 @@
8
8
  "type": "object",
9
9
  "required": ["url_host"],
10
10
  "properties": {
11
+ "http_method": {
12
+ "type": "string",
13
+ "title": "HTTP Method",
14
+ "enum": ["POST", "GET"],
15
+ "order": 0
16
+ },
11
17
  "url_host": {
12
18
  "type": "string",
13
19
  "title": "URL",
14
- "order": 0
20
+ "order": 1
15
21
  },
16
22
  "headers": {
17
23
  "title": "HTTP Headers",
18
24
  "description": "Custom headers to include in the HTTP request. Useful for authentication, content type specifications, and other request metadata.",
19
- "order": 1,
25
+ "order": 2,
20
26
  "additionalProperties": {
21
27
  "type": "string"
22
28
  }
@@ -33,21 +39,21 @@
33
39
  "order": 0
34
40
  }
35
41
  },
36
- "order": 2
42
+ "order": 3
37
43
  },
38
44
  "request_format": {
39
45
  "title": "Request Format",
40
46
  "description": "Sample Request Format",
41
47
  "type": "string",
42
48
  "x-request-format": true,
43
- "order": 3
49
+ "order": 4
44
50
  },
45
51
  "response_format": {
46
52
  "title": "Response Format",
47
53
  "description": "Sample Response Format",
48
54
  "type": "string",
49
55
  "x-response-format": true,
50
- "order": 4
56
+ "order": 5
51
57
  }
52
58
  }
53
59
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multiwoven-integrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.4
4
+ version: 0.15.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Subin T P
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-11-15 00:00:00.000000000 Z
11
+ date: 2024-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport