multiwoven-integrations 0.1.2 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/multiwoven/integrations/destination/facebook_custom_audience/config/meta.json +1 -1
- data/lib/multiwoven/integrations/destination/klaviyo/config/meta.json +1 -1
- data/lib/multiwoven/integrations/destination/salesforce_crm/config/meta.json +1 -1
- data/lib/multiwoven/integrations/destination/slack/client.rb +125 -0
- data/lib/multiwoven/integrations/destination/slack/config/catalog.json +71 -0
- data/lib/multiwoven/integrations/destination/slack/config/meta.json +14 -0
- data/lib/multiwoven/integrations/destination/slack/config/spec.json +22 -0
- data/lib/multiwoven/integrations/rollout.rb +2 -1
- data/lib/multiwoven/integrations/source/bigquery/config/meta.json +1 -1
- data/lib/multiwoven/integrations/source/redshift/config/meta.json +1 -1
- data/lib/multiwoven/integrations/source/snowflake/config/meta.json +1 -1
- data/lib/multiwoven/integrations.rb +2 -0
- data/multiwoven-integrations.gemspec +2 -0
- metadata +35 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ca3845d4b648bffe8c785fdd1cc0c206099deb7d7414700d528a25ec2fb72f9
|
4
|
+
data.tar.gz: 319139931a5c9a723a379c3aa116d3d6a825235fc6b80359abf6c19104fcc815
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5a96c27ef09fb593a0f000bbefa835fb79ec2c7876a7d84635013f757d8a31a52f7f5f32b791a9539dc6494af0092faf28ca8c13cccc1b4465e94eeba49490a
|
7
|
+
data.tar.gz: a9ddefdc6259d2d160ea118e1571ed1facc8cb39d533f490692e085a12d160b2d8ec8138ab1801353c0e31eb172111ffa51d1c49af9b1b54c9a1645b7a9315f1
|
@@ -0,0 +1,125 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Multiwoven
|
4
|
+
module Integrations
|
5
|
+
module Destination
|
6
|
+
module Slack
|
7
|
+
include Multiwoven::Integrations::Core
|
8
|
+
|
9
|
+
class Client < DestinationConnector
|
10
|
+
attr_accessor :channel_id
|
11
|
+
|
12
|
+
def check_connection(connection_config)
|
13
|
+
configure_slack(connection_config[:api_token])
|
14
|
+
client = ::Slack::Web::Client.new
|
15
|
+
client.auth_test
|
16
|
+
success_status
|
17
|
+
rescue StandardError => e
|
18
|
+
failure_status(e)
|
19
|
+
end
|
20
|
+
|
21
|
+
def discover(_connection_config = nil)
|
22
|
+
catalog = build_catalog(load_catalog_streams)
|
23
|
+
catalog.to_multiwoven_message
|
24
|
+
rescue StandardError => e
|
25
|
+
handle_exception("SLACK:DISCOVER:EXCEPTION", "error", e)
|
26
|
+
end
|
27
|
+
|
28
|
+
def write(sync_config, records, action = "create")
|
29
|
+
# Currently as we only create a message for each record in slack, we are not using actions.
|
30
|
+
# This will be changed in future.
|
31
|
+
|
32
|
+
@action = sync_config.stream.action || action
|
33
|
+
connection_config = sync_config.destination.connection_specification.with_indifferent_access
|
34
|
+
configure_slack(connection_config[:api_token])
|
35
|
+
@client = ::Slack::Web::Client.new
|
36
|
+
@channel_id = connection_config[:channel_id]
|
37
|
+
process_records(records, sync_config.stream)
|
38
|
+
rescue StandardError => e
|
39
|
+
handle_exception("SLACK:WRITE:EXCEPTION", "error", e)
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def configure_slack(api_token)
|
45
|
+
::Slack.configure do |config|
|
46
|
+
config.token = api_token
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def process_records(records, stream)
|
51
|
+
write_success = 0
|
52
|
+
write_failure = 0
|
53
|
+
records.each do |record_object|
|
54
|
+
process_record(stream, record_object.with_indifferent_access)
|
55
|
+
write_success += 1
|
56
|
+
rescue StandardError => e
|
57
|
+
write_failure += 1
|
58
|
+
handle_exception("SLACK:CRM:WRITE:EXCEPTION", "error", e)
|
59
|
+
end
|
60
|
+
tracking_message(write_success, write_failure)
|
61
|
+
end
|
62
|
+
|
63
|
+
def process_record(stream, record)
|
64
|
+
send_data_to_slack(stream[:name], record)
|
65
|
+
end
|
66
|
+
|
67
|
+
def send_data_to_slack(stream_name, record = {})
|
68
|
+
args = build_args(stream_name, record)
|
69
|
+
@client.send(stream_name, **args)
|
70
|
+
end
|
71
|
+
|
72
|
+
def build_args(stream_name, record)
|
73
|
+
case stream_name
|
74
|
+
when "chat_postMessage"
|
75
|
+
{ channel: channel_id, text: slack_code_block(record[:data]) }
|
76
|
+
else
|
77
|
+
raise "Stream name not found: #{stream_name}"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def slack_code_block(data)
|
82
|
+
longest_key = data.keys.map(&:to_s).max_by(&:length).length
|
83
|
+
table_str = "```\n"
|
84
|
+
data.each do |key, value|
|
85
|
+
table_str += "#{key.to_s.ljust(longest_key)} : #{value}\n"
|
86
|
+
end
|
87
|
+
table_str += "```"
|
88
|
+
|
89
|
+
table_str
|
90
|
+
end
|
91
|
+
|
92
|
+
def success_status
|
93
|
+
ConnectionStatus.new(status: ConnectionStatusType["succeeded"]).to_multiwoven_message
|
94
|
+
end
|
95
|
+
|
96
|
+
def failure_status(error)
|
97
|
+
ConnectionStatus.new(status: ConnectionStatusType["failed"], message: error.message).to_multiwoven_message
|
98
|
+
end
|
99
|
+
|
100
|
+
def load_catalog_streams
|
101
|
+
catalog_json = read_json(CATALOG_SPEC_PATH)
|
102
|
+
catalog_json["streams"].map { |stream| build_stream(stream) }
|
103
|
+
end
|
104
|
+
|
105
|
+
def build_stream(stream)
|
106
|
+
Multiwoven::Integrations::Protocol::Stream.new(
|
107
|
+
name: stream["name"], json_schema: stream["json_schema"],
|
108
|
+
action: stream["action"]
|
109
|
+
)
|
110
|
+
end
|
111
|
+
|
112
|
+
def build_catalog(streams)
|
113
|
+
Multiwoven::Integrations::Protocol::Catalog.new(streams: streams)
|
114
|
+
end
|
115
|
+
|
116
|
+
def tracking_message(success, failure)
|
117
|
+
Multiwoven::Integrations::Protocol::TrackingMessage.new(
|
118
|
+
success: success, failed: failure
|
119
|
+
).to_multiwoven_message
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
{
|
2
|
+
"streams": [
|
3
|
+
{
|
4
|
+
"name": "chat_postMessage",
|
5
|
+
"action": "create",
|
6
|
+
"json_schema": {
|
7
|
+
"type": "object",
|
8
|
+
"additionalProperties": false,
|
9
|
+
"properties": {
|
10
|
+
"text": {
|
11
|
+
"type": ["string", "null"]
|
12
|
+
},
|
13
|
+
"attachments": {
|
14
|
+
"type": ["string", "null"]
|
15
|
+
},
|
16
|
+
"blocks": {
|
17
|
+
"type": ["array", "null"],
|
18
|
+
"items": {
|
19
|
+
"type": "string"
|
20
|
+
}
|
21
|
+
},
|
22
|
+
"as_user": {
|
23
|
+
"type": ["boolean", "null"]
|
24
|
+
},
|
25
|
+
"icon_emoji": {
|
26
|
+
"type": ["string", "null"]
|
27
|
+
},
|
28
|
+
"icon_url": {
|
29
|
+
"type": ["string", "null"]
|
30
|
+
},
|
31
|
+
"link_names": {
|
32
|
+
"type": ["boolean", "null"]
|
33
|
+
},
|
34
|
+
"metadata": {
|
35
|
+
"type": ["string", "null"]
|
36
|
+
},
|
37
|
+
"mrkdwn": {
|
38
|
+
"type": ["boolean", "null"]
|
39
|
+
},
|
40
|
+
"parse": {
|
41
|
+
"type": ["string", "null"]
|
42
|
+
},
|
43
|
+
"reply_broadcast": {
|
44
|
+
"type": ["boolean", "null"]
|
45
|
+
},
|
46
|
+
"thread_ts": {
|
47
|
+
"type": ["string", "null"]
|
48
|
+
},
|
49
|
+
"unfurl_links": {
|
50
|
+
"type": ["boolean", "null"]
|
51
|
+
},
|
52
|
+
"unfurl_media": {
|
53
|
+
"type": ["boolean", "null"]
|
54
|
+
},
|
55
|
+
"username": {
|
56
|
+
"type": ["string", "null"]
|
57
|
+
}
|
58
|
+
},
|
59
|
+
"oneOf": [
|
60
|
+
{ "required": ["text"] },
|
61
|
+
{ "required": ["attachments"] },
|
62
|
+
{ "required": ["blocks"] }
|
63
|
+
]
|
64
|
+
},
|
65
|
+
"supported_sync_modes": ["full_refresh", "incremental"],
|
66
|
+
"source_defined_cursor": true,
|
67
|
+
"default_cursor_field": ["updated"],
|
68
|
+
"source_defined_primary_key": [["Id"]]
|
69
|
+
}
|
70
|
+
]
|
71
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
{
|
2
|
+
"data": {
|
3
|
+
"name": "Slack",
|
4
|
+
"connector_type": "destination",
|
5
|
+
"category": "Team Collaboration",
|
6
|
+
"documentation_url": "https://docs.mutliwoven.com",
|
7
|
+
"github_issue_label": "destination-slack",
|
8
|
+
"icon": "slack.svg",
|
9
|
+
"license": "MIT",
|
10
|
+
"release_stage": "alpha",
|
11
|
+
"support_level": "community",
|
12
|
+
"tags": ["language:ruby", "multiwoven"]
|
13
|
+
}
|
14
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
{
|
2
|
+
"documentation_url": "https://docs.multiwoven.com/integrations/destination/slack",
|
3
|
+
"stream_type": "static",
|
4
|
+
"connection_specification": {
|
5
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
6
|
+
"title": "Slack Destination Spec",
|
7
|
+
"type": "object",
|
8
|
+
"required": ["api_token"],
|
9
|
+
"properties": {
|
10
|
+
"api_token": {
|
11
|
+
"type": "string",
|
12
|
+
"title": "API Token",
|
13
|
+
"order": 0
|
14
|
+
},
|
15
|
+
"channel_id": {
|
16
|
+
"type": "string",
|
17
|
+
"title": "Channel ID",
|
18
|
+
"order": 1
|
19
|
+
}
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
@@ -12,6 +12,7 @@ require "uri"
|
|
12
12
|
require "active_support/core_ext/hash/indifferent_access"
|
13
13
|
require "restforce"
|
14
14
|
require "logger"
|
15
|
+
require "slack-ruby-client"
|
15
16
|
|
16
17
|
# Service
|
17
18
|
require_relative "integrations/config"
|
@@ -36,6 +37,7 @@ require_relative "integrations/source/bigquery/client"
|
|
36
37
|
require_relative "integrations/destination/klaviyo/client"
|
37
38
|
require_relative "integrations/destination/salesforce_crm/client"
|
38
39
|
require_relative "integrations/destination/facebook_custom_audience/client"
|
40
|
+
require_relative "integrations/destination/slack/client"
|
39
41
|
|
40
42
|
module Multiwoven
|
41
43
|
module Integrations
|
@@ -34,6 +34,7 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.require_paths = ["lib"]
|
35
35
|
|
36
36
|
spec.add_runtime_dependency "activesupport"
|
37
|
+
spec.add_runtime_dependency "async-websocket"
|
37
38
|
spec.add_runtime_dependency "dry-schema"
|
38
39
|
spec.add_runtime_dependency "dry-struct"
|
39
40
|
spec.add_runtime_dependency "dry-types"
|
@@ -43,6 +44,7 @@ Gem::Specification.new do |spec|
|
|
43
44
|
spec.add_runtime_dependency "restforce"
|
44
45
|
spec.add_runtime_dependency "ruby-odbc"
|
45
46
|
spec.add_runtime_dependency "sequel"
|
47
|
+
spec.add_runtime_dependency "slack-ruby-client"
|
46
48
|
|
47
49
|
spec.add_development_dependency "byebug"
|
48
50
|
spec.add_development_dependency "rspec"
|
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.6
|
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-01-
|
11
|
+
date: 2024-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: async-websocket
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: dry-schema
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,6 +164,20 @@ dependencies:
|
|
150
164
|
- - ">="
|
151
165
|
- !ruby/object:Gem::Version
|
152
166
|
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: slack-ruby-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'
|
153
181
|
- !ruby/object:Gem::Dependency
|
154
182
|
name: byebug
|
155
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -271,6 +299,10 @@ files:
|
|
271
299
|
- lib/multiwoven/integrations/destination/salesforce_crm/config/catalog.json
|
272
300
|
- lib/multiwoven/integrations/destination/salesforce_crm/config/meta.json
|
273
301
|
- lib/multiwoven/integrations/destination/salesforce_crm/config/spec.json
|
302
|
+
- lib/multiwoven/integrations/destination/slack/client.rb
|
303
|
+
- lib/multiwoven/integrations/destination/slack/config/catalog.json
|
304
|
+
- lib/multiwoven/integrations/destination/slack/config/meta.json
|
305
|
+
- lib/multiwoven/integrations/destination/slack/config/spec.json
|
274
306
|
- lib/multiwoven/integrations/protocol/protocol.json
|
275
307
|
- lib/multiwoven/integrations/protocol/protocol.rb
|
276
308
|
- lib/multiwoven/integrations/rollout.rb
|
@@ -309,7 +341,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
309
341
|
- !ruby/object:Gem::Version
|
310
342
|
version: '0'
|
311
343
|
requirements: []
|
312
|
-
rubygems_version: 3.
|
344
|
+
rubygems_version: 3.5.3
|
313
345
|
signing_key:
|
314
346
|
specification_version: 4
|
315
347
|
summary: Integration suite for open source reverse ETL platform
|