rocketchat 0.1.17 → 0.1.18

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: '0296b13f4f910dc6b063a96505772863ce05b46ebf50a2766091bbd3e5de2c92'
4
- data.tar.gz: 1a0c6a828f549f57479583bd07f03a8c619d21e0fc2c256373815bdfd80915a4
3
+ metadata.gz: 2eccd5f84e40881585d0d2ce8ec0402fd48025c46278ad6cdde5e45d84f74e0a
4
+ data.tar.gz: d5dea359aedfa7f1e50153474dc5559ff330e3e5c4eea8d29621e149bff32d39
5
5
  SHA512:
6
- metadata.gz: 6c141be5cf5f3553e64fe014df2696769fd4b6adc922ca191b3538b7f39a300876d75ff0fc6712aeda0594b4c0be0d4a4c7f66a515fd1416cda614d683ac18ca
7
- data.tar.gz: 4706a56eaeddfbbd10c3757e75b7567027764ca57d0f39248d612f8ff15b2dbb8ffb8bf3792161714219ea6425340f0bada37c5438150ea6005fe24367dea009
6
+ metadata.gz: 1be0b34dbf42b24db8d6bd2f45e3724ea5e2a9f875fb26631363a659a128aa18b07127f0b584fb26055cd81da2ba1c2a20ded1bed80fbd64b2e62b2461e5fd94
7
+ data.tar.gz: 880e42339201c419097bb4738c45b2a6a0e721e05af4b248c82172de3b8bd31120eb2477ea9ed29e09b7d0d8b31581a5c3787385b07feb525a83c6fe701a425a
@@ -3,6 +3,10 @@
3
3
  ## Unreleased
4
4
  - None
5
5
 
6
+ ## [0.1.18](releases/tag/v0.1.18) - 2018-01-05
7
+ ### Added
8
+ - [#29] Support for im.create and im.counters ([@christianmoretti][])
9
+
6
10
  ## [0.1.17](releases/tag/v0.1.17) - 2019-01-05
7
11
  ### Deprecation
8
12
  - Drop Ruby 2.1 from build matrix
data/README.md CHANGED
@@ -42,6 +42,10 @@ This gem supports the following Rocket.Chat APIs (Tested against Rocket.Chat v0.
42
42
  * [/api/v1/chat.postMessage](docs/chat.md#postmessage)
43
43
  * [/api/v1/chat.update](docs/chat.md#update)
44
44
 
45
+ #### IM
46
+ * [/api/v1/im.create](docs/im.md#create)
47
+ * [/api/v1/im.counters](docs/im.md#counters)
48
+
45
49
  #### Channels
46
50
  * /api/v1/channels.archive
47
51
  * [/api/v1/channels.create](docs/channels.md#channelscreate)
@@ -1,3 +1,3 @@
1
1
  module RocketChat
2
- VERSION = '0.1.17'.freeze
2
+ VERSION = '0.1.18'.freeze
3
3
  end
@@ -0,0 +1,54 @@
1
+ module RocketChat
2
+ #
3
+ # Rocket.Chat IM Summary
4
+ #
5
+ class ImSummary
6
+ # Raw info data
7
+ attr_reader :data
8
+
9
+ #
10
+ # @param [Hash] data Raw info data
11
+ #
12
+ def initialize(data)
13
+ @data = Util.stringify_hash_keys data
14
+ end
15
+
16
+ def joined
17
+ data['joined']
18
+ end
19
+
20
+ # Qty of menbers in the chat
21
+ def members
22
+ data['members']
23
+ end
24
+
25
+ # Qty of unread messages
26
+ def unreads
27
+ data['unreads']
28
+ end
29
+
30
+ # Timestamp
31
+ def unreads_from
32
+ data['unreadsFrom']
33
+ end
34
+
35
+ # Qty of messages in the chat
36
+ def msgs
37
+ data['msgs']
38
+ end
39
+
40
+ # Last message sent
41
+ def latest
42
+ data['latest']
43
+ end
44
+
45
+ # Qty of mentions
46
+ def user_mentions
47
+ data['userMentions']
48
+ end
49
+
50
+ def success
51
+ data['success']
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,52 @@
1
+ module RocketChat
2
+ module Messages
3
+ #
4
+ # Rocket.Chat Direct messages
5
+ #
6
+ class Im
7
+ #
8
+ # @param [Session] session Session
9
+ #
10
+ def initialize(session)
11
+ @session = session
12
+ end
13
+
14
+ #
15
+ # im.create REST API
16
+ # @param [String] username Rocket.Chat username
17
+ # @return [RocketChat::Room]
18
+ # @raise [HTTPError, StatusError]
19
+ #
20
+ def create(username:)
21
+ response = session.request_json(
22
+ '/api/v1/im.create',
23
+ method: :post,
24
+ body: { username: username }
25
+ )
26
+ RocketChat::Room.new response['room']
27
+ end
28
+
29
+ #
30
+ # im.counters REST API
31
+ # @param [String] room_id Rocket.Chat roomId
32
+ # @param [String] username Rocket.Chat username
33
+ # @return [RocketChat::ImSummary]
34
+ # @raise [HTTPError, StatusError]
35
+ #
36
+ def counters(room_id:, username: nil)
37
+ response = session.request_json(
38
+ '/api/v1/im.counters',
39
+ body: {
40
+ roomId: room_id,
41
+ username: username
42
+ }
43
+ )
44
+ RocketChat::ImSummary.new response
45
+ end
46
+
47
+ private
48
+
49
+ attr_reader :session
50
+ end
51
+ end
52
+ end
@@ -58,6 +58,10 @@ module RocketChat
58
58
  @chat ||= RocketChat::Messages::Chat.new(self)
59
59
  end
60
60
 
61
+ def im
62
+ @im ||= RocketChat::Messages::Im.new(self)
63
+ end
64
+
61
65
  #
62
66
  # Settings messages proxy
63
67
  # @return [Messages::Settings]
@@ -16,6 +16,7 @@ require 'rocket_chat/messages/room'
16
16
  require 'rocket_chat/messages/channel'
17
17
  require 'rocket_chat/messages/group'
18
18
  require 'rocket_chat/messages/chat'
19
+ require 'rocket_chat/messages/im'
19
20
 
20
21
  require 'rocket_chat/server'
21
22
  require 'rocket_chat/session'
@@ -25,3 +26,4 @@ require 'rocket_chat/presence_status'
25
26
  require 'rocket_chat/room'
26
27
  require 'rocket_chat/user'
27
28
  require 'rocket_chat/message'
29
+ require 'rocket_chat/im_summary'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rocketchat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.17
4
+ version: 0.1.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - int512
@@ -149,11 +149,13 @@ files:
149
149
  - bin/console
150
150
  - lib/rocket_chat/error.rb
151
151
  - lib/rocket_chat/gem_version.rb
152
+ - lib/rocket_chat/im_summary.rb
152
153
  - lib/rocket_chat/info.rb
153
154
  - lib/rocket_chat/message.rb
154
155
  - lib/rocket_chat/messages/channel.rb
155
156
  - lib/rocket_chat/messages/chat.rb
156
157
  - lib/rocket_chat/messages/group.rb
158
+ - lib/rocket_chat/messages/im.rb
157
159
  - lib/rocket_chat/messages/list_support.rb
158
160
  - lib/rocket_chat/messages/room.rb
159
161
  - lib/rocket_chat/messages/room_support.rb