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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 40959c6f8d45faa4aa12b64948404cc58fcb6d382088a0d62a1407256472892b
4
- data.tar.gz: 02cc425ed3911368332604643bb923423b22349c4934567395655312590b7dd9
3
+ metadata.gz: ab23bea9187dbc4806aeb67be1e50fb1c4ab13e70cd970e1d271d868b334f167
4
+ data.tar.gz: c5c2c7790793e887476e3695eca41e52d5b34d964b6a5a3cbe609d3aae4d2133
5
5
  SHA512:
6
- metadata.gz: 2687ee07637e06bd3fb52bd4bdef9c9997ab1fc37e8736d0eaa54879d726f254053b796f0e4552b222127b7b8d97c5feaf73c1774dffa35fe1e33a009660e0fa
7
- data.tar.gz: 841a4a799f57f98adf218fec0b555d13028412ade5a59438a0ff9ef5d8f7859d11f82f10587f9b47faddb3042b3f2c5cd9f83d51b68eefad4d6dbdb1051b3866
6
+ metadata.gz: 4d6590a7d1abc3e621ba30fa8fa542369f4963c11eb492cdbb256f3e8eeec721339de6acffec5d09ad723379b524642a28970a7d05551bd0478ec561b1f73222
7
+ data.tar.gz: c95960a2a23486a648167444617a3c1caba767ac204500f95a39c041f974244ff492fff2b39745d990958c16db8430537674321aafb9680b3a4eac7643df968d
data/CHANGES.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Teams Connector Changelog
2
2
 
3
+ 0.1.3
4
+ ---
5
+ - Allow sending a notification to multiple channels at the same time
6
+
3
7
  0.1.2
4
8
  ---
5
9
  - Use `TeamsConnector::Configuration#load_from_rails_credentials` to load encrypted channel URLs in your Rails environment
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, channel: channel)
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, :channel
8
+ attr_accessor :template, :channels
9
9
 
10
- def initialize(template: nil, channel: TeamsConnector.configuration.default)
10
+ def initialize(template: nil, channels: TeamsConnector.configuration.default)
11
11
  @template = template
12
- @channel = channel
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
- if TeamsConnector.configuration.method == :sidekiq
28
- TeamsConnector::PostWorker.perform_async(url, content)
29
- else
30
- response = Net::HTTP.post(URI(url), content, { "Content-Type": "application/json" })
31
- response.value
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
 
@@ -1,3 +1,3 @@
1
1
  module TeamsConnector
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
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.2
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-16 00:00:00.000000000 Z
11
+ date: 2021-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler