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

api: Refactor GET /users endpoint. #546

Closed
wants to merge 2 commits into from

Conversation

akashaviator
Copy link
Contributor

@akashaviator akashaviator commented Mar 11, 2020

This adds binding for GET ../users/{id} endpoint.

'''
Example usage:

>>> client.get_member(8,{'include_custom_profile_fields': True})
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd put a space after the , here, as that's standard Python style. Otherwise lgtm.

@akashaviator
Copy link
Contributor Author

@timabbott added the space after , .

@@ -1076,6 +1076,21 @@ def delete_stream(self, stream_id):
method='DELETE',
)

def get_member(self, user_id, request=None):
Copy link
Sponsor Member

@timabbott timabbott Mar 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, let's call this get_user_by_id, not get_member. That's more consistent naming with the rest of the product.

(And I think we'll want to rename get_members to get_users)

{'result': 'success', 'msg': '', 'user': [{...}, {...}]}
'''
return self.call_endpoint(
url='users/'+str(user_id),
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We generally do space around operators like +; see PEP-8 which we follow on this.

But probably it's better to do string formatting, rather than +, here.

@akashaviator akashaviator force-pushed the get-user branch 3 times, most recently from d90ffe4 to eca22c7 Compare March 25, 2020 23:25
@akashaviator
Copy link
Contributor Author

@timabbott made those changes. I was trying to rename examples/list-members to list-users , but got "conflicting files" warning here.

@timabbott
Copy link
Sponsor Member

I merged the first commit. For the rename commit, we should make the old function name work for backwards-compatibility. Otherwise, any existing API clients will break on upgrade.

(And once we merge that and do a release, we should make a PR to update the documentation)

@akashaviator
Copy link
Contributor Author

akashaviator commented Mar 26, 2020

@timabbott So do you mean that I should create a new wrapper for the same endpoint, named as get_users ?

def get_users(request)
      return get_members(request)

@timabbott
Copy link
Sponsor Member

I was suggesting we rename get_members to get_users and do the wrappers in the other direction.

(That would be more clear about which is the preferred option, the one that's not a wrapper).

@zulipbot zulipbot added size: S and removed size: XS labels Apr 19, 2020
@akashaviator akashaviator changed the title api: Implement GET users/{id} endpoint api: Refactor GET /users endpoint. Apr 19, 2020
@akashaviator
Copy link
Contributor Author

@timabbott I've updated the PR.

'''
return self.call_endpoint(
url='users',
method='GET',
request=request,
)

def get_members(self, request: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
return self.get_users(request=request)
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a comment that this is a backwards-compatibility name. I can take care of it before merging.

@timabbott
Copy link
Sponsor Member

Merged after adding the comment discussed above, thanks @akashaviator!

We'll probably want to do similar renames to the other items we wanted to change in @orientor's OpenationId PR.

@timabbott timabbott closed this May 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants