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 optional team parameter to GetTeamInfo function calls #981

Closed
wants to merge 1 commit into from

Conversation

ed-wp
Copy link

@ed-wp ed-wp commented Oct 1, 2021

Solves: #980

Pull Request Guidelines

These are recommendations for pull requests.
They are strictly guidelines to help manage expectations.

PR preparation
  • Run make pr-prep from the root of the repository to run formatting, linting and tests.
Should this be an issue instead
  • is it a convenience method? (no new functionality, streamlines some use case)
  • exposes a previously private type, const, method, etc.
  • is it application specific (caching, retry logic, rate limiting, etc)
  • is it performance related.
API changes

Since API changes have to be maintained they undergo a more detailed review and are more likely to require changes.

  • [no tests, if you're adding to the API include at least a single test of the happy case.
  • If you can accomplish your goal without changing the API, then do so.
  • dependency changes. updates are okay. adding/removing need justification.
Examples of API changes that do not meet guidelines:
  • in library cache for users. caches are use case specific.
  • Convenience methods for Sending Messages, update, post, ephemeral, etc. consider opening an issue instead.

Copy link

@ShamanR ShamanR left a comment

Choose a reason for hiding this comment

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

sould we test emty team case?

return api.GetTeamInfoContext(context.Background())
// if the team is empty (""), will return information about the current team.
// https://api.slack.com/methods/team.info
func (api *Client) GetTeamInfo(team string) (*TeamInfo, error) {
Copy link

Choose a reason for hiding this comment

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

Backward compatibility issue.

Copy link
Member

@kanata2 kanata2 Nov 6, 2021

Choose a reason for hiding this comment

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

I'm having trouble with only one optional parameter...
I've come up with a few ideas, which one do you think is better?

other idea 1

How about adding GetAnotherTeamInfo(team string) method .

// Get your own team information.
info, err := api.GetTeamInfo()

// Get other team information.
info, err := api.GetOtherTeamInfo(teamID)

other idea 2

Use functional option pattern.

// Get your own team information.
info, err := api.GetTeamInfo()

// Get other team information.
info, err := api.GetTeamInfo(slack.GetTeamInfoOptionTeamID(teamID))

Copy link
Author

Choose a reason for hiding this comment

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

I feel like even though this is not backwards compatible, it follows how the slack API actually operates and makes it less confusing.

From Slack API Docs:

Team to get info on, if omitted, will return information about the current team. Will only return team that the authenticated token is allowed to see through external shared channels

I think that other option 2 is closer to the APIs definition, but not nearly as close as my proposal.

Thoughts?

Copy link
Member

@kanata2 kanata2 Dec 9, 2021

Choose a reason for hiding this comment

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

I think that other option 2 is closer to the APIs definition, but not nearly as close as my proposal.

The parameter team is an optional in Slack while it is required in our GetTeamInfo API with your proposal, so I think it is not so good design.
The difference in idea 2 is that it keeps team parameter optional.

@kanata2 kanata2 added the feedback given When a review has been conducted and awaiting the response from the comitter(s) label Nov 6, 2021
@kanata2
Copy link
Member

kanata2 commented Dec 8, 2022

#1118 is merged.

@kanata2 kanata2 closed this Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking changes enhancement feedback given When a review has been conducted and awaiting the response from the comitter(s) Web API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants