msteams_notifier 0.1.0 → 0.1.2

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: 10830e5a0ac7366da207f15ba162877a775e61e7897bbccc9a3ab90ddabf6bed
4
- data.tar.gz: 2653904423e2653e8e8e0ffa52772189af715aab2f4a00430ccf37ff04e2a0ff
3
+ metadata.gz: 1c1da52a34f03ee3f4580db528768b05f6a63de85a2b2d0d603de43d32bf6b23
4
+ data.tar.gz: 7fedc2ef893d4f047c5f15810f14c6a7502b3c07f8c22bc139d6d12720de330d
5
5
  SHA512:
6
- metadata.gz: 57f10a565247e387b35af52e30d3b4e454dce8bf31250a133a49fded60684d448cca08028754a7d02163f3f22387165fefba0d1e729ef6d67a0d7527da6496c4
7
- data.tar.gz: a61744eb03542dd94355b71de1bff48435026ee3485dd52a57a18f3d558056db2a090972ece9ea85768da90f970432367a5fc73b1a55566a59b25814a40e61b2
6
+ metadata.gz: de35a4e7cbbdbe927e3331c5c5937eace5aaefb37cd91e7a84f3118b33115e2dd737cc08ae075738ce5205f9966d577dfca262efcb7dd054edc696de33ef1384
7
+ data.tar.gz: 26bcc7a1674eb7dbc0b4ecd4c3e22feff3f6f7a4e45efdccfb2455af3c0f3dfdb3410100ae7a49711217e912c9902b8df8b1f1a998044f5bdf653270fdb36cdb
data/Gemfile CHANGED
@@ -3,4 +3,4 @@ source "https://rubygems.org"
3
3
  # Specify your gem's dependencies in msteams_notifier.gemspec
4
4
  gemspec
5
5
 
6
- gem "rake", "~> 12.0"
6
+ gem "rake", ">= 12.0"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- msteams_notifier (0.1.0)
4
+ msteams_notifier (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -13,7 +13,7 @@ PLATFORMS
13
13
 
14
14
  DEPENDENCIES
15
15
  msteams_notifier!
16
- rake (~> 12.0)
16
+ rake (>= 12.0)
17
17
 
18
18
  BUNDLED WITH
19
19
  2.1.4
@@ -1,3 +1,3 @@
1
1
  module MsteamsNotifier
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -1,20 +1,29 @@
1
1
  require "msteams_notifier/version"
2
2
  require "net/http"
3
+ require "json"
4
+
3
5
  module MsteamsNotifier
4
6
  class Error < StandardError; end
5
7
 
6
8
  class Message
7
9
 
10
+ attr_accessor :enabled, :webhook_url, :quick_title
11
+
8
12
  # A quick method to send a text notification
9
13
  def self.quick_message(message)
10
14
  notifier = MsteamsNotifier::Message.new
15
+ if !notifier.quick_title.nil? && !notifier.quick_title != ""
16
+ notifier.add_title notifier.quick_title
17
+ end
11
18
  notifier.add_text(message)
19
+
12
20
  notifier.send
13
21
  end
14
22
 
15
23
  def initialize(options={})
16
24
  @enabled = options[:enabled] || (defined?(Rails) ? Rails.application.credentials.dig(:ms_teams, :enabled).to_s == "1" : true)
17
- @webhook_url = options[:webhook_url] || (defined?(Rails) ? Rails.application.credentials.dig(:ms_teams, :webhook_url) : '')
25
+ @webhook_url = options[:webhook_url] || (defined?(Rails) ? Rails.application.credentials.dig(:ms_teams, :webhook_url) : "")
26
+ @quick_title = options[:quick_title] || (defined?(Rails) ? Rails.application.credentials.dig(:ms_teams, :quick_title) : nil)
18
27
  @items = []
19
28
  @actions = []
20
29
  end
@@ -64,10 +73,13 @@ module MsteamsNotifier
64
73
  http = Net::HTTP.new(uri.host, uri.port)
65
74
  http.use_ssl = true
66
75
  request = Net::HTTP::Post.new(uri.request_uri)
76
+ request["Content-Type"] = "application/json"
67
77
  request.body = json_payload
68
78
  response = http.request(request)
69
79
  response.is_a?(Net::HTTPSuccess)
70
- rescue
80
+ rescue => e
81
+ puts e.message
82
+ puts e.backtrace
71
83
  false
72
84
  end
73
85
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: msteams_notifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - adventistmedia
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-15 00:00:00.000000000 Z
11
+ date: 2024-08-28 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -52,7 +52,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
52
52
  - !ruby/object:Gem::Version
53
53
  version: '0'
54
54
  requirements: []
55
- rubygems_version: 3.2.10
55
+ rubygems_version: 3.4.10
56
56
  signing_key:
57
57
  specification_version: 4
58
58
  summary: Send a Microsoft Teams webhook message