multiwoven-integrations 0.7.4 → 0.7.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: 37b545ee313b4f088f5978fc8332e12506b2c964919a4a1a6599c7549c968ba0
4
- data.tar.gz: b8a089e677f9726a7ef2b432a6b6334a5e40e96b3190c216a133b6eef5cb6a09
3
+ metadata.gz: 72dd7b3912c4cdb05f5813b6dd17cc8d649def14a965bf69031eebdaee29f5a0
4
+ data.tar.gz: 4bc1bd0119288bd5a092aaf711853d979c13cccc1a6b06e8aa666fead633e6cc
5
5
  SHA512:
6
- metadata.gz: 8e1563c35fdf1db6451ce8c53231a2b7aba4a1eaf050d264817e3c4d63be2c46c30691b7b08007c74af76a4d91b01bcd256b370f4c2fefe6e23e617adf8e1f85
7
- data.tar.gz: 9fbe9e662993a134224d1ee03aff8ec6124ce7f59cc545b4beb3efba98407bfa42a19a846b4ebdb8d0c9a80ef4e9a58e82a4cc20219cc959a19ff3f16a98f926
6
+ metadata.gz: 555ca04c1dfc00200beb05bc812eac87ba270eff1d892574353481217272f31f60ddec401decbbacf3f96f65a8e24b67481d8b40a8cd5aa2a5da4f4af3887951
7
+ data.tar.gz: 15fe69927492c914f0bf9a60b15746443dd363e7df103dfb3476f85e63ed3ef6f720a3001e3bf0225e6bef330d6d93c2c851ba5ffe9d4c005ecca7b065caa3c5
@@ -54,31 +54,35 @@ module Multiwoven
54
54
  end
55
55
 
56
56
  def process_records(records, stream)
57
+ log_message_array = []
57
58
  write_success = 0
58
59
  write_failure = 0
59
60
  records.each do |record_object|
60
61
  record = extract_data(record_object, stream.json_schema[:properties])
61
- response = process_stream(record, stream)
62
+ request, response = *process_stream(record, stream)
62
63
  if response.success?
63
64
  write_success += 1
64
65
  else
65
66
  write_failure += 1
66
67
  end
68
+ log_message_array << log_request_response("info", request, response.body)
67
69
  rescue StandardError => e
68
70
  handle_exception("ITERABLE:WRITE:EXCEPTION", "error", e)
69
71
  write_failure += 1
72
+ log_message_array << log_request_response("error", request, e.message)
70
73
  end
71
- tracking_message(write_success, write_failure)
74
+ tracking_message(write_success, write_failure, log_message_array)
72
75
  end
73
76
 
74
77
  def process_stream(record, stream)
75
78
  klass = ::Iterable.const_get(stream.name).new(*initialize_params(stream, record))
76
79
  item_attrs = initialize_attribute(stream, record)
77
- if stream.name == "CatalogItems"
78
- klass.send(@action, item_attrs)
79
- else
80
- klass.send(@action)
81
- end
80
+ response = if stream.name == "CatalogItems"
81
+ klass.send("create", item_attrs)
82
+ else
83
+ klass.send("create")
84
+ end
85
+ [item_attrs, response]
82
86
  end
83
87
 
84
88
  def initialize_params(stream, record)
@@ -97,12 +101,6 @@ module Multiwoven
97
101
  end
98
102
  end
99
103
 
100
- def tracking_message(success, failure)
101
- Multiwoven::Integrations::Protocol::TrackingMessage.new(
102
- success: success, failed: failure
103
- ).to_multiwoven_message
104
- end
105
-
106
104
  def load_catalog
107
105
  read_json(CATALOG_SPEC_PATH)
108
106
  end
@@ -64,21 +64,24 @@ module Multiwoven
64
64
  end
65
65
 
66
66
  def process_records(records, stream)
67
+ log_message_array = []
67
68
  write_success = 0
68
69
  write_failure = 0
69
70
 
70
71
  records.each do |record|
71
72
  zendesk_data = prepare_record_data(record, stream.name)
72
73
  plural_stream_name = pluralize_stream_name(stream.name.downcase)
74
+ args = [plural_stream_name, @action, zendesk_data]
73
75
 
74
76
  if @action == "create"
75
- @client.send(plural_stream_name).create!(zendesk_data)
77
+ response = @client.send(plural_stream_name).create!(zendesk_data)
76
78
  else
77
79
  existing_record = @client.send(plural_stream_name).find(id: record[:id])
78
- existing_record.update!(zendesk_data)
80
+ response = existing_record.update!(zendesk_data)
79
81
  end
80
82
 
81
83
  write_success += 1
84
+ log_message_array << log_request_response("info", args, response)
82
85
  rescue StandardError => e
83
86
  handle_exception(e, {
84
87
  context: "ZENDESK:WRITE:EXCEPTION",
@@ -87,9 +90,9 @@ module Multiwoven
87
90
  sync_run_id: @sync_config.sync_run_id
88
91
  })
89
92
  write_failure += 1
93
+ log_message_array << log_request_response("error", args, e.message)
90
94
  end
91
-
92
- tracking_message(write_success, write_failure)
95
+ tracking_message(write_success, write_failure, log_message_array)
93
96
  end
94
97
 
95
98
  def pluralize_stream_name(name)
@@ -122,12 +125,6 @@ module Multiwoven
122
125
  def load_catalog
123
126
  read_json(CATALOG_SPEC_PATH)
124
127
  end
125
-
126
- def tracking_message(success, failure)
127
- Multiwoven::Integrations::Protocol::TrackingMessage.new(
128
- success: success, failed: failure
129
- ).to_multiwoven_message
130
- end
131
128
  end
132
129
  end
133
130
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Multiwoven
4
4
  module Integrations
5
- VERSION = "0.7.4"
5
+ VERSION = "0.7.6"
6
6
 
7
7
  ENABLED_SOURCES = %w[
8
8
  Snowflake
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multiwoven-integrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.4
4
+ version: 0.7.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Subin T P