Skip to content

Commit

Permalink
added TeamModel
Browse files Browse the repository at this point in the history
  • Loading branch information
gnello committed Apr 20, 2017
1 parent 3b0731c commit ef04803
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 19 deletions.
3 changes: 1 addition & 2 deletions .gitignore
@@ -1,3 +1,2 @@
vendor/
lab/
Models/TeamModel.php
lab/
87 changes: 76 additions & 11 deletions src/Models/TeamModel.php
Expand Up @@ -41,12 +41,50 @@ public function getAllTeams()
}

/**
* @param $team_id
* @return \Psr\Http\Message\ResponseInterface
*/
public function getGetTeamMembers($team_id)
public function getAllTeamsUserIsMemberOf()
{
return $this->client->get(self::$endpoint . '/members');
}

/**
* @return \Psr\Http\Message\ResponseInterface
*/
public function getCountUnreadMessagesAndMentionsInTeamsUserIsMemberOf()
{
return $this->client->get(self::$endpoint . '/unread');
}

/**
* @param $team_id
* @param $offset
* @param $limit
* @return null|\Psr\Http\Message\ResponseInterface
*/
public function getTeamMembers($team_id, $offset, $limit)
{
return $this->client->get(self::$endpoint . '/' . $team_id . '/members/' . $offset . '/' . $limit);
}

/**
* @param $team_id
* @param $userId
* @return null|\Psr\Http\Message\ResponseInterface
*/
public function getSingleTeamMember($team_id, $userId)
{
return $this->client->get(self::$endpoint . '/' . $team_id . '/members/' . $userId);
}

/**
* @param $team_id
* @param array $requestOptions
* @return null|\Psr\Http\Message\ResponseInterface
*/
public function getTeamMembersByIds($team_id, array $requestOptions)
{
return $this->client->get(self::$endpoint . '/members/' . $team_id);
return $this->client->post(self::$endpoint . '/' . $team_id . '/members/ids', $requestOptions);
}

/**
Expand All @@ -58,33 +96,60 @@ public function getTeam($team_id)
return $this->client->get(self::$endpoint . '/' . $team_id . '/me');
}

/**
* @param $teamName
* @return \Psr\Http\Message\ResponseInterface
*/
public function getTeamByName($teamName)
{
return $this->client->get(self::$endpoint . '/name/' . $teamName);
}

/**
* @param $team_id
* @param array $requestOptions
* @return \Psr\Http\Message\ResponseInterface
*/
public function updateTeam($team_id, array $requestOptions)
{
return $this->client->post(self::$endpoint . '/teams/' . $team_id . '/update', $requestOptions);
return $this->client->post(self::$endpoint . '/' . $team_id . '/update', $requestOptions);
}

/**
* @param $team_id
* @param $user_id
* @param $team_id
* @return \Psr\Http\Message\ResponseInterface
*/
public function addUser($team_id, $user_id)
public function getStatsOfTeam($team_id)
{
return $this->client->post(self::$endpoint . '/teams/' . $team_id . '/add_user_to_team', compact('user_id'));
return $this->client->get(self::$endpoint . '/' . $team_id . '/stats');
}

/**
* @param $team_id
* @param $user_id
* @param array $requestOptions
* @return \Psr\Http\Message\ResponseInterface
*/
public function removeUser($team_id, $user_id)
public function addUser($team_id, array $requestOptions)
{
return $this->client->post(self::$endpoint . '/' . $team_id . '/add_user_to_team', $requestOptions);
}

/**
* @param $team_id
* @param array $requestOptions
* @return null|\Psr\Http\Message\ResponseInterface
*/
public function removeUser($team_id, array $requestOptions)
{
return $this->client->post(self::$endpoint . '/' . $team_id . '/remove_user_from_team', $requestOptions);
}

/**
* @param $team_id
* @return null|\Psr\Http\Message\ResponseInterface
*/
public function getAllSlashCommandsOfTeam($team_id)
{
return $this->client->post(self::$endpoint . '/teams/' . $team_id . '/remove_user_from_team', compact('user_id'));
return $this->client->get(self::$endpoint . '/' . $team_id . '/commands/list_team_commands');
}
}
12 changes: 6 additions & 6 deletions src/Models/UserModel.php
Expand Up @@ -76,7 +76,7 @@ public function getUsersList($offset, $limit)
*/
public function getUsersListOfTeam($team_id, $offset, $limit)
{
$uri = '/teams/' . $team_id . '/' . self::$endpoint . '/' . $offset . '/' . $limit;
$uri = TeamModel::$endpoint . '/' . $team_id . '/' . self::$endpoint . '/' . $offset . '/' . $limit;
return $this->client->get($uri);
}

Expand Down Expand Up @@ -113,7 +113,7 @@ public function getUserByEmail($email)
*/
public function getUsersListByIds(array $requestOptions)
{
return $this->client->post(self::$endpoint . '/ids/', $requestOptions);
return $this->client->post(self::$endpoint . '/ids', $requestOptions);
}

/**
Expand All @@ -125,7 +125,7 @@ public function getUsersListByIds(array $requestOptions)
*/
public function getUserOfChannel($team_id, $channel_id, $offset, $limit)
{
$uri = '/teams/' . $team_id . '/channels/' . $channel_id . '/' . self::$endpoint . '/' . $offset . '/' . $limit;
$uri = TeamModel::$endpoint . '/' . $team_id . '/channels/' . $channel_id . '/' . self::$endpoint . '/' . $offset . '/' . $limit;
return $this->client->get($uri);
}

Expand All @@ -138,7 +138,7 @@ public function getUserOfChannel($team_id, $channel_id, $offset, $limit)
*/
public function getUserNotOfChannel($team_id, $channel_id, $offset, $limit)
{
$uri = '/teams/' . $team_id . '/channels/' . $channel_id . '/' . self::$endpoint . '/not_in_channel/' . $offset . '/' . $limit;
$uri = TeamModel::$endpoint . '/' . $team_id . '/channels/' . $channel_id . '/' . self::$endpoint . '/not_in_channel/' . $offset . '/' . $limit;
return $this->client->post($uri);
}

Expand Down Expand Up @@ -221,7 +221,7 @@ public function autocompleteUsers(array $requestOptions)
*/
public function autocompleteUsersOfTeam($team_id, array $requestOptions)
{
$uri = '/teams/' . $team_id . '/' . self::$endpoint . '/autocomplete';
$uri = TeamModel::$endpoint . '/' . $team_id . '/' . self::$endpoint . '/autocomplete';
return $this->client->get($uri, $requestOptions);
}

Expand All @@ -233,7 +233,7 @@ public function autocompleteUsersOfTeam($team_id, array $requestOptions)
*/
public function autocompleteUsersOfChannel($team_id, $channel_id, array $requestOptions)
{
$uri = '/teams/' . $team_id . '/channels/' . $channel_id . '/' . self::$endpoint . '/autocomplete';
$uri = TeamModel::$endpoint . '/' . $team_id . '/channels/' . $channel_id . '/' . self::$endpoint . '/autocomplete';
return $this->client->get($uri, $requestOptions);
}
}

0 comments on commit ef04803

Please sign in to comment.