multiwoven-integrations 0.1.74 → 0.1.76

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7c7b0b9a8d6a1458eef924831e842a8e78fdaafc9b8f2977da6b5f23f6a465a2
4
- data.tar.gz: 2db159c6afe7267c5d41ef179220ddc40dc84832aa8c76d949c191924d2dd44b
3
+ metadata.gz: 489b7124c7814169b6c17fbd7de9cbde740e2f23f4ce0e0f0f74ddf6ba1b73c8
4
+ data.tar.gz: 74fb01f7fa855194d7585df7ab7c79afd8a84d811be3989c30b53e3232174c9b
5
5
  SHA512:
6
- metadata.gz: 54fe61b48f851d3b211e1b26db1280e76b76d5b6f25df33e57d841626f06490431f94279f207d76369f036bd8602d947bed0a5e2e44aa6cc07743acee87d2c7a
7
- data.tar.gz: 89b9dc4e5670c9606cce6624c73552e8168443ab2ace1778202759eba6f79c522da3ce02eea469150fd05b2b3b7bdf8d873956aa049adddca1ac8bf487e41a11
6
+ metadata.gz: 470ab95e9f07707468d2baa2f414436545ffa6f51d456ee2b498ae3b88e71df0fd3e73fadf8ca2d7429238a4b8676272bbd9cec81aa762745c571625b7be2791
7
+ data.tar.gz: 30cf3c3609382f06a4d7509e2923902011dbe85f0ff23aecd8ae5ec392289de759388a438389ca3bc22aeb68ce507b0aa9ef0c8131a9d0fa5db47cde381dfff1
@@ -0,0 +1,113 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Multiwoven
4
+ module Integrations
5
+ module Destination
6
+ module Iterable
7
+ include Multiwoven::Integrations::Core
8
+ class Client < DestinationConnector
9
+ MAX_CHUNK_SIZE = 10
10
+ def check_connection(connection_config)
11
+ connection_config = connection_config.with_indifferent_access
12
+ initialize_client(connection_config)
13
+ channels = ::Iterable::Channels.new
14
+ response = channels.all
15
+ if response.success?
16
+ success_status
17
+ else
18
+ failure_status(nil)
19
+ end
20
+ rescue StandardError => e
21
+ handle_exception(e, {
22
+ context: "ITERABLE:CHECK_CONNECTION:EXCEPTION",
23
+ type: "error"
24
+ })
25
+ failure_status(e)
26
+ end
27
+
28
+ def discover(_connection_config = nil)
29
+ catalog = build_catalog(load_catalog)
30
+ catalog.to_multiwoven_message
31
+ rescue StandardError => e
32
+ handle_exception(
33
+ "ITERABLE:DISCOVER:EXCEPTION",
34
+ "error",
35
+ e
36
+ )
37
+ end
38
+
39
+ def write(sync_config, records, action = "create")
40
+ @action = sync_config.stream.action || action
41
+ connection_config = sync_config.destination.connection_specification.with_indifferent_access
42
+ initialize_client(connection_config)
43
+ process_records(records, sync_config.stream)
44
+ rescue StandardError => e
45
+ handle_exception("ITERABLE:WRITE:EXCEPTION", "error", e)
46
+ end
47
+
48
+ private
49
+
50
+ def initialize_client(connection_config)
51
+ ::Iterable.configure do |config|
52
+ config.token = connection_config[:api_key]
53
+ end
54
+ end
55
+
56
+ def process_records(records, stream)
57
+ write_success = 0
58
+ write_failure = 0
59
+ records.each do |record_object|
60
+ record = extract_data(record_object, stream.json_schema[:properties])
61
+ response = process_stream(record, stream)
62
+ if response.success?
63
+ write_success += 1
64
+ else
65
+ write_failure += 1
66
+ end
67
+ rescue StandardError => e
68
+ handle_exception("ITERABLE:WRITE:EXCEPTION", "error", e)
69
+ write_failure += 1
70
+ end
71
+ tracking_message(write_success, write_failure)
72
+ end
73
+
74
+ def process_stream(record, stream)
75
+ klass = ::Iterable.const_get(stream.name).new(*initialize_params(stream, record))
76
+ 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
82
+ end
83
+
84
+ def initialize_params(stream, record)
85
+ if stream.name == "CatalogItems"
86
+ [record[:catalog_name], record[:item_id]]
87
+ else
88
+ [record[:catalog]]
89
+ end
90
+ end
91
+
92
+ def initialize_attribute(stream, record)
93
+ if stream.name == "CatalogItems"
94
+ JSON.parse(record[:item_attribute])
95
+ else
96
+ {}
97
+ end
98
+ end
99
+
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
+ def load_catalog
107
+ read_json(CATALOG_SPEC_PATH)
108
+ end
109
+ end
110
+ end
111
+ end
112
+ end
113
+ end
@@ -0,0 +1,47 @@
1
+ {
2
+ "request_rate_limit": 6000,
3
+ "request_rate_limit_unit": "minute",
4
+ "request_rate_concurrency": 10,
5
+ "streams": [
6
+ {
7
+ "name": "Catalogs",
8
+ "action": "create",
9
+ "json_schema": {
10
+ "type": "object",
11
+ "properties": {
12
+ "catalog": {
13
+ "type": "string"
14
+ }
15
+ }
16
+ },
17
+ "response_type": "application/json",
18
+ "supported_sync_modes": ["incremental"],
19
+ "source_defined_cursor": true
20
+ },
21
+ {
22
+ "name": "CatalogItems",
23
+ "action": "create",
24
+ "json_schema": {
25
+ "type": "object",
26
+ "required": ["catalog_name", "item_id", "item_attribute"],
27
+ "properties": {
28
+ "catalog_name": {
29
+ "type": "string"
30
+ },
31
+ "item_id": {
32
+ "type": "string"
33
+ },
34
+ "item_attribute": {
35
+ "type": "string",
36
+ "description": "String must be in json format"
37
+ }
38
+ }
39
+ },
40
+ "response_type": "application/json",
41
+ "supported_sync_modes": ["incremental"],
42
+ "source_defined_cursor": true,
43
+ "default_cursor_field": ["updated"],
44
+ "source_defined_primary_key": [["catalog_name"]]
45
+ }
46
+ ]
47
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "data": {
3
+ "name": "Iterable",
4
+ "title": "Iterable",
5
+ "connector_type": "destination",
6
+ "category": "Marketing Automation",
7
+ "documentation_url": "https://docs.multiwoven.com/destinations/iterable",
8
+ "github_issue_label": "destination-iterable",
9
+ "icon": "icon.svg",
10
+ "license": "MIT",
11
+ "release_stage": "alpha",
12
+ "support_level": "community",
13
+ "tags": ["language:ruby", "multiwoven"]
14
+ }
15
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "documentation_url": "https://docs.multiwoven.com/integrations/destination/iterable",
3
+ "stream_type": "static",
4
+ "connection_specification": {
5
+ "$schema": "http://json-schema.org/draft-07/schema#",
6
+ "title": "Iterable",
7
+ "type": "object",
8
+ "required": ["api_key"],
9
+ "properties": {
10
+ "api_key": {
11
+ "description": "The Iterable API key.",
12
+ "type": "string",
13
+ "multiwoven_secret": true,
14
+ "title": "api_key",
15
+ "order": 0
16
+ }
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,71 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 25.4.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <svg version="1.0" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
4
+ viewBox="0 0 292 193.6" style="enable-background:new 0 0 292 193.6;" xml:space="preserve">
5
+ <style type="text/css">
6
+ .st0{opacity:0.25;fill:#59C1A7;enable-background:new ;}
7
+ .st1{opacity:0.25;fill:#36C3F2;enable-background:new ;}
8
+ .st2{opacity:0.15;fill:#EF3D55;enable-background:new ;}
9
+ .st3{opacity:0.15;fill:#6A266D;enable-background:new ;}
10
+ .st4{fill:#6A266D;}
11
+ .st5{fill:#36C3F2;}
12
+ .st6{fill:#59C1A7;}
13
+ .st7{fill:#EF3D55;}
14
+ .st8{fill:#333332;}
15
+ .st9{fill:none;}
16
+ </style>
17
+ <g id="Lines">
18
+
19
+ <rect x="140.4" y="74.4" transform="matrix(0.7071 -0.7071 0.7071 0.7071 -12.7722 138.3672)" class="st0" width="40.4" height="20.3"/>
20
+
21
+ <rect x="150.3" y="35.6" transform="matrix(0.7071 -0.7071 0.7071 0.7071 7.5244 129.821)" class="st1" width="20.3" height="40.4"/>
22
+
23
+ <rect x="121.3" y="64.4" transform="matrix(0.7071 -0.7071 0.7071 0.7071 -21.341 117.7495)" class="st2" width="20.3" height="40.4"/>
24
+
25
+ <rect x="111.9" y="45" transform="matrix(0.7071 -0.7071 0.7071 0.7071 -0.2944 109.5877)" class="st3" width="40.4" height="20.4"/>
26
+ </g>
27
+ <g id="Nodes">
28
+ <circle class="st4" cx="146" cy="41.3" r="10.2"/>
29
+ <circle class="st5" cx="174.9" cy="70.4" r="10.2"/>
30
+ <circle class="st6" cx="146" cy="99.3" r="10.2"/>
31
+ <circle class="st7" cx="117.1" cy="70.3" r="10.2"/>
32
+ </g>
33
+ <g id="Iterable">
34
+ <path class="st8" d="M116.7,139.6h-12.5c-0.2,0-0.4,0.2-0.4,0.4v22c0,0.2,0.2,0.4,0.4,0.4h12.5c0.2,0,0.4-0.2,0.4-0.4v-3.5
35
+ c0-0.2-0.2-0.4-0.4-0.4h-7.6c-0.4,0-0.8-0.3-0.8-0.8c0,0,0,0,0,0v-3.6c0-0.4,0.3-0.8,0.8-0.8c0,0,0,0,0,0h7c0.2,0,0.4-0.2,0.4-0.4
36
+ v-3.1c0-0.2-0.2-0.4-0.4-0.4h-7c-0.4,0-0.8-0.3-0.8-0.8c0,0,0,0,0,0v-3.4c0-0.4,0.3-0.8,0.8-0.8c0,0,0,0,0,0h7.6
37
+ c0.2,0,0.4-0.2,0.4-0.4v-3.5C117.1,139.8,116.9,139.6,116.7,139.6C116.7,139.6,116.7,139.6,116.7,139.6z"/>
38
+ <path class="st8" d="M168.6,162.4c0.1,0,0.3-0.1,0.3-0.2c0.1-0.1,0.1-0.3,0-0.4l-8.8-22c-0.1-0.2-0.2-0.3-0.4-0.3h-2.2
39
+ c-0.2,0-0.3,0.1-0.4,0.3l-8.8,22c-0.1,0.1-0.1,0.3,0,0.4c0.1,0.1,0.2,0.2,0.3,0.2h4c0.2,0,0.3-0.1,0.4-0.3l1.1-3
40
+ c0.1-0.3,0.4-0.5,0.8-0.5h7.4c0.3,0,0.6,0.2,0.8,0.5l1.1,3c0.1,0.2,0.2,0.3,0.4,0.3H168.6z M161,154.3c-0.1,0.2-0.4,0.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,0-0.7-0.3-0.7-0.7l0,0
51
+ L180.7,153.4z"/>
52
+ <path class="st8" d="M137.7,154.5c-0.2-0.4-0.1-0.9,0.3-1.1c0,0,0,0,0,0c1-0.6,1.8-1.4,2.4-2.4c0.7-1.2,1.1-2.6,1-4
53
+ c0-1.3-0.4-2.6-1-3.7c-0.6-1.1-1.6-2.1-2.7-2.8c-1.2-0.7-2.7-1.1-4.1-1.1h-7c-0.2,0-0.4,0.2-0.4,0.4v22c0,0.2,0.2,0.4,0.4,0.4h3.6
54
+ c0.2,0,0.4-0.2,0.4-0.4v-6.6c0-0.4,0.3-0.8,0.8-0.8c0,0,0,0,0,0h1.1c0.3,0,0.6,0.2,0.7,0.4l3.8,7.2c0.1,0.1,0.2,0.2,0.4,0.2h4.2
55
+ c0.2,0,0.4-0.2,0.4-0.4c0-0.1,0-0.1,0-0.2L137.7,154.5z M135.8,149.4c-0.7,0.6-1.6,0.9-2.5,0.9h-1.8c-0.4,0-0.8-0.3-0.8-0.8
56
+ c0,0,0,0,0,0v-4.7c0-0.4,0.3-0.8,0.8-0.8c0,0,0,0,0,0h1.8c0.9,0,1.8,0.3,2.5,0.9C137.1,146.1,137.1,148.1,135.8,149.4
57
+ C135.9,149.4,135.8,149.4,135.8,149.4L135.8,149.4z"/>
58
+ <path class="st8" d="M95.4,139.6H81c-0.2,0-0.4,0.2-0.4,0.4l0,0v3.5c0,0.2,0.2,0.4,0.4,0.4h4.2c0.4,0,0.8,0.3,0.8,0.8c0,0,0,0,0,0
59
+ l0,0v17.3c0,0.2,0.2,0.4,0.4,0.4h3.7c0.2,0,0.4-0.2,0.4-0.4l0,0v-17.4c0-0.4,0.3-0.8,0.8-0.8c0,0,0,0,0,0h4.1
60
+ c0.2,0,0.4-0.2,0.4-0.4V140C95.8,139.8,95.6,139.6,95.4,139.6L95.4,139.6z"/>
61
+ <path class="st8" d="M233.4,158.1h-7.6c-0.4,0-0.8-0.3-0.8-0.8c0,0,0,0,0,0v-3.6c0-0.4,0.3-0.8,0.8-0.8c0,0,0,0,0,0h7
62
+ c0.2,0,0.4-0.2,0.4-0.4v-3.1c0-0.2-0.2-0.4-0.4-0.4h-7c-0.4,0-0.8-0.3-0.8-0.7c0,0,0,0,0,0v-3.4c0-0.4,0.3-0.8,0.8-0.8c0,0,0,0,0,0
63
+ h7.6c0.2,0,0.4-0.2,0.4-0.4v-3.5c0-0.2-0.2-0.4-0.4-0.4h-12.5c-0.2,0-0.4,0.2-0.4,0.4v22c0,0.2,0.2,0.4,0.4,0.4h12.5
64
+ c0.2,0,0.4-0.2,0.4-0.4v-3.5C233.8,158.3,233.6,158.1,233.4,158.1z"/>
65
+ <path class="st8" d="M72.1,158.1h-3.6c-0.4,0-0.8-0.3-0.8-0.8c0,0,0,0,0,0l0,0v-12.6c0-0.4,0.3-0.8,0.8-0.8c0,0,0,0,0,0h3.6
66
+ c0.2,0,0.4-0.2,0.4-0.4l0,0V140c0-0.2-0.2-0.4-0.4-0.4H58.6c-0.2,0-0.4,0.2-0.4,0.4l0,0v3.5c0,0.2,0.2,0.4,0.4,0.4h3.8
67
+ c0.4,0,0.8,0.3,0.8,0.8c0,0,0,0,0,0v12.6c0,0.4-0.4,0.8-0.8,0.8h-3.8c-0.2,0-0.4,0.2-0.4,0.4l0,0v3.5c0,0.2,0.2,0.4,0.4,0.4h4.9
68
+ c0,0,0.1,0,0.1,0h3.7c0,0,0.1,0,0.1,0h4.8c0.2,0,0.4-0.2,0.4-0.4l0,0v-3.5C72.6,158.3,72.4,158.1,72.1,158.1L72.1,158.1z"/>
69
+ </g>
70
+ <rect x="50" y="25.3" class="st9" width="192" height="143"/>
71
+ </svg>
@@ -45,13 +45,14 @@ module Multiwoven::Integrations::Destination
45
45
  def write(sync_config, records, action = "destination_insert")
46
46
  connection_config = sync_config.destination.connection_specification.with_indifferent_access
47
47
  table_name = sync_config.stream.name
48
+ primary_key = sync_config.model.primary_key
48
49
  db = create_connection(connection_config)
49
50
 
50
51
  write_success = 0
51
52
  write_failure = 0
52
53
 
53
54
  records.each do |record|
54
- query = Multiwoven::Integrations::Core::QueryBuilder.perform(action, table_name, record)
55
+ query = Multiwoven::Integrations::Core::QueryBuilder.perform(action, table_name, record, primary_key)
55
56
  logger.debug("POSTGRESQL:WRITE:QUERY query = #{query} sync_id = #{sync_config.sync_id} sync_run_id = #{sync_config.sync_run_id}")
56
57
  begin
57
58
  db.exec(query)
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Multiwoven
4
4
  module Integrations
5
- VERSION = "0.1.74"
5
+ VERSION = "0.1.76"
6
6
 
7
7
  ENABLED_SOURCES = %w[
8
8
  Snowflake
@@ -29,6 +29,7 @@ module Multiwoven
29
29
  Postgresql
30
30
  Http
31
31
  Zendesk
32
+ Iterable
32
33
  ].freeze
33
34
  end
34
35
  end
@@ -27,6 +27,7 @@ require "zip"
27
27
  require "zendesk_api"
28
28
  require "faraday"
29
29
  require "base64"
30
+ require "iterable-api-client"
30
31
 
31
32
  # Service
32
33
  require_relative "integrations/config"
@@ -69,6 +70,7 @@ require_relative "integrations/destination/sftp/client"
69
70
  require_relative "integrations/destination/postgresql/client"
70
71
  require_relative "integrations/destination/http/client"
71
72
  require_relative "integrations/destination/zendesk/client"
73
+ require_relative "integrations/destination/iterable/client"
72
74
 
73
75
  module Multiwoven
74
76
  module Integrations
@@ -44,6 +44,7 @@ Gem::Specification.new do |spec|
44
44
  spec.add_runtime_dependency "google-apis-sheets_v4"
45
45
  spec.add_runtime_dependency "google-cloud-bigquery"
46
46
  spec.add_runtime_dependency "hubspot-api-client"
47
+ spec.add_runtime_dependency "iterable-api-client"
47
48
  spec.add_runtime_dependency "net-sftp"
48
49
  spec.add_runtime_dependency "pg"
49
50
  spec.add_runtime_dependency "rake"
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.74
4
+ version: 0.1.76
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-06-04 00:00:00.000000000 Z
11
+ date: 2024-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -164,6 +164,20 @@ dependencies:
164
164
  - - ">="
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: iterable-api-client
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :runtime
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
167
181
  - !ruby/object:Gem::Dependency
168
182
  name: net-sftp
169
183
  requirement: !ruby/object:Gem::Requirement
@@ -456,6 +470,11 @@ files:
456
470
  - lib/multiwoven/integrations/destination/hubspot/config/meta.json
457
471
  - lib/multiwoven/integrations/destination/hubspot/config/spec.json
458
472
  - lib/multiwoven/integrations/destination/hubspot/icon.svg
473
+ - lib/multiwoven/integrations/destination/iterable/client.rb
474
+ - lib/multiwoven/integrations/destination/iterable/config/catalog.json
475
+ - lib/multiwoven/integrations/destination/iterable/config/meta.json
476
+ - lib/multiwoven/integrations/destination/iterable/config/spec.json
477
+ - lib/multiwoven/integrations/destination/iterable/icon.svg
459
478
  - lib/multiwoven/integrations/destination/klaviyo/client.rb
460
479
  - lib/multiwoven/integrations/destination/klaviyo/config/catalog.json
461
480
  - lib/multiwoven/integrations/destination/klaviyo/config/meta.json