stoiveyp / Slack.NetStandard

.NET Core package that helps with Slack interactions
MIT License
41 stars 16 forks source link

Add teamId to enable org-wide tokens usage #92

Closed lucaghersi closed 8 months ago

lucaghersi commented 9 months ago

To support org-wide apps, you need to be able to pass "team_id" when a org token is used. Not all APIs support this parameter (https://api.slack.com/enterprise/apps/changes-apis)

This PR add support for teamId where possible, while making some rational changes to some APIs, for example using Request Objects where parameters list growth too much.

This PR contains breaking contract changes.

That said, I will be more than happy to make changes / adaptation / whatever you see fit. Open for feedback :)

lucaghersi commented 9 months ago

BTW, I tried to contain changes to the minimum amount possible, but there are potential improvements I didn't apply to maintain consistency. For example primary constructors, adding guards for required values, etc. It's even possible to drop this changes I made alltogether, and make some kind of "global teamId parameter" in the construction of the web client, and support teamId directly. As I said, happy to receive feedbacks.

stoiveyp commented 8 months ago

Hi @lucaghersi - haven't forgotten about this, just had a busy couple of days and as it's a large number of changes I want time to look through it properly before I merge it.

Really appreciate you've made changes that keep in the style of the API, I haven't spotted anything I have a problem with - hopefully it'll be approved and published in the next 24hrs 🤞

lucaghersi commented 8 months ago

No rush and thanks for looking at it. What I thought (next PR maybe?) is that it would be possible to remove the "accessToken" and "teamId" from all methods and put them in the Api client constructor and make them global, massively simplifying all methods.

stoiveyp commented 8 months ago

Not sure what you mean about accessToken? We set the token at the client level - you don't pass it into every method?

As for teamId. I want the current API Client to be a clear representation of the API as much as possible - so no global state outside of the token. But - there's definitely the possibility of something like client.ForTeam(teamId) that could then return something like an ITeamSlackClient with methods that have the parameter removed 💭