Skip to content
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

Merged
merged 2 commits into from
Mar 29, 2021
Merged

Conversation

alinavancea
Copy link
Contributor

@alinavancea alinavancea commented Mar 28, 2021

Issue #33

Summary of the changes

  • Add members method to under channel.rb

  • Add docs

  • Add rspec tests

  • rspec is passing

  • rubocop has some offenses

41 files inspected, 52 offenses detected, 1 offense auto-correctable

# @return [Room[]]
# @raise [HTTPError, StatusError]
#
def members(room_id: nil, name: nil, offset: nil, count: nil, sort: nil, fields: nil, query: {})
Copy link
Contributor Author

@alinavancea alinavancea Mar 28, 2021

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 🙇

Copy link
Owner

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')

Copy link
Contributor Author

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.

@alinavancea alinavancea force-pushed the am-add-channel-members-api branch from 98097eb to b16f0ca Compare March 28, 2021 13:30
# @return [Room[]]
# @raise [HTTPError, StatusError]
#
def members(room_id: nil, name: nil, offset: nil, count: nil, sort: nil, fields: nil, query: {})
Copy link
Owner

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')

@alinavancea alinavancea force-pushed the am-add-channel-members-api branch from 70800de to 4eae9ef Compare March 29, 2021 09:59
@alinavancea alinavancea requested a review from abrom March 29, 2021 10:02
Copy link
Owner

@abrom abrom left a 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 👍

@abrom abrom merged commit e14b0bf into abrom:main Mar 29, 2021
@abrom
Copy link
Owner

abrom commented Mar 29, 2021

FYI this has been released in v0.1.20

@alinavancea alinavancea deleted the am-add-channel-members-api branch March 29, 2021 12:13
@alinavancea
Copy link
Contributor Author

Thank you @abrom 🙇‍♀️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants