Skip to content

Commit

Permalink
Implementing more account related functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfzdotnet committed Feb 25, 2014
1 parent 6ff4e31 commit 2a16170
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 18 deletions.
24 changes: 24 additions & 0 deletions examples/movies/api/account_states.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
/**
* This file is part of the Tmdb PHP API created by Michael Roterman.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package Tmdb
* @author Michael Roterman <[email protected]>
* @copyright (c) 2013, Michael Roterman
* @version 0.0.1
*/
require_once('../../../vendor/autoload.php');
require_once('../../../apikey.php');

$token = new \Tmdb\ApiToken(TMDB_API_KEY);
$client = new \Tmdb\Client($token);

$sessionToken = new \Tmdb\SessionToken(TMDB_SESSION_TOKEN);
$client->setSessionToken($sessionToken);

$accountStates = $client->getMoviesApi()->getAccountStates(550, true);

var_dump($accountStates);
2 changes: 1 addition & 1 deletion examples/movies/api/images.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @copyright (c) 2013, Michael Roterman
* @version 0.0.1
*/
require_once('vendor/autoload.php');
require_once('../../../vendor/autoload.php');
require_once('../../../apikey.php');

$token = new \Tmdb\ApiToken(TMDB_API_KEY);
Expand Down
24 changes: 24 additions & 0 deletions examples/movies/api/movie_rating.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
/**
* This file is part of the Tmdb PHP API created by Michael Roterman.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package Tmdb
* @author Michael Roterman <[email protected]>
* @copyright (c) 2013, Michael Roterman
* @version 0.0.1
*/
require_once('../../../vendor/autoload.php');
require_once('../../../apikey.php');

$token = new \Tmdb\ApiToken(TMDB_API_KEY);
$client = new \Tmdb\Client($token);

$sessionToken = new \Tmdb\SessionToken(TMDB_SESSION_TOKEN);
$client->setSessionToken($sessionToken);

$rating = $client->getMoviesApi()->rateMovie(550, 8.5);

var_dump($rating);
16 changes: 10 additions & 6 deletions lib/Tmdb/Api/Movies.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,22 +234,26 @@ public function getTopRated(array $parameters = array(), array $headers = array(
}

/**
* This method lets users get the status of whether or not the movie has been rated or added to their favourite or watch lists. A valid session id is required.
* This method lets users get the status of whether or not the movie has been rated or added to their favourite or watch lists.
*
* A valid session id is required.
*
* @throws \Tmdb\Exception\NotImplementedException
*/
public function getAccountStates()
public function getAccountStates($id)
{
throw new NotImplementedException('TMDB account sessions have not been implemented yet!');
return $this->get('movie/' . $id . '/account_states');
}

/**
* TThis method lets users rate a movie. A valid session id or guest session id is required.
* TThis method lets users rate a movie.
*
* A valid session id or guest session id is required.
*
* @throws \Tmdb\Exception\NotImplementedException
*/
public function rateMovie()
public function rateMovie($id, $rating)
{
throw new NotImplementedException('TMDB account sessions have not been implemented yet!');
return $this->post('movie/' . $id . '/rating', json_encode(array('value' => (float) $rating)));
}
}
10 changes: 2 additions & 8 deletions test/Tmdb/Tests/Api/AccountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public function shouldGetAccount()

/**
* @test
* @expectedException Tmdb\Exception\NotImplementedException
*/
public function shouldGetLists()
{
Expand All @@ -35,7 +34,6 @@ public function shouldGetLists()

/**
* @test
* @expectedException Tmdb\Exception\NotImplementedException
*/
public function shouldGetFavoriteMovies()
{
Expand All @@ -45,17 +43,15 @@ public function shouldGetFavoriteMovies()

/**
* @test
* @expectedException Tmdb\Exception\NotImplementedException
*/
public function shouldFavorite()
{
$api = $this->getApiMock();
$api->favorite('account_id');
$api->favorite('account_id', true);
}

/**
* @test
* @expectedException Tmdb\Exception\NotImplementedException
*/
public function shouldGetRatedMovies()
{
Expand All @@ -65,7 +61,6 @@ public function shouldGetRatedMovies()

/**
* @test
* @expectedException Tmdb\Exception\NotImplementedException
*/
public function shouldGetMovieWatchlist()
{
Expand All @@ -75,12 +70,11 @@ public function shouldGetMovieWatchlist()

/**
* @test
* @expectedException Tmdb\Exception\NotImplementedException
*/
public function shouldWatchlist()
{
$api = $this->getApiMock();
$api->watchlist('account_id');
$api->watchlist('account_id', true);
}

protected function getApiClass() {
Expand Down
4 changes: 1 addition & 3 deletions test/Tmdb/Tests/Api/MoviesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ public function shouldGetTopRated()

/**
* @test
* @expectedException Tmdb\Exception\NotImplementedException
*/
public function shouldGetAccountStates()
{
Expand All @@ -249,12 +248,11 @@ public function shouldGetAccountStates()

/**
* @test
* @expectedException Tmdb\Exception\NotImplementedException
*/
public function shouldRateMovie()
{
$api = $this->getApiMock();
$api->rateMovie(self::MOVIE_ID);
$api->rateMovie(self::MOVIE_ID, 7.5);
}

protected function getApiClass() {
Expand Down

0 comments on commit 2a16170

Please sign in to comment.