multiwoven-integrations 0.12.0 → 0.13.1

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: 39b0d65bc581946d3576734695b267d4d9b32e8b973489d5d4d2cebfd0848443
4
- data.tar.gz: 778a1d8f6d056e8769699c36849de4f96992a3e1646687d93fe8428c9e56f06f
3
+ metadata.gz: 2ec77e033727b0ee1dcffb68d822fc7881da80914ad9c783dbc429805d269067
4
+ data.tar.gz: 02b8d1a3bd999110e7a251281e414e57d4725c0d16e30947a2c299d2a0aae990
5
5
  SHA512:
6
- metadata.gz: 44c7d134bdf48b7548658f91c4abbac9a7cd79caecdb1f75c628ef06cfc7e3562f6af62abfd2614661da4b90c3adf21b6c01b5514efda46ae88e46673e155386
7
- data.tar.gz: fa3e918cc7b1aa524946bc59960638004a33b78baae8bc83cdf0abef6a0a90452211253d199637fc6d937c41b109871be6b70eb54b2d551946b65fc6222b4630
6
+ metadata.gz: 13e57b0868dca890856151bccca0950d46d92113dd4deca1ef4c474513954733ac23017aa13c34a2cb98345a51ed3b9eab93c2b56994c1dd05ae5467cfb0cc0f
7
+ data.tar.gz: 52e39eb65c1903c2ac9b5c237059b1f81e62d1f704737bcf96f3fbe03a1b148b1248eab662f53197395c2143b2f8328f8e5dcb8e6cc08c13c863bc5c1871b4bf
@@ -0,0 +1,141 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Multiwoven
4
+ module Integrations
5
+ module Destination
6
+ module Mailchimp
7
+ include Multiwoven::Integrations::Core
8
+
9
+ API_VERSION = "3.0"
10
+
11
+ class Client < DestinationConnector
12
+ prepend Multiwoven::Integrations::Core::RateLimiter
13
+
14
+ def check_connection(connection_config)
15
+ connection_config = connection_config.with_indifferent_access
16
+ initialize_client(connection_config)
17
+ authenticate_client
18
+ success_status
19
+ rescue StandardError => e
20
+ failure_status(e)
21
+ end
22
+
23
+ def discover(_connection_config = nil)
24
+ catalog = build_catalog(load_catalog)
25
+ catalog.to_multiwoven_message
26
+ rescue StandardError => e
27
+ handle_exception(e, {
28
+ context: "MAILCHIMP:DISCOVER:EXCEPTION",
29
+ type: "error"
30
+ })
31
+ end
32
+
33
+ def write(sync_config, records, _action = "create")
34
+ @sync_config = sync_config
35
+ initialize_client(sync_config.destination.connection_specification)
36
+ process_records(records, sync_config.stream)
37
+ rescue StandardError => e
38
+ handle_exception(e, {
39
+ context: "MAILCHIMP:WRITE:EXCEPTION",
40
+ type: "error",
41
+ sync_id: @sync_config.sync_id,
42
+ sync_run_id: @sync_config.sync_run_id
43
+ })
44
+ end
45
+
46
+ private
47
+
48
+ def initialize_client(config)
49
+ config = config.with_indifferent_access
50
+ @client = MailchimpMarketing::Client.new
51
+ @client.set_config({
52
+ api_key: config[:api_key],
53
+ server: config[:api_key].split("-").last
54
+ })
55
+ @list_id = config[:list_id]
56
+ @email_template_id = config[:email_template_id] || ""
57
+ end
58
+
59
+ def process_records(records, stream)
60
+ log_message_array = []
61
+ write_success = 0
62
+ write_failure = 0
63
+ properties = stream.json_schema[:properties]
64
+
65
+ records.each do |record_object|
66
+ record = extract_data(record_object, properties)
67
+ args = [stream.name, "Id", record]
68
+ begin
69
+ response = send_to_mailchimp(record, stream.name)
70
+ write_success += 1
71
+ log_message_array << log_request_response("info", args, response)
72
+ rescue StandardError => e
73
+ handle_exception(e, {
74
+ context: "MAILCHIMP:WRITE:EXCEPTION",
75
+ type: "error",
76
+ sync_id: @sync_config.sync_id,
77
+ sync_run_id: @sync_config.sync_run_id
78
+ })
79
+ write_failure += 1
80
+ log_message_array << log_request_response("error", args, e.message)
81
+ end
82
+ end
83
+ tracking_message(write_success, write_failure, log_message_array)
84
+ end
85
+
86
+ def send_to_mailchimp(record, stream_name)
87
+ case stream_name
88
+ when "Audience"
89
+ @client.lists.set_list_member(@list_id, Digest::MD5.hexdigest(record[:email].downcase), {
90
+ email_address: record[:email],
91
+ status_if_new: "subscribed",
92
+ merge_fields: {
93
+ FNAME: record[:first_name],
94
+ LNAME: record[:last_name]
95
+ }
96
+ })
97
+ when "Tags"
98
+ @client.lists.update_list_member_tags(@list_id, Digest::MD5.hexdigest(record[:email].downcase), {
99
+ tags: record[:tags].map { |tag| { name: tag, status: "active" } }
100
+ })
101
+ when "Campaigns"
102
+ campaign = @client.campaigns.create({
103
+ type: "regular",
104
+ recipients: { list_id: @list_id },
105
+ settings: {
106
+ subject_line: record[:subject],
107
+ from_name: record[:from_name],
108
+ reply_to: record[:reply_to]
109
+ }
110
+ })
111
+ if @email_template_id
112
+ @client.campaigns.set_content(campaign["id"], {
113
+ template: { id: @email_template_id }
114
+ })
115
+ else
116
+ @client.campaigns.set_content(campaign["id"], {
117
+ plain_text: record[:content]
118
+ })
119
+ end
120
+ @client.campaigns.send(campaign["id"])
121
+ else
122
+ raise "Unsupported stream type: #{stream_name}"
123
+ end
124
+ end
125
+
126
+ def authenticate_client
127
+ @client.lists.get_all_lists
128
+ end
129
+
130
+ def load_catalog
131
+ read_json(CATALOG_SPEC_PATH)
132
+ end
133
+
134
+ def log_debug(message)
135
+ Multiwoven::Integrations::Service.logger.debug(message)
136
+ end
137
+ end
138
+ end
139
+ end
140
+ end
141
+ end
@@ -0,0 +1,141 @@
1
+ {
2
+ "request_rate_limit": 100000,
3
+ "request_rate_limit_unit": "day",
4
+ "request_rate_concurrency": 10,
5
+ "streams": [
6
+ {
7
+ "name": "Audience",
8
+ "action": "create",
9
+ "json_schema": {
10
+ "type": "object",
11
+ "additionalProperties": true,
12
+ "required": ["email"],
13
+ "properties": {
14
+ "email": {
15
+ "type": "string",
16
+ "format": "email"
17
+ },
18
+ "first_name": {
19
+ "type": "string"
20
+ },
21
+ "last_name": {
22
+ "type": "string"
23
+ },
24
+ "status": {
25
+ "type": "string",
26
+ "enum": ["subscribed", "unsubscribed", "cleaned", "pending"]
27
+ },
28
+ "tags": {
29
+ "type": "array",
30
+ "items": {
31
+ "type": "string"
32
+ }
33
+ },
34
+ "merge_fields": {
35
+ "type": "object",
36
+ "additionalProperties": true,
37
+ "properties": {
38
+ "FNAME": {
39
+ "type": "string"
40
+ },
41
+ "LNAME": {
42
+ "type": "string"
43
+ }
44
+ }
45
+ },
46
+ "language": {
47
+ "type": "string"
48
+ },
49
+ "vip": {
50
+ "type": "boolean"
51
+ },
52
+ "timestamp_signup": {
53
+ "type": "string",
54
+ "format": "date-time"
55
+ },
56
+ "ip_signup": {
57
+ "type": "string",
58
+ "format": "ipv4"
59
+ },
60
+ "timestamp_opt": {
61
+ "type": "string",
62
+ "format": "date-time"
63
+ },
64
+ "ip_opt": {
65
+ "type": "string",
66
+ "format": "ipv4"
67
+ }
68
+ }
69
+ },
70
+ "supported_sync_modes": ["incremental"],
71
+ "source_defined_cursor": true,
72
+ "default_cursor_field": ["timestamp_opt"],
73
+ "source_defined_primary_key": [["email"]]
74
+ },
75
+ {
76
+ "name": "Tags",
77
+ "action": "create",
78
+ "json_schema": {
79
+ "type": "object",
80
+ "additionalProperties": true,
81
+ "required": ["email", "tags"],
82
+ "properties": {
83
+ "email": {
84
+ "type": "string",
85
+ "format": "email"
86
+ },
87
+ "tags": {
88
+ "type": "array",
89
+ "items": {
90
+ "type": "string"
91
+ }
92
+ }
93
+ }
94
+ },
95
+ "supported_sync_modes": ["incremental"],
96
+ "source_defined_cursor": true,
97
+ "default_cursor_field": ["updated"]
98
+ },
99
+ {
100
+ "name": "Campaigns",
101
+ "action": "create",
102
+ "json_schema": {
103
+ "type": "object",
104
+ "additionalProperties": true,
105
+ "required": ["subject", "from_name", "reply_to", "recipients"],
106
+ "properties": {
107
+ "subject": {
108
+ "type": "string"
109
+ },
110
+ "from_name": {
111
+ "type": "string"
112
+ },
113
+ "reply_to": {
114
+ "type": "string",
115
+ "format": "email"
116
+ },
117
+ "recipients": {
118
+ "type": "object",
119
+ "properties": {
120
+ "list_id": {
121
+ "type": "string"
122
+ }
123
+ }
124
+ },
125
+ "template_id": {
126
+ "type": "string"
127
+ },
128
+ "content": {
129
+ "type": "string"
130
+ },
131
+ "send_time": {
132
+ "type": "string",
133
+ "format": "date-time"
134
+ }
135
+ }
136
+ },
137
+ "supported_sync_modes": ["full_refresh"],
138
+ "source_defined_cursor": false
139
+ }
140
+ ]
141
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "data": {
3
+ "name": "Mailchimp",
4
+ "title": "Mailchimp",
5
+ "connector_type": "destination",
6
+ "category": "Marketing Automation",
7
+ "documentation_url": "https://docs.multiwoven.com/destinations/crm/mailchimp",
8
+ "github_issue_label": "destination-mailchimp",
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,28 @@
1
+ {
2
+ "documentation_url": "https://docs.multiwoven.com/integrations/destination/mailchimp",
3
+ "stream_type": "static",
4
+ "connection_specification": {
5
+ "$schema": "http://json-schema.org/draft-07/schema#",
6
+ "title": "Mailchimp",
7
+ "type": "object",
8
+ "required": ["api_key", "list_id"],
9
+ "properties": {
10
+ "api_key": {
11
+ "type": "string",
12
+ "multiwoven_secret": true,
13
+ "title": "API Key",
14
+ "order": 0
15
+ },
16
+ "list_id": {
17
+ "type": "string",
18
+ "title": "List Id",
19
+ "order": 1
20
+ },
21
+ "email_template_id": {
22
+ "type": "string",
23
+ "title": "Email Template Id",
24
+ "order": 2
25
+ }
26
+ }
27
+ }
28
+ }
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
2
+ <svg fill="#000000" width="800px" height="800px" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
3
+ <path d="M23.974 15.12c0.219-0.026 0.443-0.026 0.661 0 0.12-0.271 0.141-0.745 0.031-1.255-0.156-0.76-0.37-1.224-0.818-1.151-0.443 0.073-0.458 0.625-0.302 1.385 0.094 0.427 0.25 0.797 0.427 1.021zM20.161 15.724c0.318 0.141 0.51 0.234 0.589 0.151 0.047-0.052 0.036-0.146-0.042-0.271-0.156-0.255-0.479-0.516-0.823-0.661-0.719-0.302-1.547-0.203-2.177 0.26-0.214 0.156-0.411 0.375-0.385 0.505 0.010 0.042 0.042 0.073 0.115 0.083 0.177 0.021 0.786-0.286 1.495-0.333 0.495-0.031 0.911 0.125 1.229 0.266zM19.521 16.089c-0.417 0.068-0.641 0.203-0.786 0.328-0.13 0.109-0.203 0.234-0.203 0.318l0.031 0.078 0.068 0.026c0.094 0 0.302-0.089 0.302-0.089 0.427-0.156 0.885-0.208 1.333-0.135 0.208 0.021 0.307 0.036 0.354-0.036 0.010-0.021 0.026-0.063-0.016-0.13-0.094-0.161-0.516-0.427-1.083-0.359zM22.688 17.432c0.281 0.135 0.589 0.083 0.688-0.12 0.104-0.208-0.042-0.49-0.323-0.625-0.281-0.141-0.589-0.083-0.693 0.12-0.099 0.208 0.047 0.484 0.328 0.625zM24.495 15.849c-0.229-0.005-0.422 0.245-0.422 0.562-0.005 0.313 0.172 0.568 0.401 0.573s0.417-0.245 0.422-0.557c0.005-0.313-0.177-0.573-0.401-0.578zM9.156 21.505c-0.057-0.068-0.151-0.047-0.24-0.026-0.073 0.016-0.146 0.026-0.214 0.031-0.156 0-0.302-0.073-0.391-0.198-0.104-0.161-0.099-0.401 0.016-0.672l0.052-0.125c0.188-0.411 0.49-1.099 0.146-1.755-0.255-0.495-0.677-0.802-1.188-0.865-0.49-0.063-0.974 0.109-1.313 0.469-0.505 0.557-0.583 1.318-0.484 1.589 0.036 0.099 0.094 0.125 0.135 0.13 0.083 0.010 0.208-0.052 0.292-0.266l0.021-0.068c0.036-0.115 0.104-0.328 0.208-0.495 0.281-0.427 0.849-0.547 1.271-0.266 0.354 0.229 0.495 0.667 0.344 1.078-0.078 0.219-0.208 0.625-0.177 0.964 0.057 0.682 0.474 0.953 0.849 0.984 0.365 0.016 0.62-0.193 0.688-0.344 0.036-0.089 0.005-0.141-0.016-0.167zM30.255 20.26c-0.016-0.052-0.104-0.385-0.229-0.781l-0.255-0.682c0.5-0.75 0.51-1.422 0.443-1.802-0.073-0.469-0.266-0.87-0.661-1.281-0.391-0.417-1.198-0.844-2.333-1.161l-0.594-0.161c0-0.026-0.031-1.406-0.057-1.995-0.016-0.427-0.052-1.099-0.26-1.755-0.245-0.891-0.677-1.672-1.214-2.172 1.479-1.536 2.406-3.229 2.401-4.677-0.005-2.797-3.427-3.641-7.646-1.891l-0.896 0.38c-0.547-0.536-1.089-1.073-1.641-1.609-4.813-4.203-19.854 12.542-15.047 16.615l1.052 0.891c-0.281 0.76-0.38 1.578-0.292 2.391 0.115 1.12 0.688 2.193 1.625 3.021 0.885 0.786 2.052 1.286 3.188 1.286 1.87 4.318 6.146 6.969 11.156 7.12 5.38 0.156 9.896-2.37 11.786-6.911 0.125-0.318 0.651-1.755 0.651-3.021 0-1.276-0.719-1.802-1.177-1.802zM8.25 23.656c-0.161 0.031-0.333 0.042-0.5 0.036-1.62-0.042-3.375-1.505-3.552-3.245-0.193-1.922 0.786-3.396 2.521-3.745 0.24-0.052 0.484-0.068 0.729-0.057 0.974 0.057 2.406 0.802 2.729 2.922 0.292 1.88-0.167 3.792-1.927 4.094zM6.438 15.552c-1.078 0.208-2.031 0.823-2.615 1.667-0.349-0.286-0.995-0.849-1.109-1.068-0.927-1.771 1.016-5.203 2.37-7.146 3.354-4.792 8.609-8.422 11.042-7.766 0.396 0.115 1.703 1.635 1.703 1.635s-2.432 1.349-4.688 3.234c-3.036 2.344-5.328 5.745-6.703 9.443zM23.484 22.943c0.036-0.016 0.063-0.057 0.057-0.094-0.005-0.052-0.047-0.089-0.099-0.083 0 0-2.542 0.38-4.948-0.505 0.26-0.849 0.958-0.542 2.010-0.458 1.635 0.099 3.276-0.078 4.854-0.526 1.089-0.313 2.516-0.927 3.63-1.807 0.375 0.823 0.505 1.729 0.505 1.729s0.292-0.052 0.531 0.099c0.229 0.141 0.396 0.438 0.281 1.193-0.229 1.417-0.833 2.568-1.844 3.63-0.63 0.682-1.38 1.245-2.219 1.656-0.464 0.245-0.948 0.448-1.443 0.615-3.813 1.245-7.714-0.125-8.974-3.068-0.099-0.224-0.182-0.458-0.25-0.698-0.536-1.938-0.083-4.266 1.344-5.729 0.083-0.094 0.172-0.203 0.172-0.344 0-0.115-0.073-0.234-0.135-0.323-0.495-0.724-2.219-1.953-1.875-4.339 0.25-1.714 1.745-2.917 3.141-2.849l0.354 0.021c0.604 0.036 1.13 0.115 1.625 0.135 0.833 0.036 1.583-0.083 2.469-0.823 0.297-0.25 0.536-0.469 0.943-0.536 0.042-0.005 0.151-0.047 0.359-0.036 0.219 0.010 0.427 0.078 0.609 0.198 0.714 0.474 0.813 1.62 0.849 2.458 0.021 0.479 0.078 1.635 0.099 1.969 0.047 0.76 0.245 0.87 0.646 1 0.229 0.078 0.443 0.135 0.75 0.219 0.943 0.266 1.5 0.536 1.849 0.88 0.214 0.214 0.307 0.443 0.339 0.661 0.115 0.813-0.625 1.813-2.583 2.724-2.141 0.995-4.734 1.245-6.526 1.047l-0.63-0.073c-1.432-0.193-2.25 1.661-1.391 2.938 0.552 0.818 2.068 1.354 3.578 1.354 3.464 0 6.13-1.484 7.12-2.766l0.078-0.115c0.052-0.073 0.010-0.109-0.052-0.068-0.807 0.552-4.406 2.755-8.25 2.094 0 0-0.469-0.078-0.896-0.245-0.339-0.13-1.047-0.458-1.135-1.188 3.104 0.964 5.057 0.052 5.057 0.052zM18.568 22.359h0.005zM12.63 8.984c1.193-1.38 2.661-2.578 3.974-3.25 0.047-0.026 0.094 0.026 0.073 0.068-0.104 0.188-0.307 0.599-0.37 0.901-0.010 0.047 0.042 0.083 0.078 0.057 0.823-0.557 2.245-1.156 3.495-1.234 0.052 0 0.078 0.068 0.036 0.099-0.208 0.161-0.391 0.344-0.552 0.552-0.026 0.036 0 0.083 0.042 0.083 0.88 0.010 2.115 0.318 2.917 0.771 0.057 0.031 0.021 0.135-0.042 0.12-1.219-0.281-3.214-0.495-5.286 0.016-1.849 0.453-3.26 1.146-4.292 1.901-0.052 0.036-0.115-0.031-0.073-0.083z"/>
4
+ </svg>
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Multiwoven
4
4
  module Integrations
5
- VERSION = "0.12.0"
5
+ VERSION = "0.13.1"
6
6
 
7
7
  ENABLED_SOURCES = %w[
8
8
  Snowflake
@@ -41,6 +41,7 @@ module Multiwoven
41
41
  Oracle
42
42
  MicrosoftExcel
43
43
  MicrosoftSql
44
+ Mailchimp
44
45
  ].freeze
45
46
  end
46
47
  end
@@ -36,6 +36,7 @@ require "aws-sdk-sagemaker"
36
36
  require "aws-sdk-sagemakerruntime"
37
37
  require "google/cloud/ai_platform/v1"
38
38
  require "grpc"
39
+ require "MailchimpMarketing"
39
40
 
40
41
  # Service
41
42
  require_relative "integrations/config"
@@ -90,6 +91,7 @@ require_relative "integrations/destination/databricks_lakehouse/client"
90
91
  require_relative "integrations/destination/oracle_db/client"
91
92
  require_relative "integrations/destination/microsoft_excel/client"
92
93
  require_relative "integrations/destination/microsoft_sql/client"
94
+ require_relative "integrations/destination/mailchimp/client"
93
95
 
94
96
  module Multiwoven
95
97
  module Integrations
@@ -52,6 +52,7 @@ Gem::Specification.new do |spec|
52
52
  spec.add_runtime_dependency "grpc"
53
53
  spec.add_runtime_dependency "hubspot-api-client"
54
54
  spec.add_runtime_dependency "iterable-api-client"
55
+ spec.add_runtime_dependency "MailchimpMarketing"
55
56
  spec.add_runtime_dependency "net-sftp"
56
57
  spec.add_runtime_dependency "pg"
57
58
  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.12.0
4
+ version: 0.13.1
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-10-04 00:00:00.000000000 Z
11
+ date: 2024-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -276,6 +276,20 @@ dependencies:
276
276
  - - ">="
277
277
  - !ruby/object:Gem::Version
278
278
  version: '0'
279
+ - !ruby/object:Gem::Dependency
280
+ name: MailchimpMarketing
281
+ requirement: !ruby/object:Gem::Requirement
282
+ requirements:
283
+ - - ">="
284
+ - !ruby/object:Gem::Version
285
+ version: '0'
286
+ type: :runtime
287
+ prerelease: false
288
+ version_requirements: !ruby/object:Gem::Requirement
289
+ requirements:
290
+ - - ">="
291
+ - !ruby/object:Gem::Version
292
+ version: '0'
279
293
  - !ruby/object:Gem::Dependency
280
294
  name: net-sftp
281
295
  requirement: !ruby/object:Gem::Requirement
@@ -610,6 +624,11 @@ files:
610
624
  - lib/multiwoven/integrations/destination/klaviyo/config/meta.json
611
625
  - lib/multiwoven/integrations/destination/klaviyo/config/spec.json
612
626
  - lib/multiwoven/integrations/destination/klaviyo/icon.svg
627
+ - lib/multiwoven/integrations/destination/mailchimp/client.rb
628
+ - lib/multiwoven/integrations/destination/mailchimp/config/catalog.json
629
+ - lib/multiwoven/integrations/destination/mailchimp/config/meta.json
630
+ - lib/multiwoven/integrations/destination/mailchimp/config/spec.json
631
+ - lib/multiwoven/integrations/destination/mailchimp/icon.svg
613
632
  - lib/multiwoven/integrations/destination/maria_db/client.rb
614
633
  - lib/multiwoven/integrations/destination/maria_db/config/meta.json
615
634
  - lib/multiwoven/integrations/destination/maria_db/config/spec.json