This repository has been archived by the owner on Dec 17, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from cleentfaar/team.info
Team.info (rebased)
- Loading branch information
Showing
12 changed files
with
369 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Slack API library. | ||
* | ||
* (c) Cas Leentfaar <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace CL\Slack\Model; | ||
|
||
/** | ||
* @author Nic Malan <[email protected]> | ||
* | ||
* @link Official documentation at https://api.slack.com/types | ||
*/ | ||
class Team extends AbstractModel | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private $id; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $name; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $domain; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $emailDomain; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private $icon; | ||
|
||
/** | ||
* @return string The ID of this team. | ||
*/ | ||
public function getId() | ||
{ | ||
return $this->id; | ||
} | ||
|
||
/** | ||
* @return string The name of this team. | ||
*/ | ||
public function getName() | ||
{ | ||
return $this->name; | ||
} | ||
|
||
/** | ||
* @return string The domain of this team. | ||
*/ | ||
public function getDomain() | ||
{ | ||
return $this->domain; | ||
} | ||
|
||
/** | ||
* @return string The email domain of this team. | ||
*/ | ||
public function getEmailDomain() | ||
{ | ||
return $this->emailDomain; | ||
} | ||
|
||
/** | ||
* @return array of icons | ||
*/ | ||
public function getIcon() | ||
{ | ||
return $this->icon; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Slack API library. | ||
* | ||
* (c) Cas Leentfaar <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace CL\Slack\Payload; | ||
|
||
/** | ||
* @author Nic Malan <[email protected]> | ||
* | ||
* @link Official documentation at https://api.slack.com/methods/team.info | ||
*/ | ||
class TeamInfoPayload extends AbstractPayload | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getMethod() | ||
{ | ||
return 'team.info'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Slack API library. | ||
* | ||
* (c) Cas Leentfaar <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace CL\Slack\Payload; | ||
|
||
use CL\Slack\Model\Team; | ||
|
||
/** | ||
* @author Nic Malan <[email protected]> | ||
*/ | ||
class TeamInfoPayloadResponse extends AbstractPayloadResponse | ||
{ | ||
/** | ||
* @var Team|null | ||
*/ | ||
private $team; | ||
|
||
/** | ||
* @return Team|null | ||
*/ | ||
public function getTeam() | ||
{ | ||
return $this->team; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/CL/Slack/Resources/config/serializer/CL.Slack.Model.Team.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
CL\Slack\Model\Team: | ||
properties: | ||
id: | ||
type: string | ||
name: | ||
type: string | ||
domain: | ||
type: string | ||
emailDomain: | ||
type: string | ||
serialized_name: email_domain | ||
icon: | ||
type: array<string, string> |
4 changes: 4 additions & 0 deletions
4
src/CL/Slack/Resources/config/serializer/CL.Slack.Payload.TeamInfoPayload.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
CL\Slack\Payload\TeamInfoPayload: | ||
properties: | ||
error: | ||
type: string |
4 changes: 4 additions & 0 deletions
4
src/CL/Slack/Resources/config/serializer/CL.Slack.Payload.TeamInfoPayloadResponse.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
CL\Slack\Payload\TeamInfoPayloadResponse: | ||
properties: | ||
team: | ||
type: CL\Slack\Model\Team |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
## channels.list | ||
|
||
This method is used to get the info for a team. | ||
|
||
| | | | ||
|-------------------------|---------------------------------------------------------------------------------------------------------------------------------| | ||
| Official documentation | https://api.slack.com/methods/team.info | | ||
| `Payload` class | [TeamInfoPayload](https://github.com/cleentfaar/slack/blob/master/src/CL/Slack/Payload/TeamInfoPayload.php) | | ||
| `PayloadResponse` class | [TeamInfoPayloadResponse](https://github.com/cleentfaar/slack/blob/master/src/CL/Slack/Payload/TeamInfoPayloadResponse.php) | | ||
|
||
|
||
### Usage | ||
|
||
```php | ||
$payload = new TeamInfoPayload(); | ||
|
||
$apiClient = new ApiClient('your-slack-token-here'); | ||
$response = $apiClient->send($payload); | ||
|
||
if ($response->isOk()) { | ||
$response->getTeam() // the team's info | ||
} else { | ||
// something went wrong, but what? | ||
|
||
// simple error (Slack's error message) | ||
echo $response->getError(); | ||
|
||
// explained error (Slack's explanation of the error, according to the documentation) | ||
echo $response->getErrorExplanation(); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Slack API library. | ||
* | ||
* (c) Cas Leentfaar <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace CL\Slack\Tests\Model; | ||
|
||
use CL\Slack\Model\AbstractModel; | ||
use CL\Slack\Model\Team; | ||
|
||
/** | ||
* @author Nic Malan <[email protected]> | ||
*/ | ||
class TeamInfoTest extends AbstractModelTest | ||
{ | ||
/** | ||
* @return array | ||
*/ | ||
protected function getModelData() | ||
{ | ||
return $this->createTeam(); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
protected function getModelClass() | ||
{ | ||
return 'CL\Slack\Model\Team'; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @param Team $actualModel | ||
*/ | ||
protected function assertModel(array $expectedData, AbstractModel $actualModel) | ||
{ | ||
$this->assertTeam($expectedData, $actualModel); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
tests/src/CL/Slack/Tests/Payload/TeamInfoPayloadResponseTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Slack API library. | ||
* | ||
* (c) Cas Leentfaar <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace CL\Slack\Tests\Payload; | ||
|
||
use CL\Slack\Payload\PayloadResponseInterface; | ||
use CL\Slack\Payload\TeamInfoPayloadResponse; | ||
|
||
/** | ||
* @author Nic Malan <[email protected]> | ||
*/ | ||
class TeamInfoPayloadResponseTest extends AbstractPayloadResponseTest | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function createResponseData() | ||
{ | ||
return [ | ||
'team' => $this->createTeam(), | ||
]; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @param array $responseData | ||
* @param TeamInfoPayloadResponse $payloadResponse | ||
*/ | ||
protected function assertResponse(array $responseData, PayloadResponseInterface $payloadResponse) | ||
{ | ||
$this->assertInstanceOf('CL\Slack\Model\Team', $payloadResponse->getTeam()); | ||
$this->assertTeam($responseData['team'], $payloadResponse->getTeam()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Slack API library. | ||
* | ||
* (c) Cas Leentfaar <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace CL\Slack\Tests\Payload; | ||
|
||
use CL\Slack\Payload\PayloadInterface; | ||
use CL\Slack\Payload\TeamInfoPayload; | ||
|
||
/** | ||
* @author Nic Malan <[email protected]> | ||
*/ | ||
class TeamInfoPayloadTest extends AbstractPayloadTest | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function createPayload() | ||
{ | ||
$payload = new TeamInfoPayload(); | ||
return $payload; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @param TeamInfoPayload $payload | ||
*/ | ||
protected function getExpectedPayloadData(PayloadInterface $payload) | ||
{ | ||
return []; | ||
} | ||
} |