Class: RocketChat::Messages::Group
- Includes:
- ListSupport
- Defined in:
- lib/rocket_chat/messages/group.rb
Overview
Rocket.Chat Group messages
Constant Summary
Constants inherited from Room
Class Method Summary collapse
-
.settable_attributes ⇒ Object
Keys for set_attr: * [String] announcement Announcement for the channel * [Hash] custom_fields Custom fields for the channel * [String] description A room’s description * [String] purpose Alias for description * [Boolean] read_only Read-only status * [String] topic A room’s topic * [Strong] type c (channel) or p (private group).
Instance Method Summary collapse
-
#add_leader(room_id: nil, name: nil, user_id: nil, username: nil) ⇒ Boolean
*.add_leader REST API.
-
#list(offset: nil, count: nil, sort: nil, fields: nil, query: nil) ⇒ Room[]
groups.list REST API.
-
#list_all(offset: nil, count: nil, sort: nil, fields: nil, query: nil) ⇒ Room[]
groups.listAll REST API.
-
#online(room_id: nil, name: nil) ⇒ Users[]
groups.online REST API.
-
#remove_leader(room_id: nil, name: nil, user_id: nil, username: nil) ⇒ Boolean
*.remove_leader REST API.
Methods inherited from Room
#add_all, #add_moderator, #add_owner, api_path, #archive, #create, #delete, #info, inherited, #initialize, #invite, #kick, #leave, #members, #remove_moderator, #remove_owner, #rename, #set_attr, #unarchive, #upload_file
Methods included from UserSupport
Methods included from RoomSupport
#room_params, #room_query_params
Constructor Details
This class inherits a constructor from RocketChat::Messages::Room
Class Method Details
.settable_attributes ⇒ Object
Keys for set_attr:
- String
-
announcement Announcement for the channel
- Hash
-
custom_fields Custom fields for the channel
- String
-
description A room’s description
- String
-
purpose Alias for description
- Boolean
-
read_only Read-only status
- String
-
topic A room’s topic
- Strong
-
type c (channel) or p (private group)
102 103 104 |
# File 'lib/rocket_chat/messages/group.rb', line 102 def self.settable_attributes %i[announcement custom_fields description purpose read_only topic type] end |
Instance Method Details
#add_leader(room_id: nil, name: nil, user_id: nil, username: nil) ⇒ Boolean
*.add_leader REST API
18 19 20 21 22 23 24 25 |
# File 'lib/rocket_chat/messages/group.rb', line 18 def add_leader(room_id: nil, name: nil, user_id: nil, username: nil) session.request_json( self.class.api_path('addLeader'), method: :post, body: room_params(room_id, name) .merge(user_params(user_id, username)) )['success'] end |
#list(offset: nil, count: nil, sort: nil, fields: nil, query: nil) ⇒ Room[]
groups.list REST API
51 52 53 54 55 56 57 58 |
# File 'lib/rocket_chat/messages/group.rb', line 51 def list(offset: nil, count: nil, sort: nil, fields: nil, query: nil) response = session.request_json( '/api/v1/groups.list', body: build_list_body(offset, count, sort, fields, query) ) response['groups'].map { |hash| RocketChat::Room.new hash } if response['success'] end |
#list_all(offset: nil, count: nil, sort: nil, fields: nil, query: nil) ⇒ Room[]
groups.listAll REST API
68 69 70 71 72 73 74 75 |
# File 'lib/rocket_chat/messages/group.rb', line 68 def list_all(offset: nil, count: nil, sort: nil, fields: nil, query: nil) response = session.request_json( '/api/v1/groups.listAll', body: build_list_body(offset, count, sort, fields, query) ) response['groups'].map { |hash| RocketChat::Room.new hash } if response['success'] end |
#online(room_id: nil, name: nil) ⇒ Users[]
Must provide either ‘room_id` or `name` parameter. `room_id` will take precedence if providing both
groups.online REST API
85 86 87 88 89 90 91 92 |
# File 'lib/rocket_chat/messages/group.rb', line 85 def online(room_id: nil, name: nil) response = session.request_json( '/api/v1/groups.online', body: { query: room_query_params(room_id, name) } ) response['online'].map { |hash| RocketChat::User.new hash } if response['success'] end |
#remove_leader(room_id: nil, name: nil, user_id: nil, username: nil) ⇒ Boolean
*.remove_leader REST API
34 35 36 37 38 39 40 41 |
# File 'lib/rocket_chat/messages/group.rb', line 34 def remove_leader(room_id: nil, name: nil, user_id: nil, username: nil) session.request_json( self.class.api_path('removeLeader'), method: :post, body: room_params(room_id, name) .merge(user_params(user_id, username)) )['success'] end |