teams_connector 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +4 -0
- data/README.md +3 -1
- data/lib/teams_connector/notification/message.rb +1 -1
- data/lib/teams_connector/notification.rb +14 -12
- data/lib/teams_connector/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab23bea9187dbc4806aeb67be1e50fb1c4ab13e70cd970e1d271d868b334f167
|
4
|
+
data.tar.gz: c5c2c7790793e887476e3695eca41e52d5b34d964b6a5a3cbe609d3aae4d2133
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d6590a7d1abc3e621ba30fa8fa542369f4963c11eb492cdbb256f3e8eeec721339de6acffec5d09ad723379b524642a28970a7d05551bd0478ec561b1f73222
|
7
|
+
data.tar.gz: c95960a2a23486a648167444617a3c1caba767ac204500f95a39c041f974244ff492fff2b39745d990958c16db8430537674321aafb9680b3a4eac7643df968d
|
data/CHANGES.md
CHANGED
data/README.md
CHANGED
@@ -27,6 +27,8 @@ Or install it yourself as:
|
|
27
27
|
## Usage
|
28
28
|
After setting up the Incoming Webhook Connector for your Microsoft Teams channel, it is as simple as configuring the channel and creating a new `TeamsConnector::Notification`.
|
29
29
|
|
30
|
+
The `channels` parameter can either be a single channel identifier or an array of multiple channel identifiers, that each will receive the notification.
|
31
|
+
|
30
32
|
```ruby
|
31
33
|
# TeamsConnector initializer
|
32
34
|
TeamsConnector.configure do |config|
|
@@ -34,7 +36,7 @@ TeamsConnector.configure do |config|
|
|
34
36
|
end
|
35
37
|
|
36
38
|
# Send a test card to your channel
|
37
|
-
TeamsConnector::Notification.new(:test_card, :channel_id).deliver_later
|
39
|
+
TeamsConnector::Notification.new(template: :test_card, channels: :channel_id).deliver_later
|
38
40
|
|
39
41
|
# Send a card with a list of facts
|
40
42
|
content = {
|
@@ -3,7 +3,7 @@ module TeamsConnector
|
|
3
3
|
attr_accessor :summary, :content
|
4
4
|
|
5
5
|
def initialize(template, summary, content = {}, channel = TeamsConnector.configuration.default)
|
6
|
-
super(template: template,
|
6
|
+
super(template: template, channels: channel)
|
7
7
|
@summary = summary
|
8
8
|
@content = content
|
9
9
|
end
|
@@ -5,11 +5,11 @@ require 'teams_connector/post_worker' if defined? Sidekiq
|
|
5
5
|
|
6
6
|
module TeamsConnector
|
7
7
|
class Notification
|
8
|
-
attr_accessor :template, :
|
8
|
+
attr_accessor :template, :channels
|
9
9
|
|
10
|
-
def initialize(template: nil,
|
10
|
+
def initialize(template: nil, channels: TeamsConnector.configuration.default)
|
11
11
|
@template = template
|
12
|
-
@
|
12
|
+
@channels = channels.instance_of?(Array) ? channels : [channels]
|
13
13
|
end
|
14
14
|
|
15
15
|
def deliver_later
|
@@ -18,17 +18,19 @@ module TeamsConnector
|
|
18
18
|
renderer = ERB.new(File.read(template_path))
|
19
19
|
renderer.location = [template_path.to_s, 0]
|
20
20
|
|
21
|
-
url = TeamsConnector.configuration.channels[@channel]
|
22
|
-
url = TeamsConnector.configuration.channels[TeamsConnector.configuration.default] if TeamsConnector.configuration.always_use_default
|
23
|
-
raise ArgumentError, "The Teams channel '#{@channel}' is not available in the configuration." if url.nil?
|
24
|
-
|
25
21
|
content = renderer.result(binding)
|
26
22
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
23
|
+
channels = TeamsConnector.configuration.always_use_default ? [TeamsConnector.configuration.default] : @channels
|
24
|
+
channels.each do |channel|
|
25
|
+
url = TeamsConnector.configuration.channels[channel]
|
26
|
+
raise ArgumentError, "The Teams channel '#{channel}' is not available in the configuration." if url.nil?
|
27
|
+
|
28
|
+
if TeamsConnector.configuration.method == :sidekiq
|
29
|
+
TeamsConnector::PostWorker.perform_async(url, content)
|
30
|
+
else
|
31
|
+
response = Net::HTTP.post(URI(url), content, { "Content-Type": "application/json" })
|
32
|
+
response.value
|
33
|
+
end
|
32
34
|
end
|
33
35
|
end
|
34
36
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: teams_connector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lucas Keune
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
11
|
+
date: 2021-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|