Skip to content

Commit

Permalink
Version bump to v0.1.13
Browse files Browse the repository at this point in the history
Added support for channel/group addAll endpoint
  • Loading branch information
abrom committed Sep 8, 2017
1 parent 00b6b67 commit 972f06f
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 3 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ This gem supports the following Rocket.Chat APIs (Tested against Rocket.Chat v0.
* /api/v1/channels.archive
* [/api/v1/channels.create](docs/channels.md#channelscreate)
* [/api/v1/channels.delete](docs/channels.md#channelsdelete)
* [/api/v1/channels.addAll](docs/channels.md#channelsaddall)
* [/api/v1/channels.addOwner](docs/channels.md#channelsaddowner)
* [/api/v1/channels.removeOwner](docs/channels.md#channelsremoveowner)
* [/api/v1/channels.addModerator](docs/channels.md#channelsaddmoderator)
* [/api/v1/channels.removeModerator](docs/channels.md#channelsremovemoderator)
* [/api/v1/channels.info](docs/channels.md#channelsinfo)
* [/api/v1/channels.invite](docs/channels.md#channelsinvite)
* [/api/v1/channels.join](docs/channels.md#channelsjoin)
Expand All @@ -63,6 +68,11 @@ This gem supports the following Rocket.Chat APIs (Tested against Rocket.Chat v0.
* /api/v1/groups.archive
* /api/v1/groups.create
* /api/v1/groups.delete
* [/api/v1/groups.addAll](docs/groups.md#groupsaddall)
* [/api/v1/groups.addOwner](docs/groups.md#groupsaddowner)
* [/api/v1/groups.removeOwner](docs/groups.md#groupsremoveowner)
* [/api/v1/groups.addModerator](docs/groups.md#groupsaddmoderator)
* [/api/v1/groups.removeModerator](docs/groups.md#groupsremovemoderator)
* /api/v1/groups.info
* /api/v1/groups.invite
* /api/v1/groups.leave
Expand Down
44 changes: 44 additions & 0 deletions docs/channels.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,50 @@ Either room_id (RocketChat's ID) or name can be used.
To delete a channel, the same options as an info request can be used (`room_id` or `name`).


#### channels.addAll

```ruby
require 'rocketchat'

rocket_server = RocketChat::Server.new('http://your.server.address/')
session = rocket_server.login('username', 'password')
success = session.channels.add_all(room_id: 'ByehQjC44FwMeiLbX')
```

Optional parameter for add_all is `active_users_only` (default false)

_N.B. the addAll API endpoint requires the calling user to have the `admin` role_


#### channels.addOwner

```ruby
require 'rocketchat'

rocket_server = RocketChat::Server.new('http://your.server.address/')
session = rocket_server.login('username', 'password')
success = session.channels.add_owner(name: 'some_channelname', username: 'some_username')
```

Either room_id (RocketChat's ID) or name can be used.
The same applies to user_id and username.


#### channels.removeOwner

To remove an owner from a channel, the same options as an `add_owner` request can be used.


#### channels.addModerator

To add a moderator to a channel, the same options as an `add_owner` request can be used.


#### channels.removeModerator

To remove a moderator from a channel, the same options as an `add_owner` request can be used.


#### channels.invite

```ruby
Expand Down
44 changes: 44 additions & 0 deletions docs/groups.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,47 @@ rocket_server = RocketChat::Server.new('http://your.server.address/')
session = rocket_server.login('username', 'password')
groups = session.groups.list(offset: 40)
```


#### groups.addAll

```ruby
require 'rocketchat'

rocket_server = RocketChat::Server.new('http://your.server.address/')
session = rocket_server.login('username', 'password')
success = session.groups.add_all(room_id: 'ByehQjC44FwMeiLbX')
```

Optional parameter for add_all is `active_users_only` (default false)

_N.B. the addAll API endpoint requires the calling user to have the `admin` role_


#### groups.addOwner

```ruby
require 'rocketchat'

rocket_server = RocketChat::Server.new('http://your.server.address/')
session = rocket_server.login('username', 'password')
success = session.groups.add_owner(name: 'some_groupname', username: 'some_username')
```

Either room_id (RocketChat's ID) or name can be used.
The same applies to user_id and username.


#### groups.removeOwner

To remove an owner from a group, the same options as an `add_owner` request can be used.


#### groups.addModerator

To add a moderator to a group, the same options as an `add_owner` request can be used.


#### groups.removeModerator

To remove a moderator from a group, the same options as an `add_owner` request can be used.
2 changes: 1 addition & 1 deletion lib/rocket_chat/gem_version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module RocketChat
VERSION = '0.1.12'.freeze
VERSION = '0.1.13'.freeze
end
31 changes: 29 additions & 2 deletions lib/rocket_chat/messages/room.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,29 @@ def delete(room_id: nil, name: nil)
)['success']
end

#
# *.addAll REST API
# @param [String] room_id Rocket.Chat room id
# @param [String] name Rocket.Chat room name (coming soon)
# @param [String] active_users_only Add active users only
# @return [Boolean]
# @raise [HTTPError, StatusError]
#
def add_all(room_id: nil, name: nil, active_users_only: false)
session.request_json(
self.class.api_path('addAll'),
method: :post,
body: room_params(room_id, name)
.merge(activeUsersOnly: active_users_only)
)['success']
end

#
# *.add_owner REST API
# @param [String] room_id Rocket.Chat room id
# @param [String] name Rocket.Chat room name (coming soon)
# @param [String] user_id Rocket.Chat user id
# @param [String] username Rocket.Chat username
# @return [Boolean]
# @raise [HTTPError, StatusError]
#
Expand All @@ -79,7 +98,9 @@ def add_owner(room_id: nil, name: nil, user_id: nil, username: nil)
#
# *.remove_owner REST API
# @param [String] room_id Rocket.Chat room id
# @param [String] name Rocket.Chat room name (coming soon)
# @param [String] user_id Rocket.Chat user id
# @param [String] username Rocket.Chat username
# @return [Boolean]
# @raise [HTTPError, StatusError]
#
Expand All @@ -95,7 +116,9 @@ def remove_owner(room_id: nil, name: nil, user_id: nil, username: nil)
#
# *.add_moderator REST API
# @param [String] room_id Rocket.Chat room id
# @param [String] name Rocket.Chat room name (coming soon)
# @param [String] user_id Rocket.Chat user id
# @param [String] username Rocket.Chat username
# @return [Boolean]
# @raise [HTTPError, StatusError]
#
Expand All @@ -111,7 +134,9 @@ def add_moderator(room_id: nil, name: nil, user_id: nil, username: nil)
#
# *.remove_moderator REST API
# @param [String] room_id Rocket.Chat room id
# @param [String] name Rocket.Chat room name (coming soon)
# @param [String] user_id Rocket.Chat user id
# @param [String] username Rocket.Chat username
# @return [Boolean]
# @raise [HTTPError, StatusError]
#
Expand Down Expand Up @@ -146,7 +171,7 @@ def info(room_id: nil, name: nil)
# @param [String] room_id Rocket.Chat room id
# @param [String] name Rocket.Chat room name (coming soon)
# @param [String] user_id Rocket.Chat user id
# @param [String] username Username
# @param [String] username Rocket.Chat username
# @return [Boolean]
# @raise [HTTPError, StatusError]
#
Expand All @@ -162,6 +187,7 @@ def invite(room_id: nil, name: nil, user_id: nil, username: nil)
#
# *.archive REST API
# @param [String] room_id Rocket.Chat room id
# @param [String] name Rocket.Chat room name (coming soon)
# @return [Boolean]
# @raise [HTTPError, StatusError]
#
Expand All @@ -176,6 +202,7 @@ def archive(room_id: nil, name: nil)
#
# *.unarchive REST API
# @param [String] room_id Rocket.Chat room id
# @param [String] name Rocket.Chat room name (coming soon)
# @return [Boolean]
# @raise [HTTPError, StatusError]
#
Expand Down Expand Up @@ -220,7 +247,7 @@ def rename(room_id, new_name)
#
# *.set* REST API
# @param [String] room_id Rocket.Chat room id
# @param [String] new_name New room name
# @param [String] name Rocket.Chat room name (coming soon)
# @param [Hash] setting Single key-value
# @return [Boolean]
# @raise [ArgumentError, HTTPError, StatusError]
Expand Down

0 comments on commit 972f06f

Please sign in to comment.