Skip to content

Commit

Permalink
Merge pull request #7 from mdietger/master
Browse files Browse the repository at this point in the history
Added users functionality for Twitch API V5
  • Loading branch information
PetterKraabol committed Mar 22, 2017
2 parents f7a6b1c + 1af4a1d commit d8b7b24
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
15 changes: 15 additions & 0 deletions docs/users.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ User objects, followings and followed videos.
// User object
user($user);

// Get the users by username
$options = [
'login' => 'username',
];
users($options)

// Authenticated user object
authUser($token);

Expand Down Expand Up @@ -43,6 +49,15 @@ class UsersController extends Controller
return TwitchApi::user('zarlach');
}

public function users()
{
$options = [
'login' => 'username',
];

return TwitchApi::users($options);
}

public function authUser()
{
TwitchApi::setToken('xxxxxxxxxxxxxx');
Expand Down
14 changes: 14 additions & 0 deletions src/API/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ public function user($user)
return $this->sendRequest('GET', 'users/'.$user);
}

/**
* Users object
*
* @param $options List options
*
* @return JSON Users object
*/
public function users($options)
{
$availableOptions = ['login'];

return $this->sendRequest('GET', 'users', false, $options, $availableOptions);
}

/**
* Authenticated user object.
*
Expand Down
7 changes: 7 additions & 0 deletions src/Services/TwitchApiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,13 @@ public function user($user)
return $users->user($user);
}

public function users($options)
{
$users = new Users();

return $users->users($options);
}

public function authUser($token = null)
{
$users = new Users();
Expand Down

0 comments on commit d8b7b24

Please sign in to comment.