mirror of
https://github.com/quentin-g-dev/afup.git
synced 2026-03-26 02:02:15 +01:00
33 lines
829 B
PHP
33 lines
829 B
PHP
<?php
|
|
|
|
namespace AppBundle\Slack;
|
|
|
|
class LegacyClient
|
|
{
|
|
private $token;
|
|
|
|
public function __construct($token)
|
|
{
|
|
$this->token = $token;
|
|
}
|
|
|
|
public function invite($email)
|
|
{
|
|
$return = file_get_contents(sprintf("https://slack.com/api/users.admin.invite?token=%s&email=%s", $this->token, $email));
|
|
|
|
if (false === $return) {
|
|
throw new \RuntimeException("Erreur lors de l'appel à l'API slack");
|
|
}
|
|
|
|
$decodedContent = json_decode($return, true);
|
|
|
|
if (false === $decodedContent) {
|
|
throw new \RuntimeException("Erreur lecture retour API slack");
|
|
}
|
|
|
|
if (false === $decodedContent["ok"]) {
|
|
throw new \RuntimeException(sprintf("Erreur sur le retour de l'appel slack : %s", $decodedContent['error']));
|
|
}
|
|
}
|
|
}
|