Skip to content

Commit

Permalink
Added user VHS endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklaw5 committed Apr 2, 2017
1 parent c21c7d5 commit 4870ae4
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions src/Api/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace TwitchApi\Api;

use TwitchApi\Exceptions\EndpointNotSupportedByApiVersionException;
use TwitchApi\Exceptions\InvalidIdentifierException;
use TwitchApi\Exceptions\InvalidLimitException;
use TwitchApi\Exceptions\InvalidOffsetException;
Expand Down Expand Up @@ -278,4 +279,57 @@ public function unblockUser($userIdentifier, $userToUnlockIdentifier, $accessTok

return $this->delete(sprintf('users/%s/blocks/%s', $userIdentifier, $userToUnlockIdentifier), [], $accessToken);
}

/**
* Creates a connection between a user and VHS
*
* @param string $identifier
* @param string $accessToken
* @throws EndpointNotSupportedByApiVersionException
* @return null|array|json
*/
public function createUserVHSConnection($identifier, $accessToken)
{
if (!$this->apiVersionIsGreaterThanV4()) {
throw new EndpointNotSupportedByApiVersionException('vhs');
}

$params = [
'identifier' => $identifier,
];

return $this->put('user/vhs', $params, $accessToken);
}

/**
* Check whether an authenticated Twitch user is connected to VHS
*
* @param string $accessToken
* @throws EndpointNotSupportedByApiVersionException
* @return array|json
*/
public function checkUserVHSConnection($accessToken)
{
if (!$this->apiVersionIsGreaterThanV4()) {
throw new EndpointNotSupportedByApiVersionException('vhs');
}

return $this->get('user/vhs', [], $accessToken);
}

/**
* Delete the connection between an authenticated Twitch user and VHS
*
* @param string $accessToken
* @throws EndpointNotSupportedByApiVersionException
* @return null|array|json
*/
public function deleteUserVHSConnection($accessToken)
{
if (!$this->apiVersionIsGreaterThanV4()) {
throw new EndpointNotSupportedByApiVersionException('vhs');
}

return $this->delete('user/vhs', [], $accessToken);
}
}

0 comments on commit 4870ae4

Please sign in to comment.