-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add channel members API #34
Conversation
lib/rocket_chat/messages/channel.rb
Outdated
# @return [Room[]] | ||
# @raise [HTTPError, StatusError] | ||
# | ||
def members(room_id: nil, name: nil, offset: nil, count: nil, sort: nil, fields: nil, query: {}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added room_id
and name
as first arguments for this method, I think wold be consistent with the other methods in this file.
This is a method which is also a list and the arguments offset: nil, count: nil, sort: nil, fields: nil, query: {}
make sense.
I'm not sure about the fields
looking at the RocketChat API docs this is not supported, I added it for consistency.
We could also omit it, and use {}
or nil
when building the params for list build_list_body(offset, count, sort, {}, query)
.
I noticed that fields
is required build_list_body
method.
I'm having doubts on what is the best approach, @abrom could you please advise when you have the chance?
Thank you 🙇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, the API would support both the room ID and name.
The API does not support either fields
or query
parameters so please remove these. We wouldn't want someone to think that because the method accepts these parameters that the API does too!
If you just pass through the fields
value as nil
it will not be included.
Given that the groups.members API also supports the same parameters and returns the same response I would suggest you put this API code in the parent class Room
. That way it will be available to both. As per the other methods in the Room
class you'd pass the URI for the API through using the api_path
helper: self.class.api_path('members')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@abrom Thank you for the feedback 🙇♀️ I applied your suggestions.
98097eb
to
b16f0ca
Compare
lib/rocket_chat/messages/channel.rb
Outdated
# @return [Room[]] | ||
# @raise [HTTPError, StatusError] | ||
# | ||
def members(room_id: nil, name: nil, offset: nil, count: nil, sort: nil, fields: nil, query: {}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, the API would support both the room ID and name.
The API does not support either fields
or query
parameters so please remove these. We wouldn't want someone to think that because the method accepts these parameters that the API does too!
If you just pass through the fields
value as nil
it will not be included.
Given that the groups.members API also supports the same parameters and returns the same response I would suggest you put this API code in the parent class Room
. That way it will be available to both. As per the other methods in the Room
class you'd pass the URI for the API through using the api_path
helper: self.class.api_path('members')
70800de
to
4eae9ef
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one @alinavancea looks great 👍
FYI this has been released in v0.1.20 |
Thank you @abrom 🙇♀️ |
Issue #33
Summary of the changes
Add
members
method to underchannel.rb
Add docs
Add
rspec
testsrspec is passing
rubocop has some offenses