Skip to content

Commit

Permalink
Implemented functions into the Account API, just adding movies to a w…
Browse files Browse the repository at this point in the history
…atchlist or favoriting them does not function, need to get back at this later.
  • Loading branch information
wtfzdotnet committed Feb 25, 2014
1 parent f64a18a commit 6ff4e31
Show file tree
Hide file tree
Showing 6 changed files with 156 additions and 18 deletions.
24 changes: 24 additions & 0 deletions examples/account/api/favorite.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);

$favorite = $client->getAccountApi()->favorite(TMDB_ACCOUNT_ID, 97020, true);

var_dump($favorite);
24 changes: 24 additions & 0 deletions examples/account/api/favorite_movies.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);

$favorite_movies = $client->getAccountApi()->getFavoriteMovies(TMDB_ACCOUNT_ID);

var_dump($favorite_movies);
24 changes: 24 additions & 0 deletions examples/account/api/rated_movies.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);

$rated_movies = $client->getAccountApi()->getRatedMovies(TMDB_ACCOUNT_ID);

var_dump($rated_movies);
24 changes: 24 additions & 0 deletions examples/account/api/watchlist.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);

$watchlist = $client->getAccountApi()->watchlist(TMDB_ACCOUNT_ID, 97020, true);

var_dump($watchlist);
24 changes: 24 additions & 0 deletions examples/account/api/watchlist_movies.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);

$watchlist_movies = $client->getAccountApi()->getMovieWatchlist(TMDB_ACCOUNT_ID);

var_dump($watchlist_movies);
54 changes: 36 additions & 18 deletions lib/Tmdb/Api/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,68 +32,86 @@ public function getAccount(array $parameters = array(), array $headers = array()
/**
* Get the lists that you have created and marked as a favorite.
*
* @param integer $id
* @param integer $accountId
* @param array $parameters
* @param array $headers
* @return mixed
*/
public function getLists($id, array $parameters = array(), array $headers = array())
public function getLists($accountId, array $parameters = array(), array $headers = array())
{
return $this->get('account/' . $id . '/lists', $parameters, $headers);
return $this->get('account/' . $accountId . '/lists', $parameters, $headers);
}

/**
* Get the list of favorite movies for an account.
*
* @throws NotImplementedException
* @param integer $accountId
* @param array $parameters
* @param array $headers
* @return mixed
*/
public function getFavoriteMovies()
public function getFavoriteMovies($accountId, array $parameters = array(), array $headers = array())
{
throw new NotImplementedException(__METHOD__ . ' has not been implemented yet.');
return $this->get('account/' . $accountId . '/favorite_movies', $parameters, $headers);
}

/**
* Add or remove a movie to an accounts favorite list.
*
* @throws NotImplementedException
* @param integer $accountId
* @param integer $movieId
* @param boolean $isFavorite
* @return mixed
* @todo refuses to function? review
*/
public function favorite()
public function favorite($accountId, $movieId, $isFavorite = true)
{
throw new NotImplementedException(__METHOD__ . ' has not been implemented yet.');
return $this->post('account/' . $accountId . '/favorite', json_encode(array(
'movie_id' => $movieId,
'favorite' => $isFavorite
)));
}

/**
* Get the list of rated movies (and associated rating) for an account.
*
* @throws NotImplementedException
* @param integer $accountId
* @param array $parameters
* @param array $headers
* @return mixed
*/
public function getRatedMovies()
public function getRatedMovies($accountId, array $parameters = array(), array $headers = array())
{
throw new NotImplementedException(__METHOD__ . ' has not been implemented yet.');
return $this->get('account/' . $accountId . '/rated_movies', $parameters, $headers);
}

/**
* Get the list of movies on an accounts watchlist.
*
* @throws NotImplementedException
* @param integer $accountId
* @param array $parameters
* @param array $headers
* @return mixed
*/
public function getMovieWatchlist()
public function getMovieWatchlist($accountId, array $parameters = array(), array $headers = array())
{
throw new NotImplementedException(__METHOD__ . ' has not been implemented yet.');
return $this->get('account/' . $accountId . '/movie_watchlist', $parameters, $headers);
}

/**
* Add or remove a movie to an accounts watch list.
*
* @throws NotImplementedException
* @param integer $accountId
* @param integer $movieId
* @param boolean $isOnWatchlist
* @return mixed
* @todo refuses to function? review
*/
public function watchlist()
public function watchlist($accountId, $movieId, $isOnWatchlist = true)
{
throw new NotImplementedException(__METHOD__ . ' has not been implemented yet.');
return $this->post('account/' . $accountId . '/movie_watchlist', json_encode(array(
'movie_id' => $movieId,
'movie_watchlist' => $isOnWatchlist
)));
}
}

0 comments on commit 6ff4e31

Please sign in to comment.