Class: RocketChat::Messages::Channel
- Includes:
- ListSupport, UserSupport
- Defined in:
- lib/rocket_chat/messages/channel.rb
Overview
Rocket.Chat Channel messages
Class Method Summary collapse
-
.settable_attributes ⇒ Object
Keys for set_attr: * [String] description A room's description * [String] join_code Code to join a channel * [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
-
#join(room_id: nil, name: nil) ⇒ Boolean
channels.join REST API.
-
#list(offset: nil, count: nil, sort: nil, fields: nil, query: nil) ⇒ Room[]
channels.list REST API.
-
#online(room_id: nil, name: nil) ⇒ Users[]
channels.online REST API.
Methods included from UserSupport
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
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
-
description A room's description
- String
-
join_code Code to join a channel
- 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)
70 71 72 |
# File 'lib/rocket_chat/messages/channel.rb', line 70 def self.settable_attributes %i[description join_code purpose read_only topic type] end |
Instance Method Details
#join(room_id: nil, name: nil) ⇒ Boolean
channels.join REST API
19 20 21 22 23 24 25 |
# File 'lib/rocket_chat/messages/channel.rb', line 19 def join(room_id: nil, name: nil) session.request_json( '/api/v1/channels.join', method: :post, body: room_params(room_id, name) )['success'] end |
#list(offset: nil, count: nil, sort: nil, fields: nil, query: nil) ⇒ Room[]
channels.list REST API
37 38 39 40 41 42 43 44 |
# File 'lib/rocket_chat/messages/channel.rb', line 37 def list(offset: nil, count: nil, sort: nil, fields: nil, query: nil) response = session.request_json( '/api/v1/channels.list', body: build_list_body(offset, count, sort, fields, query) ) response['channels'].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
channels.online REST API
54 55 56 57 58 59 60 61 |
# File 'lib/rocket_chat/messages/channel.rb', line 54 def online(room_id: nil, name: nil) response = session.request_json( '/api/v1/channels.online', body: { query: room_query_params(room_id, name) } ) response['online'].map { |hash| RocketChat::User.new hash } if response['success'] end |