New Upstream Release - ruby-hangouts-chat
Ready changes
Summary
Merged new upstream version: 0.1.0 (was: 0.0.5).
Resulting package
Built on 2022-05-15T14:18 (took 3m32s)
The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:
apt install -t fresh-releases ruby-hangouts-chat
Lintian Result
Diff
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 14a43d7..f706d44 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,19 +1,32 @@
# Changelog
+## 0.1.0
+
+- Added ability to specify a thread when send messages (thanks to @hazi)
+
+## 0.0.6
+
+- Fixed proxy ENV support for ruby versions < 2.5.0
+
## 0.0.5
- * Resolved missing dependencies for development and testing
+
+- Resolved missing dependencies for development and testing
## 0.0.4
- * Added Card Messages support
+
+- Added Card Messages support
## 0.0.3
- * Added YARD documentation
- * Added HangoutsChat::Sender::APIError exception for unsuccessful responses
+
+- Added YARD documentation
+- Added HangoutsChat::Sender::APIError exception for unsuccessful responses
## 0.0.2
- * Added tests
- * Improved appearance
- * Added and performed rubocop code analyze
+
+- Added tests
+- Improved appearance
+- Added and performed rubocop code analyze
## 0.0.1
- * Initial version with Hangouts Chat simple text messages support
+
+- Initial version with Hangouts Chat simple text messages support
diff --git a/README.md b/README.md
index 6ad7cf4..c8f9095 100644
--- a/README.md
+++ b/README.md
@@ -13,11 +13,14 @@ $ gem install hangouts-chat
or add to your Gemfile
-```ruby
-require 'hangouts-chat'
+```
+gem 'hangouts-chat'
```
## Usage
+```ruby
+require 'hangouts_chat'
+```
### Simple Text Message
Simple messages that appear inline as if typed by a user. Details and format: [Simple Text Messages](https://developers.google.com/hangouts/chat/reference/message-formats/basic)
```ruby
@@ -32,12 +35,32 @@ sender = HangoutsChat::Sender.new 'webhook_URL'
header = { title: 'Pizza Bot Customer Support',
subtitle: 'pizzabot@example.com',
imageUrl: 'https://goo.gl/aeDtrS' }
-sections = [{ keyValue: { topLabel: 'Order No.', content: '12345' } },
- { keyValue: { topLabel: 'Status', content: 'In Delivery' } }]
+sections = [{ widgets: [{ keyValue: { topLabel: 'Order No.', content: '12345' } },
+ { keyValue: { topLabel: 'Status', content: 'In Delivery' } }] }]
sender.card(header, sections)
```
+### Message to thread
+
+```ruby
+# Create new thread
+sender = HangoutsChat::Sender.new 'webhook_URL'
+res = sender.simple 'text'
+
+# Response parse
+res_json = JSON.parse(res.body)
+thread_name = res_json.dig("thread", "name") #=> "spaces/SPACES_ID/threads/THREADS_ID"
+
+# Send to thread (simple)
+sender.simple('res message', thread: thread_name)
+
+# Send to thread (card)
+header = {...}
+sections = {...}
+sender.card(header, sections, thread: thread_name)
+```
+
### How to get Webhook URL
1. Open channel to which you want to send messages
2. Click on the channel name in top bar and select 'Configure webhooks'
diff --git a/debian/changelog b/debian/changelog
index 4bcffbf..0c07285 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,4 +1,4 @@
-ruby-hangouts-chat (0.0.5-3) UNRELEASED; urgency=medium
+ruby-hangouts-chat (0.1.0-1) UNRELEASED; urgency=medium
[ Utkarsh Gupta ]
* Add salsa-ci.yml
@@ -12,8 +12,9 @@ ruby-hangouts-chat (0.0.5-3) UNRELEASED; urgency=medium
+ ruby-hangouts-chat: Add :all qualifier for ruby dependency.
* Update watch file format version to 4.
* Bump debhelper from old 12 to 13.
+ * New upstream release.
- -- Utkarsh Gupta <guptautkarsh2102@gmail.com> Tue, 13 Aug 2019 05:35:29 +0530
+ -- Utkarsh Gupta <guptautkarsh2102@gmail.com> Sun, 15 May 2022 14:14:45 -0000
ruby-hangouts-chat (0.0.5-2) unstable; urgency=medium
diff --git a/debian/patches/avoid-internet.patch b/debian/patches/avoid-internet.patch
index 83e4a33..716bdab 100644
--- a/debian/patches/avoid-internet.patch
+++ b/debian/patches/avoid-internet.patch
@@ -4,8 +4,10 @@ Bug-Debian: https://bugs.debian.org/926247
Forwarded: not-needed
Date: 2019-04-05
---- ruby-hangouts-chat-0.0.5.orig/test/hangouts_chat/http_test.rb
-+++ ruby-hangouts-chat-0.0.5/test/hangouts_chat/http_test.rb
+Index: ruby-hangouts-chat/test/hangouts_chat/http_test.rb
+===================================================================
+--- ruby-hangouts-chat.orig/test/hangouts_chat/http_test.rb
++++ ruby-hangouts-chat/test/hangouts_chat/http_test.rb
@@ -18,7 +18,7 @@ class HTTPTest < Minitest::Test
assert_equal 'application/json', req['Content-Type']
end
@@ -15,8 +17,10 @@ Date: 2019-04-05
stub_request(:any, @url)
payload = 'Test text'
---- ruby-hangouts-chat-0.0.5.orig/test/hangouts_chat_test.rb
-+++ ruby-hangouts-chat-0.0.5/test/hangouts_chat_test.rb
+Index: ruby-hangouts-chat/test/hangouts_chat_test.rb
+===================================================================
+--- ruby-hangouts-chat.orig/test/hangouts_chat_test.rb
++++ ruby-hangouts-chat/test/hangouts_chat_test.rb
@@ -14,7 +14,7 @@ class HangoutsChatTest < Minitest::Test
assert_equal HangoutsChat::Sender::HTTP, http.class
end
@@ -35,8 +39,8 @@ Date: 2019-04-05
stub_request(:any, /chat\.googleapis\.com/).to_return(status: 200)
header = { title: 'Pizza Bot Customer Support',
subtitle: 'pizzabot@example.com',
-@@ -38,7 +38,7 @@ class HangoutsChatTest < Minitest::Test
- { cards: [header: header, sections: sections] }.to_json
+@@ -64,7 +64,7 @@ class HangoutsChatTest < Minitest::Test
+ { cards: [header: header, sections: sections], thread: { name: thread} }.to_json
end
- def test_api_error_exception_message
diff --git a/hangouts-chat.gemspec b/hangouts-chat.gemspec
index d76241f..e8fd57f 100644
--- a/hangouts-chat.gemspec
+++ b/hangouts-chat.gemspec
@@ -2,22 +2,22 @@
# This file has been automatically generated by gem2tgz #
#########################################################
# -*- encoding: utf-8 -*-
-# stub: hangouts-chat 0.0.5 ruby lib
+# stub: hangouts-chat 0.1.0 ruby lib
Gem::Specification.new do |s|
s.name = "hangouts-chat".freeze
- s.version = "0.0.5"
+ s.version = "0.1.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
s.require_paths = ["lib".freeze]
s.authors = ["enzinia".freeze]
- s.date = "2018-03-31"
+ s.date = "2021-02-18"
s.description = "Send messages to G Suite Hangouts Chat rooms using incoming webhooks and Net::HTTP::Post".freeze
s.email = "vkukovskij@gmail.com".freeze
s.files = ["CHANGELOG.md".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "lib/hangouts_chat.rb".freeze, "lib/hangouts_chat/exceptions.rb".freeze, "lib/hangouts_chat/http.rb".freeze, "lib/hangouts_chat/version.rb".freeze, "test/hangouts_chat/http_test.rb".freeze, "test/hangouts_chat_test.rb".freeze, "test/test_helper.rb".freeze]
s.homepage = "https://github.com/enzinia/hangouts-chat".freeze
s.licenses = ["MIT".freeze]
- s.rubygems_version = "2.7.6".freeze
+ s.rubygems_version = "2.7.6.2".freeze
s.summary = "Library for sending messages to Hangouts Chat rooms".freeze
s.test_files = ["test/hangouts_chat/http_test.rb".freeze, "test/hangouts_chat_test.rb".freeze, "test/test_helper.rb".freeze]
@@ -25,14 +25,12 @@ Gem::Specification.new do |s|
s.specification_version = 4
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
- s.add_development_dependency(%q<bundler>.freeze, ["~> 1"])
s.add_development_dependency(%q<minitest>.freeze, ["~> 5"])
s.add_development_dependency(%q<rake>.freeze, ["~> 12"])
s.add_development_dependency(%q<rubocop>.freeze, ["<= 0.54.0"])
s.add_development_dependency(%q<webmock>.freeze, ["~> 3"])
s.add_development_dependency(%q<yard>.freeze, ["> 0.9.11", "~> 0.9"])
else
- s.add_dependency(%q<bundler>.freeze, ["~> 1"])
s.add_dependency(%q<minitest>.freeze, ["~> 5"])
s.add_dependency(%q<rake>.freeze, ["~> 12"])
s.add_dependency(%q<rubocop>.freeze, ["<= 0.54.0"])
@@ -40,7 +38,6 @@ Gem::Specification.new do |s|
s.add_dependency(%q<yard>.freeze, ["> 0.9.11", "~> 0.9"])
end
else
- s.add_dependency(%q<bundler>.freeze, ["~> 1"])
s.add_dependency(%q<minitest>.freeze, ["~> 5"])
s.add_dependency(%q<rake>.freeze, ["~> 12"])
s.add_dependency(%q<rubocop>.freeze, ["<= 0.54.0"])
diff --git a/lib/hangouts_chat.rb b/lib/hangouts_chat.rb
index 8a771e3..7490f5b 100644
--- a/lib/hangouts_chat.rb
+++ b/lib/hangouts_chat.rb
@@ -18,29 +18,34 @@ module HangoutsChat
# Sends Simple Text Message
# @param text [String] text to send to room
+ # @param thread [String] it will be sent as a reply (`nil` is a new thread will be created)
# @return [Net::HTTPResponse] response object
- def simple(text)
+ def simple(text, thread: nil)
payload = { text: text }
- send_request(payload)
+ send_request(payload, thread: thread)
end
# Sends Card Message
# @since 0.0.4
# @param header [Hash] card header content
# @param sections [Array<Hash>] card widgets array
+ # @param thread [String] it will be sent as a reply (`nil` is a new thread will be created)
# @return [Net::HTTPResponse] response object
- def card(header, sections)
+ def card(header, sections, thread: nil)
payload = { cards: [header: header, sections: sections] }
- send_request(payload)
+ send_request(payload, thread: thread)
end
private
# Sends payload and check response
# @param payload [Hash] data to send by POST
+ # @param thread [String] it will be sent as a reply (`nil` is a new thread will be created)
# @return [Net::HTTPResponse] response object
# @raise [APIError] if got unsuccessful response
- def send_request(payload)
+ def send_request(payload, thread: nil)
+ payload[:thread] = { name: thread } if thread
+
response = @http.post payload
raise APIError, response unless response.is_a?(Net::HTTPSuccess)
response
diff --git a/lib/hangouts_chat/http.rb b/lib/hangouts_chat/http.rb
index f6fa406..dcf28b7 100644
--- a/lib/hangouts_chat/http.rb
+++ b/lib/hangouts_chat/http.rb
@@ -22,10 +22,9 @@ module HangoutsChat
def post(payload)
@req.body = payload.to_json
- res = Net::HTTP.start(@uri.hostname, @uri.port, use_ssl: true) do |http|
+ Net::HTTP.start(@uri.hostname, @uri.port, :ENV, use_ssl: true) do |http|
http.request(@req)
end
- res
end
end
end
diff --git a/lib/hangouts_chat/version.rb b/lib/hangouts_chat/version.rb
index fc159ce..cacef96 100644
--- a/lib/hangouts_chat/version.rb
+++ b/lib/hangouts_chat/version.rb
@@ -1,4 +1,4 @@
module HangoutsChat
# Library version
- VERSION = '0.0.5'.freeze
+ VERSION = '0.1.0'.freeze
end
diff --git a/test/hangouts_chat_test.rb b/test/hangouts_chat_test.rb
index 1c263ab..0f6f840 100644
--- a/test/hangouts_chat_test.rb
+++ b/test/hangouts_chat_test.rb
@@ -29,8 +29,8 @@ class HangoutsChatTest < Minitest::Test
header = { title: 'Pizza Bot Customer Support',
subtitle: 'pizzabot@example.com',
imageUrl: 'https://goo.gl/aeDtrS' }
- sections = [{ keyValue: { topLabel: 'Order No.', content: '12345' } },
- { keyValue: { topLabel: 'Status', content: 'In Delivery' } }]
+ sections = [{ widgets: [{ keyValue: { topLabel: 'Order No.', content: '12345' } },
+ { keyValue: { topLabel: 'Status', content: 'In Delivery' } }] }]
@sender.card(header, sections)
@@ -38,6 +38,32 @@ class HangoutsChatTest < Minitest::Test
{ cards: [header: header, sections: sections] }.to_json
end
+ def test_simple_message_threaded_request
+ stub_request(:any, /chat\.googleapis\.com/).to_return(status: 200)
+ message = 'Test simple message'
+ thread = 'spaces/space_id/threads/threads_id'
+
+ @sender.simple(message, thread: thread)
+
+ assert_requested :post, @webhook_url, times: 1, body:
+ { text: message, thread: { name: thread} }.to_json
+ end
+
+ def test_card_message_threaded_request
+ stub_request(:any, /chat\.googleapis\.com/).to_return(status: 200)
+ header = { title: 'Pizza Bot Customer Support',
+ subtitle: 'pizzabot@example.com',
+ imageUrl: 'https://goo.gl/aeDtrS' }
+ sections = [{ widgets: [{ keyValue: { topLabel: 'Order No.', content: '12345' } },
+ { keyValue: { topLabel: 'Status', content: 'In Delivery' } }] }]
+ thread = 'spaces/space_id/threads/threads_id'
+
+ @sender.card(header, sections, thread: thread)
+
+ assert_requested :post, @webhook_url, times: 1, body:
+ { cards: [header: header, sections: sections], thread: { name: thread} }.to_json
+ end
+
def test_api_error_exception_message
stub_request(:any, /chat\.googleapis\.com/)
.to_return(status: [403, 'Forbidden'], body: 'Response body')
Debdiff
[The following lists of changes regard files as different if they have different names, permissions or owners.]
Files in second set of .debs but not in first
-rw-r--r-- root/root /usr/share/rubygems-integration/all/specifications/hangouts-chat-0.1.0.gemspec
Files in first set of .debs but not in second
-rw-r--r-- root/root /usr/share/rubygems-integration/all/specifications/hangouts-chat-0.0.5.gemspec
No differences were encountered in the control files