rocketchat 0.1.15 → 0.1.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.rubocop.yml +60 -3
- data/.travis.yml +18 -6
- data/CHANGELOG.md +117 -0
- data/Gemfile +2 -0
- data/LICENSE +1 -1
- data/README.md +15 -7
- data/Rakefile +2 -0
- data/bin/console +1 -0
- data/lib/rocket_chat/error.rb +6 -0
- data/lib/rocket_chat/gem_version.rb +3 -1
- data/lib/rocket_chat/im_summary.rb +56 -0
- data/lib/rocket_chat/info.rb +2 -0
- data/lib/rocket_chat/message.rb +2 -0
- data/lib/rocket_chat/messages/channel.rb +18 -0
- data/lib/rocket_chat/messages/chat.rb +2 -0
- data/lib/rocket_chat/messages/group.rb +2 -0
- data/lib/rocket_chat/messages/im.rb +54 -0
- data/lib/rocket_chat/messages/list_support.rb +2 -0
- data/lib/rocket_chat/messages/room.rb +24 -1
- data/lib/rocket_chat/messages/room_support.rb +2 -0
- data/lib/rocket_chat/messages/settings.rb +2 -0
- data/lib/rocket_chat/messages/user.rb +4 -2
- data/lib/rocket_chat/messages/user_support.rb +2 -0
- data/lib/rocket_chat/presence_status.rb +2 -0
- data/lib/rocket_chat/request_helper.rb +6 -2
- data/lib/rocket_chat/room.rb +2 -0
- data/lib/rocket_chat/server.rb +2 -0
- data/lib/rocket_chat/session.rb +6 -0
- data/lib/rocket_chat/token.rb +2 -0
- data/lib/rocket_chat/user.rb +7 -0
- data/lib/rocket_chat/util.rb +4 -3
- data/lib/rocketchat.rb +4 -0
- data/rocketchat.gemspec +12 -5
- metadata +85 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b5f446da6cb7e901ef27edc15d4294fdb1db3a7c6386c35aeec2acbf513a2246
|
4
|
+
data.tar.gz: 19bda5415f803dd4a7cf7bc05ec2ec1fcf925d364e55068f0d7630d28e5da190
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9c94588357cbeb32f18afe79b3439bded7fc8191b31627a440288642842d971119591cdf47e981836c7ea8b3d4ff76ed36040701b6c0fb24d33e9e7a349ef1a
|
7
|
+
data.tar.gz: b14f92c34a2b9a6f17d4da573b793268b3c8f83590326b5faca1e1d6b0b4ebba5bbdea73c1ea5bcc406aa5a729988ac6eb230359f1fbbb8de23b2694b60bc652
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,16 +1,73 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-performance
|
3
|
+
- rubocop-rake
|
4
|
+
- rubocop-rspec
|
5
|
+
|
6
|
+
AllCops:
|
7
|
+
NewCops: enable
|
8
|
+
TargetRubyVersion: 2.5
|
9
|
+
|
10
|
+
Layout/EmptyLinesAroundAttributeAccessor:
|
11
|
+
Enabled: true
|
12
|
+
|
13
|
+
Layout/LineLength:
|
14
|
+
Max: 120
|
15
|
+
|
16
|
+
Layout/SpaceAroundMethodCallOperator:
|
17
|
+
Enabled: true
|
18
|
+
|
19
|
+
Lint/DeprecatedOpenSSLConstant:
|
20
|
+
Enabled: true
|
21
|
+
|
22
|
+
Lint/MixedRegexpCaptureTypes:
|
23
|
+
Enabled: true
|
24
|
+
|
25
|
+
Lint/RaiseException:
|
26
|
+
Enabled: true
|
27
|
+
|
28
|
+
Lint/StructNewOverride:
|
29
|
+
Enabled: true
|
30
|
+
|
1
31
|
Metrics/BlockLength:
|
2
32
|
Exclude:
|
3
33
|
- "**/*_spec.rb"
|
4
34
|
- "spec/shared/*.rb"
|
5
35
|
|
6
|
-
Metrics/LineLength:
|
7
|
-
Max: 120
|
8
|
-
|
9
36
|
Metrics/MethodLength:
|
10
37
|
Max: 15
|
11
38
|
Exclude:
|
12
39
|
- "**/*_spec.rb"
|
13
40
|
|
41
|
+
RSpec/ExampleLength:
|
42
|
+
Max: 10
|
43
|
+
|
44
|
+
RSpec/MultipleExpectations:
|
45
|
+
Max: 5
|
46
|
+
|
47
|
+
RSpec/MultipleMemoizedHelpers:
|
48
|
+
Max: 15
|
49
|
+
|
50
|
+
Style/ExponentialNotation:
|
51
|
+
Enabled: true
|
52
|
+
|
53
|
+
Style/HashEachMethods:
|
54
|
+
Enabled: true
|
55
|
+
|
56
|
+
Style/HashTransformKeys:
|
57
|
+
Enabled: true
|
58
|
+
|
59
|
+
Style/HashTransformValues:
|
60
|
+
Enabled: true
|
61
|
+
|
14
62
|
Style/NumericLiterals:
|
15
63
|
Exclude:
|
16
64
|
- "**/*_spec.rb"
|
65
|
+
|
66
|
+
Style/RedundantRegexpCharacterClass:
|
67
|
+
Enabled: true
|
68
|
+
|
69
|
+
Style/RedundantRegexpEscape:
|
70
|
+
Enabled: true
|
71
|
+
|
72
|
+
Style/SlicingWithRange:
|
73
|
+
Enabled: true
|
data/.travis.yml
CHANGED
@@ -1,10 +1,14 @@
|
|
1
|
+
env:
|
2
|
+
global:
|
3
|
+
- CC_TEST_REPORTER_ID=abf0a371ff8851f13b563671914b195bb46f0997f0f93142e666d9acad08e22f
|
4
|
+
|
1
5
|
language: ruby
|
6
|
+
|
2
7
|
rvm:
|
3
|
-
- 2.
|
4
|
-
- 2.
|
5
|
-
- 2.
|
6
|
-
-
|
7
|
-
- 2.4
|
8
|
+
- 2.5
|
9
|
+
- 2.6
|
10
|
+
- 2.7
|
11
|
+
- 3.0
|
8
12
|
|
9
13
|
before_install:
|
10
14
|
- gem update bundler
|
@@ -13,6 +17,14 @@ install:
|
|
13
17
|
- bundle install --jobs=3 --retry=3
|
14
18
|
- gem install rubocop
|
15
19
|
|
20
|
+
before_script:
|
21
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
22
|
+
- chmod +x ./cc-test-reporter
|
23
|
+
- ./cc-test-reporter before-build
|
24
|
+
|
16
25
|
script:
|
17
|
-
- rubocop
|
26
|
+
- bundle exec rubocop
|
18
27
|
- bundle exec rake
|
28
|
+
|
29
|
+
after_script:
|
30
|
+
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## Unreleased
|
4
|
+
- None
|
5
|
+
|
6
|
+
## [0.1.20](releases/tag/v0.1.20) - 2021-03-29
|
7
|
+
### Added
|
8
|
+
- [#34] Support for channels.members and groups.members ([@alinavancea][])
|
9
|
+
|
10
|
+
### Deprecation
|
11
|
+
- [#35] Drop Ruby 2.3 and 2.4 support ([@abrom][])
|
12
|
+
|
13
|
+
## [0.1.19](releases/tag/v0.1.19) - 2019-03-01
|
14
|
+
### Fixed
|
15
|
+
- Address CVE-2020-8130 - `rake` OS command injection vulnerability ([@abrom][])
|
16
|
+
|
17
|
+
## [0.1.18](releases/tag/v0.1.18) - 2018-01-05
|
18
|
+
### Added
|
19
|
+
- [#29] Support for im.create and im.counters ([@christianmoretti][])
|
20
|
+
|
21
|
+
## [0.1.17](releases/tag/v0.1.17) - 2019-01-05
|
22
|
+
### Deprecation
|
23
|
+
- Drop Ruby 2.1 from build matrix ([@abrom][])
|
24
|
+
|
25
|
+
## [0.1.16](releases/tag/v0.1.16) - 2018-10-3
|
26
|
+
### Deprecation
|
27
|
+
- Drop Ruby 2.0 from build matrix ([@abrom][])
|
28
|
+
|
29
|
+
### Added
|
30
|
+
- [#27] Support for channels.online ([@chrisstime][])
|
31
|
+
- [#28] `rubocop-rspec` dependency and fixed new lints ([@abrom][])
|
32
|
+
|
33
|
+
## [0.1.15](releases/tag/v0.1.15) - 2017-12-21
|
34
|
+
### Fixed
|
35
|
+
- Updated yard to resolve potential security vulnerability ([@abrom][])
|
36
|
+
|
37
|
+
## [0.1.14](releases/tag/v0.1.14) - 2017-10-9
|
38
|
+
### Added
|
39
|
+
- [#19] Room/channel kick function ([@hardik127][])
|
40
|
+
|
41
|
+
## [0.1.13](releases/tag/v0.1.13) - 2017-10-9
|
42
|
+
### Added
|
43
|
+
- Support for channel/group addAll endpoint ([@abrom][])
|
44
|
+
|
45
|
+
## [0.1.12](releases/tag/v0.1.12) - 2017-08-28
|
46
|
+
### Fixed
|
47
|
+
- GET request parameter encoding ([@abrom][])
|
48
|
+
|
49
|
+
## [0.1.11](releases/tag/v0.1.11) - 2017-08-22
|
50
|
+
### Fixed
|
51
|
+
- [#15] Response parser improvements ([@reist][],[@danischreiber][])
|
52
|
+
- [#17] Fixed a missing dependency issue with `net/http` ([@abrom][])
|
53
|
+
|
54
|
+
### Added
|
55
|
+
- [#14] Add/remove moderator from room ([@danischreiber][])
|
56
|
+
|
57
|
+
## [0.1.10](releases/tag/v0.1.10) - 2017-07-31
|
58
|
+
### Added
|
59
|
+
- [#13] Allow query to be passed through for `list` requests ([@danischreiber][])
|
60
|
+
|
61
|
+
## [0.1.9](releases/tag/v0.1.9) - 2017-07-16
|
62
|
+
### Fixed
|
63
|
+
- Update chat message handlers to support Ruby 2.0 ([@abrom][])
|
64
|
+
|
65
|
+
## [0.1.8](releases/tag/v0.1.8) - 2017-07-16
|
66
|
+
### Added
|
67
|
+
- Messages chat API support ([@abrom][])
|
68
|
+
|
69
|
+
## [0.1.7](releases/tag/v0.1.7) - 2017-07-16
|
70
|
+
### Added
|
71
|
+
- [#10] Archive/unarchive room support ([@danischreiber][])
|
72
|
+
|
73
|
+
## [0.1.6](releases/tag/v0.1.6) - 2017-07-12
|
74
|
+
### Added
|
75
|
+
- [#8] Various channel/group (room) API support ([@reist][],[@danischreiber][])
|
76
|
+
|
77
|
+
## [0.1.5](releases/tag/v0.1.5) - 2017-07-9
|
78
|
+
### Added
|
79
|
+
- [#6] User createToken and resetAvatar endpoints ([@reist][])
|
80
|
+
- [#7] Support for debugging server calls ([@reist][])
|
81
|
+
|
82
|
+
## [0.1.4](releases/tag/v0.1.4) - 2017-07-9
|
83
|
+
### Fixed
|
84
|
+
- Fixed a missing dependency issue with `uri` ([@abrom][])
|
85
|
+
|
86
|
+
## [0.1.2](releases/tag/v0.1.2) - 2017-05-24
|
87
|
+
### Added
|
88
|
+
- [#3] Initial support for 'Room' endpoints ([@reist][])
|
89
|
+
|
90
|
+
## [0.1.1](releases/tag/v0.1.1) - 2017-05-1
|
91
|
+
### Added
|
92
|
+
- Support for settings get/set endpoints ([@abrom][])
|
93
|
+
|
94
|
+
## [0.0.8](releases/tag/v0.0.8) - 2017-04-30
|
95
|
+
### Added
|
96
|
+
- Support for Users `getPresence` endpoint ([@abrom][])
|
97
|
+
|
98
|
+
## [0.0.7](releases/tag/v0.0.7) - 2017-04-30
|
99
|
+
### Added
|
100
|
+
- Support for Users `list` endpoint ([@abrom][])
|
101
|
+
|
102
|
+
## [0.0.6](releases/tag/v0.0.6) - 2017-04-25
|
103
|
+
### Fixed
|
104
|
+
- [#2] Allow requests to include server options ([@reist][])
|
105
|
+
|
106
|
+
## [0.0.5](releases/tag/v0.0.5) - 2017-04-25
|
107
|
+
### Added
|
108
|
+
- [#1] Added Users `info` and `delete` endpoints ([@reist][])
|
109
|
+
|
110
|
+
[@abrom]: https://github.com/abrom
|
111
|
+
[@reist]: https://github.com/reist
|
112
|
+
[@danischreiber]: https://github.com/danischreiber
|
113
|
+
[@hardik127]: https://github.com/hardik127
|
114
|
+
[@chrisstime]: https://github.com/chrisstime
|
115
|
+
[@christianmoretti]: https://github.com/christianmoretti
|
116
|
+
[@alinavancea]: https://github.com/alinavancea
|
117
|
+
|
data/Gemfile
CHANGED
data/LICENSE
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
MIT License
|
2
2
|
|
3
3
|
Copyright (c) 2016 int512
|
4
|
-
Copyright (c)
|
4
|
+
Copyright (c) 2019 Andrew Bromwich
|
5
5
|
|
6
6
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
7
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
[![Travis Build Status](http://img.shields.io/travis/abrom/rocketchat-ruby.svg?style=flat)](https://travis-ci.org/abrom/rocketchat-ruby)
|
2
|
-
[![
|
2
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/9de85764122a44a14c22/maintainability)](https://codeclimate.com/github/abrom/rocketchat-ruby/maintainability)
|
3
|
+
[![Test Coverage](https://api.codeclimate.com/v1/badges/9de85764122a44a14c22/test_coverage)](https://codeclimate.com/github/abrom/rocketchat-ruby/test_coverage)
|
3
4
|
[![Gem Version](http://img.shields.io/gem/v/rocketchat.svg?style=flat)](#)
|
4
5
|
|
5
6
|
# Rocket.Chat REST API for Ruby
|
@@ -31,15 +32,19 @@ This gem supports the following Rocket.Chat APIs (Tested against Rocket.Chat v0.
|
|
31
32
|
* [/api/v1/info](#info)
|
32
33
|
|
33
34
|
#### Authentication
|
34
|
-
* [/api/v1/login](#
|
35
|
-
* [/api/v1/logout](#
|
35
|
+
* [/api/v1/login](docs/authentication.md#login)
|
36
|
+
* [/api/v1/logout](docs/authentication.md#logout)
|
36
37
|
* /api/v1/me
|
37
38
|
|
38
39
|
#### Chat
|
39
|
-
* /api/v1/chat.delete
|
40
|
-
* /api/v1/chat.getMessage
|
41
|
-
* /api/v1/chat.postMessage
|
42
|
-
* /api/v1/chat.update
|
40
|
+
* [/api/v1/chat.delete](docs/chat.md#delete)
|
41
|
+
* [/api/v1/chat.getMessage](docs/chat.md#getmessage)
|
42
|
+
* [/api/v1/chat.postMessage](docs/chat.md#postmessage)
|
43
|
+
* [/api/v1/chat.update](docs/chat.md#update)
|
44
|
+
|
45
|
+
#### IM
|
46
|
+
* [/api/v1/im.create](docs/im.md#create)
|
47
|
+
* [/api/v1/im.counters](docs/im.md#counters)
|
43
48
|
|
44
49
|
#### Channels
|
45
50
|
* /api/v1/channels.archive
|
@@ -62,6 +67,8 @@ This gem supports the following Rocket.Chat APIs (Tested against Rocket.Chat v0.
|
|
62
67
|
* [/api/v1/channels.setReadOnly](docs/channels.md#channelsset_attr)
|
63
68
|
* [/api/v1/channels.setTopic](docs/channels.md#channelsset_attr)
|
64
69
|
* [/api/v1/channels.setType](docs/channels.md#channelsset_attr)
|
70
|
+
* [/api/v1/channels.online](docs/channels.md#channelsonline)
|
71
|
+
* [/api/v1/channels.members](docs/channels.md#channelsmembers)
|
65
72
|
* /api/v1/channels.unarchive
|
66
73
|
|
67
74
|
#### Groups
|
@@ -83,6 +90,7 @@ This gem supports the following Rocket.Chat APIs (Tested against Rocket.Chat v0.
|
|
83
90
|
* /api/v1/groups.setReadOnly
|
84
91
|
* /api/v1/groups.setTopic
|
85
92
|
* /api/v1/groups.setType
|
93
|
+
* [/api/v1/groups.members](docs/groups.md#groupsmembers)
|
86
94
|
* /api/v1/groups.unarchive
|
87
95
|
|
88
96
|
#### Users
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
data/lib/rocket_chat/error.rb
CHANGED
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RocketChat
|
4
|
+
#
|
5
|
+
# Rocket.Chat IM Summary
|
6
|
+
#
|
7
|
+
class ImSummary
|
8
|
+
# Raw info data
|
9
|
+
attr_reader :data
|
10
|
+
|
11
|
+
#
|
12
|
+
# @param [Hash] data Raw info data
|
13
|
+
#
|
14
|
+
def initialize(data)
|
15
|
+
@data = Util.stringify_hash_keys data
|
16
|
+
end
|
17
|
+
|
18
|
+
def joined
|
19
|
+
data['joined']
|
20
|
+
end
|
21
|
+
|
22
|
+
# Qty of members in the chat
|
23
|
+
def members
|
24
|
+
data['members']
|
25
|
+
end
|
26
|
+
|
27
|
+
# Qty of unread messages
|
28
|
+
def unreads
|
29
|
+
data['unreads']
|
30
|
+
end
|
31
|
+
|
32
|
+
# Timestamp
|
33
|
+
def unreads_from
|
34
|
+
data['unreadsFrom']
|
35
|
+
end
|
36
|
+
|
37
|
+
# Qty of messages in the chat
|
38
|
+
def msgs
|
39
|
+
data['msgs']
|
40
|
+
end
|
41
|
+
|
42
|
+
# Last message sent
|
43
|
+
def latest
|
44
|
+
data['latest']
|
45
|
+
end
|
46
|
+
|
47
|
+
# Qty of mentions
|
48
|
+
def user_mentions
|
49
|
+
data['userMentions']
|
50
|
+
end
|
51
|
+
|
52
|
+
def success
|
53
|
+
data['success']
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/rocket_chat/info.rb
CHANGED
data/lib/rocket_chat/message.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RocketChat
|
2
4
|
module Messages
|
3
5
|
#
|
@@ -5,6 +7,7 @@ module RocketChat
|
|
5
7
|
#
|
6
8
|
class Channel < Room
|
7
9
|
include ListSupport
|
10
|
+
include UserSupport
|
8
11
|
|
9
12
|
#
|
10
13
|
# channels.join REST API
|
@@ -40,6 +43,21 @@ module RocketChat
|
|
40
43
|
response['channels'].map { |hash| RocketChat::Room.new hash } if response['success']
|
41
44
|
end
|
42
45
|
|
46
|
+
#
|
47
|
+
# channels.online REST API
|
48
|
+
# @param [String] room_id Rocket.Chat room id
|
49
|
+
# @return [Users[]]
|
50
|
+
# @raise [HTTPError, StatusError]
|
51
|
+
#
|
52
|
+
def online(room_id: nil, name: nil)
|
53
|
+
response = session.request_json(
|
54
|
+
'/api/v1/channels.online',
|
55
|
+
body: room_params(room_id, name)
|
56
|
+
)
|
57
|
+
|
58
|
+
response['online'].map { |hash| RocketChat::User.new hash } if response['success']
|
59
|
+
end
|
60
|
+
|
43
61
|
# Keys for set_attr:
|
44
62
|
# * [String] description A room's description
|
45
63
|
# * [String] join_code Code to join a channel
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RocketChat
|
4
|
+
module Messages
|
5
|
+
#
|
6
|
+
# Rocket.Chat Direct messages
|
7
|
+
#
|
8
|
+
class Im
|
9
|
+
#
|
10
|
+
# @param [Session] session Session
|
11
|
+
#
|
12
|
+
def initialize(session)
|
13
|
+
@session = session
|
14
|
+
end
|
15
|
+
|
16
|
+
#
|
17
|
+
# im.create REST API
|
18
|
+
# @param [String] username Rocket.Chat username
|
19
|
+
# @return [RocketChat::Room]
|
20
|
+
# @raise [HTTPError, StatusError]
|
21
|
+
#
|
22
|
+
def create(username:)
|
23
|
+
response = session.request_json(
|
24
|
+
'/api/v1/im.create',
|
25
|
+
method: :post,
|
26
|
+
body: { username: username }
|
27
|
+
)
|
28
|
+
RocketChat::Room.new response['room']
|
29
|
+
end
|
30
|
+
|
31
|
+
#
|
32
|
+
# im.counters REST API
|
33
|
+
# @param [String] room_id Rocket.Chat roomId
|
34
|
+
# @param [String] username Rocket.Chat username
|
35
|
+
# @return [RocketChat::ImSummary]
|
36
|
+
# @raise [HTTPError, StatusError]
|
37
|
+
#
|
38
|
+
def counters(room_id:, username: nil)
|
39
|
+
response = session.request_json(
|
40
|
+
'/api/v1/im.counters',
|
41
|
+
body: {
|
42
|
+
roomId: room_id,
|
43
|
+
username: username
|
44
|
+
}
|
45
|
+
)
|
46
|
+
RocketChat::ImSummary.new response
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
attr_reader :session
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RocketChat
|
2
4
|
module Messages
|
3
5
|
#
|
@@ -9,9 +11,11 @@ module RocketChat
|
|
9
11
|
|
10
12
|
def self.inherited(subclass)
|
11
13
|
field = subclass.name.split('::')[-1].downcase
|
12
|
-
collection = field
|
14
|
+
collection = "#{field}s"
|
13
15
|
subclass.send(:define_singleton_method, :field) { field }
|
14
16
|
subclass.send(:define_singleton_method, :collection) { collection }
|
17
|
+
|
18
|
+
super
|
15
19
|
end
|
16
20
|
|
17
21
|
#
|
@@ -281,6 +285,25 @@ module RocketChat
|
|
281
285
|
)['success']
|
282
286
|
end
|
283
287
|
|
288
|
+
#
|
289
|
+
# *.members* REST API
|
290
|
+
# @param [String] room_id Rocket.Chat room id
|
291
|
+
# @param [String] name Rocket.Chat room name
|
292
|
+
# @param [Integer] offset Query offset
|
293
|
+
# @param [Integer] count Query count/limit
|
294
|
+
# @param [Hash] sort Query field sort hash. eg `{ msgs: 1, name: -1 }`
|
295
|
+
# @return [Users[]]
|
296
|
+
# @raise [HTTPError, StatusError]
|
297
|
+
#
|
298
|
+
def members(room_id: nil, name: nil, offset: nil, count: nil, sort: nil)
|
299
|
+
response = session.request_json(
|
300
|
+
self.class.api_path('members'),
|
301
|
+
body: room_params(room_id, name).merge(build_list_body(offset, count, sort, nil, nil))
|
302
|
+
)
|
303
|
+
|
304
|
+
response['members'].map { |hash| RocketChat::User.new hash } if response['success']
|
305
|
+
end
|
306
|
+
|
284
307
|
private
|
285
308
|
|
286
309
|
attr_reader :session
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RocketChat
|
2
4
|
module Messages
|
3
5
|
#
|
@@ -67,7 +69,7 @@ module RocketChat
|
|
67
69
|
method: :post,
|
68
70
|
body: {
|
69
71
|
userId: id,
|
70
|
-
data: user_option_hash(options, true)
|
72
|
+
data: user_option_hash(options, include_personal_fields: true)
|
71
73
|
}
|
72
74
|
)
|
73
75
|
RocketChat::User.new response['user']
|
@@ -177,7 +179,7 @@ module RocketChat
|
|
177
179
|
|
178
180
|
attr_reader :session
|
179
181
|
|
180
|
-
def user_option_hash(options, include_personal_fields
|
182
|
+
def user_option_hash(options, include_personal_fields: false)
|
181
183
|
args = [options, :active, :roles, :join_default_channels, :require_password_change,
|
182
184
|
:send_welcome_email, :verified, :custom_fields]
|
183
185
|
args += %i[username email name password] if include_personal_fields
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'uri'
|
2
4
|
require 'openssl'
|
3
5
|
require 'net/http'
|
@@ -30,7 +32,7 @@ module RocketChat
|
|
30
32
|
check_response response, fail_unless_ok
|
31
33
|
|
32
34
|
response_json = parse_response(response.body)
|
33
|
-
options[:debug]
|
35
|
+
options[:debug]&.puts("Response: #{response_json.inspect}")
|
34
36
|
check_response_json response_json, upstreamed_errors
|
35
37
|
|
36
38
|
response_json
|
@@ -56,6 +58,7 @@ module RocketChat
|
|
56
58
|
|
57
59
|
def check_response(response, fail_unless_ok)
|
58
60
|
return if response.is_a?(Net::HTTPOK) || !(fail_unless_ok || response.is_a?(Net::HTTPServerError))
|
61
|
+
|
59
62
|
raise RocketChat::HTTPError, "Invalid http response code: #{response.code}"
|
60
63
|
end
|
61
64
|
|
@@ -81,6 +84,7 @@ module RocketChat
|
|
81
84
|
end
|
82
85
|
|
83
86
|
return unless headers
|
87
|
+
|
84
88
|
headers = Util.stringify_hash_keys headers
|
85
89
|
headers.delete_if { |key, value| key.nil? || value.nil? }
|
86
90
|
end
|
@@ -107,7 +111,7 @@ module RocketChat
|
|
107
111
|
add_body(req, body) if body
|
108
112
|
else
|
109
113
|
uri = path
|
110
|
-
uri +=
|
114
|
+
uri += "?#{body.map { |k, v| "#{k}=#{v}" }.join('&')}" if body
|
111
115
|
req = Net::HTTP::Get.new(uri, headers)
|
112
116
|
end
|
113
117
|
|
data/lib/rocket_chat/room.rb
CHANGED
data/lib/rocket_chat/server.rb
CHANGED
data/lib/rocket_chat/session.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RocketChat
|
2
4
|
#
|
3
5
|
# Rocket.Chat Session
|
@@ -58,6 +60,10 @@ module RocketChat
|
|
58
60
|
@chat ||= RocketChat::Messages::Chat.new(self)
|
59
61
|
end
|
60
62
|
|
63
|
+
def im
|
64
|
+
@im ||= RocketChat::Messages::Im.new(self)
|
65
|
+
end
|
66
|
+
|
61
67
|
#
|
62
68
|
# Settings messages proxy
|
63
69
|
# @return [Messages::Settings]
|
data/lib/rocket_chat/token.rb
CHANGED
data/lib/rocket_chat/user.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RocketChat
|
2
4
|
#
|
3
5
|
# Rocket.Chat User
|
@@ -63,6 +65,11 @@ module RocketChat
|
|
63
65
|
data['active']
|
64
66
|
end
|
65
67
|
|
68
|
+
# User roles
|
69
|
+
def roles
|
70
|
+
data['roles']
|
71
|
+
end
|
72
|
+
|
66
73
|
def inspect
|
67
74
|
format(
|
68
75
|
'#<%<class_name>s:0x%<object_id>p @id="%<id>s" @username="%<username>s" @active="%<active>s">',
|
data/lib/rocket_chat/util.rb
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RocketChat
|
2
4
|
#
|
3
5
|
# Rocket.Chat generic utility functions
|
4
6
|
#
|
5
7
|
module Util
|
8
|
+
module_function
|
9
|
+
|
6
10
|
#
|
7
11
|
# Stringify symbolized hash keys
|
8
12
|
# @param [Hash] hash A string/symbol keyed hash
|
@@ -20,7 +24,6 @@ module RocketChat
|
|
20
24
|
end
|
21
25
|
new_hash
|
22
26
|
end
|
23
|
-
module_function :stringify_hash_keys
|
24
27
|
|
25
28
|
#
|
26
29
|
# Slice keys from hash
|
@@ -37,7 +40,6 @@ module RocketChat
|
|
37
40
|
end
|
38
41
|
new_hash
|
39
42
|
end
|
40
|
-
module_function :slice_hash
|
41
43
|
|
42
44
|
#
|
43
45
|
# Camelize a string or symbol
|
@@ -47,6 +49,5 @@ module RocketChat
|
|
47
49
|
def camelize(string)
|
48
50
|
string.to_s.gsub(/_([a-z])/) { Regexp.last_match(1).upcase }
|
49
51
|
end
|
50
|
-
module_function :camelize
|
51
52
|
end
|
52
53
|
end
|
data/lib/rocketchat.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rocket_chat/gem_version'
|
2
4
|
|
3
5
|
require 'json'
|
@@ -16,6 +18,7 @@ require 'rocket_chat/messages/room'
|
|
16
18
|
require 'rocket_chat/messages/channel'
|
17
19
|
require 'rocket_chat/messages/group'
|
18
20
|
require 'rocket_chat/messages/chat'
|
21
|
+
require 'rocket_chat/messages/im'
|
19
22
|
|
20
23
|
require 'rocket_chat/server'
|
21
24
|
require 'rocket_chat/session'
|
@@ -25,3 +28,4 @@ require 'rocket_chat/presence_status'
|
|
25
28
|
require 'rocket_chat/room'
|
26
29
|
require 'rocket_chat/user'
|
27
30
|
require 'rocket_chat/message'
|
31
|
+
require 'rocket_chat/im_summary'
|
data/rocketchat.gemspec
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
5
|
|
4
6
|
require 'rocket_chat/gem_version'
|
@@ -13,15 +15,20 @@ Gem::Specification.new do |spec|
|
|
13
15
|
spec.description = 'Rocket.Chat REST API v1 for Ruby'
|
14
16
|
spec.homepage = 'https://github.com/abrom/rocketchat-ruby'
|
15
17
|
spec.license = 'MIT'
|
18
|
+
spec.required_ruby_version = ['>= 2.5.0', '< 3.1.0']
|
16
19
|
|
17
20
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|docs)/}) }
|
18
21
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
22
|
spec.require_paths = ['lib']
|
20
23
|
|
21
|
-
spec.add_development_dependency 'bundler', '
|
22
|
-
spec.add_development_dependency 'rake', '
|
24
|
+
spec.add_development_dependency 'bundler', ['>= 1.11', '< 3.0']
|
25
|
+
spec.add_development_dependency 'rake', '>= 12.3.3'
|
23
26
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
24
|
-
spec.add_development_dependency 'rubocop', '~>
|
25
|
-
spec.add_development_dependency '
|
27
|
+
spec.add_development_dependency 'rubocop', '~> 1.12'
|
28
|
+
spec.add_development_dependency 'rubocop-performance', '~> 1.10'
|
29
|
+
spec.add_development_dependency 'rubocop-rake', '~> 0.5'
|
30
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 2.2'
|
31
|
+
spec.add_development_dependency 'simplecov', '~> 0.16'
|
32
|
+
spec.add_development_dependency 'webmock', '~> 3.12'
|
26
33
|
spec.add_development_dependency 'yard', '~> 0.9.11'
|
27
34
|
end
|
metadata
CHANGED
@@ -1,44 +1,50 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rocketchat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- int512
|
8
8
|
- abrom
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-03-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
18
|
+
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '1.11'
|
21
|
+
- - "<"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: '3.0'
|
21
24
|
type: :development
|
22
25
|
prerelease: false
|
23
26
|
version_requirements: !ruby/object:Gem::Requirement
|
24
27
|
requirements:
|
25
|
-
- - "
|
28
|
+
- - ">="
|
26
29
|
- !ruby/object:Gem::Version
|
27
30
|
version: '1.11'
|
31
|
+
- - "<"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.0'
|
28
34
|
- !ruby/object:Gem::Dependency
|
29
35
|
name: rake
|
30
36
|
requirement: !ruby/object:Gem::Requirement
|
31
37
|
requirements:
|
32
|
-
- - "
|
38
|
+
- - ">="
|
33
39
|
- !ruby/object:Gem::Version
|
34
|
-
version:
|
40
|
+
version: 12.3.3
|
35
41
|
type: :development
|
36
42
|
prerelease: false
|
37
43
|
version_requirements: !ruby/object:Gem::Requirement
|
38
44
|
requirements:
|
39
|
-
- - "
|
45
|
+
- - ">="
|
40
46
|
- !ruby/object:Gem::Version
|
41
|
-
version:
|
47
|
+
version: 12.3.3
|
42
48
|
- !ruby/object:Gem::Dependency
|
43
49
|
name: rspec
|
44
50
|
requirement: !ruby/object:Gem::Requirement
|
@@ -59,28 +65,84 @@ dependencies:
|
|
59
65
|
requirements:
|
60
66
|
- - "~>"
|
61
67
|
- !ruby/object:Gem::Version
|
62
|
-
version: '
|
68
|
+
version: '1.12'
|
69
|
+
type: :development
|
70
|
+
prerelease: false
|
71
|
+
version_requirements: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.12'
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
name: rubocop-performance
|
78
|
+
requirement: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.10'
|
83
|
+
type: :development
|
84
|
+
prerelease: false
|
85
|
+
version_requirements: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.10'
|
90
|
+
- !ruby/object:Gem::Dependency
|
91
|
+
name: rubocop-rake
|
92
|
+
requirement: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.5'
|
97
|
+
type: :development
|
98
|
+
prerelease: false
|
99
|
+
version_requirements: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.5'
|
104
|
+
- !ruby/object:Gem::Dependency
|
105
|
+
name: rubocop-rspec
|
106
|
+
requirement: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '2.2'
|
63
111
|
type: :development
|
64
112
|
prerelease: false
|
65
113
|
version_requirements: !ruby/object:Gem::Requirement
|
66
114
|
requirements:
|
67
115
|
- - "~>"
|
68
116
|
- !ruby/object:Gem::Version
|
69
|
-
version: '
|
117
|
+
version: '2.2'
|
118
|
+
- !ruby/object:Gem::Dependency
|
119
|
+
name: simplecov
|
120
|
+
requirement: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0.16'
|
125
|
+
type: :development
|
126
|
+
prerelease: false
|
127
|
+
version_requirements: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0.16'
|
70
132
|
- !ruby/object:Gem::Dependency
|
71
133
|
name: webmock
|
72
134
|
requirement: !ruby/object:Gem::Requirement
|
73
135
|
requirements:
|
74
136
|
- - "~>"
|
75
137
|
- !ruby/object:Gem::Version
|
76
|
-
version: '
|
138
|
+
version: '3.12'
|
77
139
|
type: :development
|
78
140
|
prerelease: false
|
79
141
|
version_requirements: !ruby/object:Gem::Requirement
|
80
142
|
requirements:
|
81
143
|
- - "~>"
|
82
144
|
- !ruby/object:Gem::Version
|
83
|
-
version: '
|
145
|
+
version: '3.12'
|
84
146
|
- !ruby/object:Gem::Dependency
|
85
147
|
name: yard
|
86
148
|
requirement: !ruby/object:Gem::Requirement
|
@@ -107,6 +169,7 @@ files:
|
|
107
169
|
- ".gitignore"
|
108
170
|
- ".rubocop.yml"
|
109
171
|
- ".travis.yml"
|
172
|
+
- CHANGELOG.md
|
110
173
|
- Gemfile
|
111
174
|
- LICENSE
|
112
175
|
- README.md
|
@@ -114,11 +177,13 @@ files:
|
|
114
177
|
- bin/console
|
115
178
|
- lib/rocket_chat/error.rb
|
116
179
|
- lib/rocket_chat/gem_version.rb
|
180
|
+
- lib/rocket_chat/im_summary.rb
|
117
181
|
- lib/rocket_chat/info.rb
|
118
182
|
- lib/rocket_chat/message.rb
|
119
183
|
- lib/rocket_chat/messages/channel.rb
|
120
184
|
- lib/rocket_chat/messages/chat.rb
|
121
185
|
- lib/rocket_chat/messages/group.rb
|
186
|
+
- lib/rocket_chat/messages/im.rb
|
122
187
|
- lib/rocket_chat/messages/list_support.rb
|
123
188
|
- lib/rocket_chat/messages/room.rb
|
124
189
|
- lib/rocket_chat/messages/room_support.rb
|
@@ -139,7 +204,7 @@ homepage: https://github.com/abrom/rocketchat-ruby
|
|
139
204
|
licenses:
|
140
205
|
- MIT
|
141
206
|
metadata: {}
|
142
|
-
post_install_message:
|
207
|
+
post_install_message:
|
143
208
|
rdoc_options: []
|
144
209
|
require_paths:
|
145
210
|
- lib
|
@@ -147,16 +212,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
147
212
|
requirements:
|
148
213
|
- - ">="
|
149
214
|
- !ruby/object:Gem::Version
|
150
|
-
version:
|
215
|
+
version: 2.5.0
|
216
|
+
- - "<"
|
217
|
+
- !ruby/object:Gem::Version
|
218
|
+
version: 3.1.0
|
151
219
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
220
|
requirements:
|
153
221
|
- - ">="
|
154
222
|
- !ruby/object:Gem::Version
|
155
223
|
version: '0'
|
156
224
|
requirements: []
|
157
|
-
|
158
|
-
|
159
|
-
signing_key:
|
225
|
+
rubygems_version: 3.2.3
|
226
|
+
signing_key:
|
160
227
|
specification_version: 4
|
161
228
|
summary: Rocket.Chat REST API v1 for Ruby
|
162
229
|
test_files: []
|