multiwoven-integrations 0.1.18 → 0.1.19
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: 429328f071eab809197f11563a5c87a91ca1d83db1f89f67edc001b2d8aa0d08
|
4
|
+
data.tar.gz: fdbe36a9021b0eae79cff29ec7002859f03993e354d61a45e01024b293ea5835
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b17d88517b0b196bef171d72abb99f8ae9faa8e1b8e62c4e9296e86d821025544c742e35a526b5cd1a35a31e8f1959183648a24dcb8ac0269ec34dca5de87e0
|
7
|
+
data.tar.gz: 96d942afc5d2a4015534b57d72b2f8f35fdb91bec1004e5d180ecf451d46a5cc980fdfca406335de9d7ef522e041c49dcba459d56f297ead36223e701f389ac3
|
@@ -3,7 +3,8 @@
|
|
3
3
|
module Multiwoven::Integrations::Destination
|
4
4
|
module FacebookCustomAudience
|
5
5
|
include Multiwoven::Integrations::Core
|
6
|
-
class Client < DestinationConnector
|
6
|
+
class Client < DestinationConnector # rubocop:disable Metrics/ClassLength
|
7
|
+
MAX_CHUNK_SIZE = 10_000
|
7
8
|
def check_connection(connection_config)
|
8
9
|
connection_config = connection_config.with_indifferent_access
|
9
10
|
access_token = connection_config[:access_token]
|
@@ -54,8 +55,8 @@ module Multiwoven::Integrations::Destination
|
|
54
55
|
url = generate_url(sync_config, connection_config)
|
55
56
|
write_success = 0
|
56
57
|
write_failure = 0
|
57
|
-
records.
|
58
|
-
payload = create_payload(
|
58
|
+
records.each_slice(MAX_CHUNK_SIZE) do |chunk|
|
59
|
+
payload = create_payload(chunk, sync_config.stream.json_schema.with_indifferent_access)
|
59
60
|
response = Multiwoven::Integrations::Core::HttpClient.request(
|
60
61
|
url,
|
61
62
|
sync_config.stream.request_method,
|
@@ -63,28 +64,22 @@ module Multiwoven::Integrations::Destination
|
|
63
64
|
headers: auth_headers(access_token)
|
64
65
|
)
|
65
66
|
if success?(response)
|
66
|
-
write_success +=
|
67
|
+
write_success += chunk.size
|
67
68
|
else
|
68
|
-
write_failure +=
|
69
|
+
write_failure += chunk.size
|
69
70
|
end
|
70
71
|
rescue StandardError => e
|
71
|
-
|
72
|
-
|
73
|
-
)
|
74
|
-
write_failure += 1
|
72
|
+
handle_exception("FACEBOOK:RECORD:WRITE:EXCEPTION", "error", e)
|
73
|
+
write_failure += chunk.size
|
75
74
|
end
|
75
|
+
|
76
76
|
tracker = Multiwoven::Integrations::Protocol::TrackingMessage.new(
|
77
77
|
success: write_success,
|
78
78
|
failed: write_failure
|
79
79
|
)
|
80
80
|
tracker.to_multiwoven_message
|
81
81
|
rescue StandardError => e
|
82
|
-
|
83
|
-
handle_exception(
|
84
|
-
"FACEBOOK:WRITE:EXCEPTION",
|
85
|
-
"error",
|
86
|
-
e
|
87
|
-
)
|
82
|
+
handle_exception("FACEBOOK:WRITE:EXCEPTION", "error", e)
|
88
83
|
end
|
89
84
|
|
90
85
|
private
|
@@ -93,28 +88,30 @@ module Multiwoven::Integrations::Destination
|
|
93
88
|
sync_config.stream.url.gsub("{audience_id}", connection_config[:audience_id])
|
94
89
|
end
|
95
90
|
|
96
|
-
def create_payload(
|
97
|
-
schema, data = extract_schema_and_data(
|
91
|
+
def create_payload(records, json_schema)
|
92
|
+
schema, data = extract_schema_and_data(records, json_schema)
|
98
93
|
{
|
99
94
|
"payload" => {
|
100
95
|
"schema" => schema,
|
101
|
-
"data" =>
|
96
|
+
"data" => data
|
102
97
|
}
|
103
98
|
}
|
104
99
|
end
|
105
100
|
|
106
|
-
def extract_schema_and_data(
|
101
|
+
def extract_schema_and_data(records, json_schema)
|
107
102
|
schema_properties = json_schema[:properties]
|
108
|
-
schema =
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
103
|
+
schema = records.first.keys.map(&:to_s).map(&:upcase)
|
104
|
+
data = []
|
105
|
+
records.each do |record|
|
106
|
+
encrypted_data_array = []
|
107
|
+
record.with_indifferent_access.each do |key, value|
|
108
|
+
schema_key = key.upcase
|
109
|
+
encrypted_value = schema_properties[schema_key] && schema_properties[schema_key]["x-hashRequired"] ? Digest::SHA256.hexdigest(value.to_s) : value
|
110
|
+
encrypted_data_array << encrypted_value
|
111
|
+
end
|
112
|
+
data << encrypted_data_array
|
115
113
|
end
|
116
|
-
|
117
|
-
[schema, encrypted_data_array]
|
114
|
+
[schema, data]
|
118
115
|
end
|
119
116
|
|
120
117
|
def auth_headers(access_token)
|
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.1.
|
4
|
+
version: 0.1.19
|
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-02-
|
11
|
+
date: 2024-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -362,7 +362,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
362
362
|
- !ruby/object:Gem::Version
|
363
363
|
version: '0'
|
364
364
|
requirements: []
|
365
|
-
rubygems_version: 3.
|
365
|
+
rubygems_version: 3.4.1
|
366
366
|
signing_key:
|
367
367
|
specification_version: 4
|
368
368
|
summary: Integration suite for open source reverse ETL platform
|