multiwoven-integrations 0.7.5 → 0.7.7
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c28512cd0448ff7e826e5425252fb976f61f5e1b2a64ab1c77221934ff8f4ce
|
4
|
+
data.tar.gz: dcbc3b59cd6a694844bee68741a718634caa5405d73fd9b348f86cd4b1ff87f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 965e40b1589563aa28bff12b99ee87beb5437661f195d3912ad2450cb45ae2ff5b0c8a57e7581fe387db6e34dda1acfc3b5248ca93ad386d5ed67e7da0ba3d67
|
7
|
+
data.tar.gz: 6d2d29049d602e64e5b162a1f5246f2138ba2997aa09b2342beaf9b3031ff3e5fedfd207b93277a7ab55b882611a0ebf9a9e830ed02578caa8757c2d5109c564
|
@@ -59,10 +59,12 @@ module Multiwoven
|
|
59
59
|
connection_config = sync_config.destination.connection_specification.with_indifferent_access
|
60
60
|
api_key = connection_config[:api_key]
|
61
61
|
url = sync_config.stream.url
|
62
|
+
log_message_array = []
|
62
63
|
write_success = 0
|
63
64
|
write_failure = 0
|
64
65
|
records.each_slice(MAX_CHUNK_SIZE) do |chunk|
|
65
66
|
payload = create_payload(chunk)
|
67
|
+
args = [sync_config.stream.request_method, url, payload]
|
66
68
|
response = Multiwoven::Integrations::Core::HttpClient.request(
|
67
69
|
url,
|
68
70
|
sync_config.stream.request_method,
|
@@ -74,6 +76,7 @@ module Multiwoven
|
|
74
76
|
else
|
75
77
|
write_failure += chunk.size
|
76
78
|
end
|
79
|
+
log_message_array << log_request_response("info", args, response)
|
77
80
|
rescue StandardError => e
|
78
81
|
handle_exception(e, {
|
79
82
|
context: "AIRTABLE:RECORD:WRITE:EXCEPTION",
|
@@ -82,13 +85,9 @@ module Multiwoven
|
|
82
85
|
sync_run_id: sync_config.sync_run_id
|
83
86
|
})
|
84
87
|
write_failure += chunk.size
|
88
|
+
log_message_array << log_request_response("error", args, e.message)
|
85
89
|
end
|
86
|
-
|
87
|
-
tracker = Multiwoven::Integrations::Protocol::TrackingMessage.new(
|
88
|
-
success: write_success,
|
89
|
-
failed: write_failure
|
90
|
-
)
|
91
|
-
tracker.to_multiwoven_message
|
90
|
+
tracking_message(write_success, write_failure, log_message_array)
|
92
91
|
rescue StandardError => e
|
93
92
|
handle_exception(e, {
|
94
93
|
context: "AIRTABLE:RECORD:WRITE:EXCEPTION",
|
@@ -119,7 +118,7 @@ module Multiwoven
|
|
119
118
|
end
|
120
119
|
|
121
120
|
def base_id_exists?(bases, base_id)
|
122
|
-
return if
|
121
|
+
return if extract_bases(bases).any? { |base| base["id"] == base_id }
|
123
122
|
|
124
123
|
raise ArgumentError, "base_id not found"
|
125
124
|
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
|