Open maknz opened 8 years ago
Wouldn't it be cool to be able to instantiate a Client
just by Team
name!? Something like: new Client('mycompany');
this will make it easier to use the default settings. Same would be possible with an array new Client(['company1', 'company2']);
.
You'd still need to provide the endpoints as well, so wrapping all that up in a Team
seems to solve that while still keeping the client easy to interact with.
Ideally the client would generally only be instantiated in the Laravel service provider, or some other IoC type deal. But, even if it was in a a controller, it should still be a one-off thing.
We could also have an addTeam
method to Client
so you could just do new Client
and then $instance->addTeam($team)->addTeam($anotherTeam)
.
Ok, so the teams are not in the config file? It feels a bit away from the quick and simple usage yet.
My idea is something like the different DB connections - everything is in the config file and you have a default one - so the usage of \Slack::send('Hello world!');
is possible but it's also possible to use it like \Slack::team('myteam')->send('hello world')
or with an array of teams \Slack::team(['myteam1', 'myteam2'])->send('hello world')
and with the Team object \Slack::team(new Team(...))->send('hello world')
or with an array of team objects or mix it up.
Edit: Ok, you have moved the laravel parts in another repo - sorry. So this is everything thought for laravel.^^
Ah yes, sorry for the confusion. Yeah, for Laravel you'd have your teams in a config file, and then just simply Slack::team('company1')->send('message')
:+1:. The teams would be required for instantiating the client for uses outside Laravel.
We need to support multiple teams. As part of the 2.0 release, we'll be moving away from simply an 'endpoint' and have a first-class
Team
object. A client can be instantiated with one or more teams. Each team will have a default channel, and a name which can be used to refer to that team, e.g. 'mycompany'.Example usage:
The full lead up discussion to the feature is over at #44.
I plan to work on this next weekend.