diff --git a/examples/account/model/account.php b/examples/account/model/account.php new file mode 100644 index 00000000..aa109d22 --- /dev/null +++ b/examples/account/model/account.php @@ -0,0 +1,26 @@ + + * @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); + +$accountRepository = new \Tmdb\Repository\AccountRepository($client); +$account = $accountRepository->getAccount(); + +var_dump($account); + diff --git a/examples/account/model/favorite.php b/examples/account/model/favorite.php new file mode 100644 index 00000000..4d195cb4 --- /dev/null +++ b/examples/account/model/favorite.php @@ -0,0 +1,29 @@ + + * @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); + +/** + * @var \Tmdb\Repository\AccountRepository $accountRepository + */ +$accountRepository = new \Tmdb\Repository\AccountRepository($client); +$lists = $accountRepository->favorite(TMDB_ACCOUNT_ID, 150); + +var_dump($lists); + diff --git a/examples/account/model/favorite_movies.php b/examples/account/model/favorite_movies.php new file mode 100644 index 00000000..77b4d28c --- /dev/null +++ b/examples/account/model/favorite_movies.php @@ -0,0 +1,29 @@ + + * @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); + +/** + * @var \Tmdb\Repository\AccountRepository $accountRepository + */ +$accountRepository = new \Tmdb\Repository\AccountRepository($client); +$lists = $accountRepository->getFavoriteMovies(TMDB_ACCOUNT_ID); + +var_dump($lists); + diff --git a/examples/account/model/lists.php b/examples/account/model/lists.php new file mode 100644 index 00000000..6f8f6ca1 --- /dev/null +++ b/examples/account/model/lists.php @@ -0,0 +1,29 @@ + + * @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); + +/** + * @var \Tmdb\Repository\AccountRepository $accountRepository + */ +$accountRepository = new \Tmdb\Repository\AccountRepository($client); +$lists = $accountRepository->getLists(TMDB_ACCOUNT_ID); + +var_dump($lists); + diff --git a/examples/account/model/movie_watchlist.php b/examples/account/model/movie_watchlist.php new file mode 100644 index 00000000..18542f82 --- /dev/null +++ b/examples/account/model/movie_watchlist.php @@ -0,0 +1,29 @@ + + * @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); + +/** + * @var \Tmdb\Repository\AccountRepository $accountRepository + */ +$accountRepository = new \Tmdb\Repository\AccountRepository($client); +$lists = $accountRepository->getMovieWatchlist(TMDB_ACCOUNT_ID); + +var_dump($lists); + diff --git a/examples/account/model/rated_movies.php b/examples/account/model/rated_movies.php new file mode 100644 index 00000000..a1e0f957 --- /dev/null +++ b/examples/account/model/rated_movies.php @@ -0,0 +1,29 @@ + + * @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); + +/** + * @var \Tmdb\Repository\AccountRepository $accountRepository + */ +$accountRepository = new \Tmdb\Repository\AccountRepository($client); +$lists = $accountRepository->getRatedMovies(TMDB_ACCOUNT_ID); + +var_dump($lists); + diff --git a/examples/account/model/watchlist.php b/examples/account/model/watchlist.php new file mode 100644 index 00000000..00de319e --- /dev/null +++ b/examples/account/model/watchlist.php @@ -0,0 +1,29 @@ + + * @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); + +/** + * @var \Tmdb\Repository\AccountRepository $accountRepository + */ +$accountRepository = new \Tmdb\Repository\AccountRepository($client); +$lists = $accountRepository->watchlist(TMDB_ACCOUNT_ID, 49047); + +var_dump($lists); + diff --git a/examples/lists/model/get.php b/examples/lists/model/get.php index b864e16d..8107437c 100644 --- a/examples/lists/model/get.php +++ b/examples/lists/model/get.php @@ -16,6 +16,9 @@ $token = new \Tmdb\ApiToken(TMDB_API_KEY); $client = new \Tmdb\Client($token); +$sessionToken = new \Tmdb\SessionToken(TMDB_SESSION_TOKEN); +$client->setSessionToken($sessionToken); + $repository = new \Tmdb\Repository\ListRepository($client); $list = $repository->load('509ec17b19c2950a0600050d'); diff --git a/examples/lists/model/item_status.php b/examples/lists/model/item_status.php index ab3e31b8..570aa4ac 100644 --- a/examples/lists/model/item_status.php +++ b/examples/lists/model/item_status.php @@ -16,7 +16,10 @@ $token = new \Tmdb\ApiToken(TMDB_API_KEY); $client = new \Tmdb\Client($token); +$sessionToken = new \Tmdb\SessionToken(TMDB_SESSION_TOKEN); +$client->setSessionToken($sessionToken); + $repository = new \Tmdb\Repository\ListRepository($client); -$list = $repository->getItemStatus('509ec17b19c2950a0600050d'); +$list = $repository->getItemStatus('509ec17b19c2950a0600050d', 150); var_dump($list); \ No newline at end of file diff --git a/examples/movies/model/account_states.php b/examples/movies/model/account_states.php new file mode 100644 index 00000000..921e9712 --- /dev/null +++ b/examples/movies/model/account_states.php @@ -0,0 +1,25 @@ + + * @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); + +$repository = new \Tmdb\Repository\MovieRepository($client); +$accountStates = $repository->getAccountStates(97020); + +var_dump($accountStates); \ No newline at end of file diff --git a/examples/movies/model/rate.php b/examples/movies/model/rate.php new file mode 100644 index 00000000..e24ed605 --- /dev/null +++ b/examples/movies/model/rate.php @@ -0,0 +1,25 @@ + + * @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); + +$repository = new \Tmdb\Repository\MovieRepository($client); +$rate = $repository->rate(49047, 6.5); + +var_dump($rate); \ No newline at end of file diff --git a/lib/Tmdb/Factory/AccountFactory.php b/lib/Tmdb/Factory/AccountFactory.php new file mode 100644 index 00000000..3b1559f9 --- /dev/null +++ b/lib/Tmdb/Factory/AccountFactory.php @@ -0,0 +1,97 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +namespace Tmdb\Factory; + +use Tmdb\Exception\NotImplementedException; +use Tmdb\Model\Account; +use Tmdb\Model\Lists\Result; + +class AccountFactory extends AbstractFactory +{ + /** + * @var MovieFactory + */ + private $movieFactory; + + public function __construct() + { + $this->movieFactory = new MovieFactory(); + } + + /** + * @param array $data + * + * @return Account + */ + public function create(array $data = array()) + { + return $this->hydrate(new Account(), $data); + } + + /** + * @param array $data + * + * @return Result + */ + public function createStatusResult(array $data = array()) + { + return $this->hydrate(new Result(), $data); + } + + /** + * Create movie + * + * @param array $data + * @return \Tmdb\Model\Movie + */ + public function createMovie(array $data = array()) { + return $this->getMovieFactory()->create($data); + } + + /** + * Create list item + * + * @param array $data + * @return \Tmdb\Model\AbstractModel + */ + public function createListItem(array $data = array()) + { + return $this->hydrate(new Account\ListItem(), $data); + } + + /** + * {@inheritdoc} + */ + public function createCollection(array $data = array()) + { + throw new NotImplementedException('Not implemented'); + } + + /** + * @param \Tmdb\Factory\MovieFactory $movieFactory + * @return $this + */ + public function setMovieFactory($movieFactory) + { + $this->movieFactory = $movieFactory; + return $this; + } + + /** + * @return \Tmdb\Factory\MovieFactory + */ + public function getMovieFactory() + { + return $this->movieFactory; + } +} diff --git a/lib/Tmdb/Factory/MovieFactory.php b/lib/Tmdb/Factory/MovieFactory.php index 810503d3..505c6e97 100644 --- a/lib/Tmdb/Factory/MovieFactory.php +++ b/lib/Tmdb/Factory/MovieFactory.php @@ -20,6 +20,7 @@ use Tmdb\Model\Common\GenericCollection; use Tmdb\Model\Common\Trailer\Youtube; use Tmdb\Model\Common\Translation; +use Tmdb\Model\Lists\Result; use Tmdb\Model\Movie; class MovieFactory extends AbstractFactory { @@ -181,6 +182,45 @@ public function createCollection(array $data = array()) return $collection; } + /** + * Create result + * + * @param array $data + * @return \Tmdb\Model\AbstractModel + */ + public function createResult(array $data = array()) { + return $this->hydrate(new Result(), $data); + } + + /** + * Create rating + * + * @param array $data + * @return \Tmdb\Model\AbstractModel + */ + public function createRating(array $data = array()) { + return $this->hydrate(new Movie\Rating(), $data); + } + + /** + * Create the account states + * + * @param array $data + * @return \Tmdb\Model\AbstractModel + */ + public function createAccountStates(array $data = array()) + { + $accountStates = new Movie\AccountStates(); + + if (array_key_exists('rated', $data)) { + $rating = new Movie\Rating(); + + $accountStates->setRated($this->hydrate($rating, $data['rated'])); + } + + return $this->hydrate($accountStates, $data); + } + /** * @param \Tmdb\Factory\People\CastFactory $castFactory * @return $this diff --git a/lib/Tmdb/Model/Account.php b/lib/Tmdb/Model/Account.php new file mode 100644 index 00000000..e7a9e17a --- /dev/null +++ b/lib/Tmdb/Model/Account.php @@ -0,0 +1,167 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +namespace Tmdb\Model; + +class Account extends AbstractModel { + /** + * @var integer + */ + private $id; + + /** + * @var boolean + */ + private $includeAdult; + + /** + * @var string + */ + private $iso31661; + + /** + * @var string + */ + private $iso6391; + + /** + * @var string + */ + private $name; + + /** + * @var string + */ + private $username; + + /** + * @var array + */ + public static $_properties = array( + 'id', + 'include_adult', + 'iso_3166_1', + 'iso_639_1', + 'name', + 'username' + ); + + /** + * @param int $id + * @return $this + */ + public function setId($id) + { + $this->id = $id; + return $this; + } + + /** + * @return int + */ + public function getId() + { + return $this->id; + } + + /** + * @param boolean $includeAdult + * @return $this + */ + public function setIncludeAdult($includeAdult) + { + $this->includeAdult = $includeAdult; + return $this; + } + + /** + * @return boolean + */ + public function getIncludeAdult() + { + return $this->includeAdult; + } + + /** + * @param string $iso31661 + * @return $this + */ + public function setIso31661($iso31661) + { + $this->iso31661 = $iso31661; + return $this; + } + + /** + * @return string + */ + public function getIso31661() + { + return $this->iso31661; + } + + /** + * @param string $iso6391 + * @return $this + */ + public function setIso6391($iso6391) + { + $this->iso6391 = $iso6391; + return $this; + } + + /** + * @return string + */ + public function getIso6391() + { + return $this->iso6391; + } + + /** + * @param string $name + * @return $this + */ + public function setName($name) + { + $this->name = $name; + return $this; + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @param string $username + * @return $this + */ + public function setUsername($username) + { + $this->username = $username; + return $this; + } + + /** + * @return string + */ + public function getUsername() + { + return $this->username; + } + + +} diff --git a/lib/Tmdb/Model/Account/ListItem.php b/lib/Tmdb/Model/Account/ListItem.php new file mode 100644 index 00000000..3d3b8aa5 --- /dev/null +++ b/lib/Tmdb/Model/Account/ListItem.php @@ -0,0 +1,239 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +namespace Tmdb\Model\Account; + +use Tmdb\Model\AbstractModel; +use Tmdb\Model\Image\PosterImage; + +class ListItem extends AbstractModel { + /** + * @var string + */ + private $id; + + /** + * @var string + */ + private $description; + + /** + * @var int + */ + private $favoriteCount; + + /** + * @var int + */ + private $itemCount; + + /** + * @var string + */ + private $iso6391; + + /** + * @var string + */ + private $listType; + + /** + * @var string + */ + private $name; + + /** + * @var string + */ + private $posterPath; + + /** + * @var PosterImage + */ + private $posterImage; + + /** + * @var array + */ + public static $_properties = array( + 'description', + 'favorite_count', + 'id', + 'item_count', + 'iso_639_1', + 'list_type', + 'name', + 'poster_path' + ); + + /** + * @param string $description + * @return $this + */ + public function setDescription($description) + { + $this->description = $description; + return $this; + } + + /** + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * @param int $favoriteCount + * @return $this + */ + public function setFavoriteCount($favoriteCount) + { + $this->favoriteCount = $favoriteCount; + return $this; + } + + /** + * @return int + */ + public function getFavoriteCount() + { + return $this->favoriteCount; + } + + /** + * @param string $id + * @return $this + */ + public function setId($id) + { + $this->id = $id; + return $this; + } + + /** + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * @param string $iso6391 + * @return $this + */ + public function setIso6391($iso6391) + { + $this->iso6391 = $iso6391; + return $this; + } + + /** + * @return string + */ + public function getIso6391() + { + return $this->iso6391; + } + + /** + * @param int $itemCount + * @return $this + */ + public function setItemCount($itemCount) + { + $this->itemCount = $itemCount; + return $this; + } + + /** + * @return int + */ + public function getItemCount() + { + return $this->itemCount; + } + + /** + * @param string $listType + * @return $this + */ + public function setListType($listType) + { + $this->listType = $listType; + return $this; + } + + /** + * @return string + */ + public function getListType() + { + return $this->listType; + } + + /** + * @param string $name + * @return $this + */ + public function setName($name) + { + $this->name = $name; + return $this; + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @param \Tmdb\Model\Image\PosterImage $posterImage + * @return $this + */ + public function setPosterImage($posterImage) + { + $this->posterImage = $posterImage; + return $this; + } + + /** + * @return \Tmdb\Model\Image\PosterImage + */ + public function getPosterImage() + { + return $this->posterImage; + } + + /** + * @param string $posterPath + * @return $this + */ + public function setPosterPath($posterPath) + { + $this->posterPath = $posterPath; + return $this; + } + + /** + * @return string + */ + public function getPosterPath() + { + return $this->posterPath; + } +} diff --git a/lib/Tmdb/Model/Movie/AccountStates.php b/lib/Tmdb/Model/Movie/AccountStates.php new file mode 100644 index 00000000..bae93379 --- /dev/null +++ b/lib/Tmdb/Model/Movie/AccountStates.php @@ -0,0 +1,116 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +namespace Tmdb\Model\Movie; + +use Tmdb\Model\AbstractModel; + +class AccountStates extends AbstractModel { + + /** + * @var integer + */ + private $id; + + /** + * @var boolean + */ + private $favorite; + + /** + * @var Rating + */ + private $rated; + + /** + * @var boolean + */ + private $watchlist; + + public static $_properties = array( + 'id', + 'favorite', + 'watchlist', + ); + + /** + * @param boolean $favorite + * @return $this + */ + public function setFavorite($favorite) + { + $this->favorite = $favorite; + return $this; + } + + /** + * @return boolean + */ + public function getFavorite() + { + return $this->favorite; + } + + /** + * @param int $id + * @return $this + */ + public function setId($id) + { + $this->id = $id; + return $this; + } + + /** + * @return int + */ + public function getId() + { + return $this->id; + } + + /** + * @param \Tmdb\Model\Movie\Rating $rated + * @return $this + */ + public function setRated($rated) + { + $this->rated = $rated; + return $this; + } + + /** + * @return \Tmdb\Model\Movie\Rating + */ + public function getRated() + { + return $this->rated; + } + + /** + * @param boolean $watchlist + * @return $this + */ + public function setWatchlist($watchlist) + { + $this->watchlist = $watchlist; + return $this; + } + + /** + * @return boolean + */ + public function getWatchlist() + { + return $this->watchlist; + } +} diff --git a/lib/Tmdb/Model/Movie/Rating.php b/lib/Tmdb/Model/Movie/Rating.php new file mode 100644 index 00000000..41a09e02 --- /dev/null +++ b/lib/Tmdb/Model/Movie/Rating.php @@ -0,0 +1,45 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +namespace Tmdb\Model\Movie; + +use Tmdb\Model\AbstractModel; + +class Rating extends AbstractModel { + + /** + * @var float + */ + private $value; + + public static $_properties = array( + 'value', + ); + + /** + * @param float $value + * @return $this + */ + public function setValue($value) + { + $this->value = $value; + return $this; + } + + /** + * @return float + */ + public function getValue() + { + return $this->value; + } +} diff --git a/lib/Tmdb/Repository/AccountRepository.php b/lib/Tmdb/Repository/AccountRepository.php new file mode 100644 index 00000000..f2e1f749 --- /dev/null +++ b/lib/Tmdb/Repository/AccountRepository.php @@ -0,0 +1,142 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +namespace Tmdb\Repository; + +use Tmdb\Factory\AccountFactory; +use Tmdb\Model\Collection\ResultCollection; +use Tmdb\Model\Movie; + +class AccountRepository extends AbstractRepository { + + /** + * Get the basic information for an account. You will need to have a valid session id. + * + * @return null|\Tmdb\Model\AbstractModel + */ + public function getAccount() + { + $data = $this->getApi()->getAccount(); + return $this->getFactory()->create($data); + } + + /** + * Get the lists that you have created and marked as a favorite. + * + * @param string $accountId + * @param array $parameters + * @param array $headers + * @return ResultCollection + */ + public function getLists($accountId, array $parameters = array(), array $headers = array()) + { + $data = $this->getApi()->getLists($accountId, $parameters, $headers); + return $this->getFactory()->createResultCollection($data, 'createListItem'); + } + + /** + * Get the list of favorite movies for an account. + * + * @param string $accountId + * @param array $parameters + * @param array $headers + * @return ResultCollection + */ + public function getFavoriteMovies($accountId, array $parameters = array(), array $headers = array()) + { + $data = $this->getApi()->getFavoriteMovies($accountId, $parameters, $headers); + return $this->getFactory()->createResultCollection($data, 'createMovie'); + } + + + /** + * Add or remove a movie to an accounts favorite list. + * + * @param string $accountId + * @param int|Movie $movie + * @param boolean $isFavorite + * @return ResultCollection + */ + public function favorite($accountId, $movie, $isFavorite = true) + { + if ($movie instanceof Movie) { + $movie = $movie->getId(); + } + + $data = $this->getApi()->favorite($accountId, $movie, $isFavorite); + return $this->getFactory()->createStatusResult($data); + } + + /** + * Get the list of rated movies (and associated rating) for an account. + * + * @param string $accountId + * @param array $parameters + * @param array $headers + * @return ResultCollection + */ + public function getRatedMovies($accountId, array $parameters = array(), array $headers = array()) + { + $data = $this->getApi()->getRatedMovies($accountId, $parameters, $headers); + return $this->getFactory()->createResultCollection($data, 'createMovie'); + } + + /** + * Get the list of movies on an accounts watchlist. + * + * @param string $accountId + * @param array $parameters + * @param array $headers + * @return ResultCollection + */ + public function getMovieWatchlist($accountId, array $parameters = array(), array $headers = array()) + { + $data = $this->getApi()->getMovieWatchlist($accountId, $parameters, $headers); + return $this->getFactory()->createResultCollection($data, 'createMovie'); + } + + /** + * Add or remove a movie to an accounts watch list. + * + * @param string $accountId + * @param int|Movie $movie + * @param boolean $isOnWatchlist + * @return ResultCollection + */ + public function watchlist($accountId, $movie, $isOnWatchlist = true) + { + if ($movie instanceof Movie) { + $movie = $movie->getId(); + } + + $data = $this->getApi()->watchlist($accountId, $movie, $isOnWatchlist); + return $this->getFactory()->createStatusResult($data); + } + + /** + * Return the Collection API Class + * + * @return \Tmdb\Api\Account + */ + public function getApi() + { + return $this->getClient()->getAccountApi(); + } + + /** + * @return AccountFactory + */ + public function getFactory() + { + return new AccountFactory(); + } +} diff --git a/lib/Tmdb/Repository/MovieRepository.php b/lib/Tmdb/Repository/MovieRepository.php index 2c288ed8..e8753ad9 100644 --- a/lib/Tmdb/Repository/MovieRepository.php +++ b/lib/Tmdb/Repository/MovieRepository.php @@ -23,6 +23,21 @@ class MovieRepository extends AbstractRepository { + /** + * @var ImageFactory + */ + private $imageFactory; + + /** + * @var AlternativeTitleFactory + */ + private $alternativeTitleFactory; + + /** + * @var PeopleFactory + */ + private $peopleFactory; + /** * Load a movie with the given identifier * @@ -307,6 +322,33 @@ public function getTopRated(array $options = 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. + * + * @param integer $id + * @return Movie[] + */ + public function getAccountStates($id) + { + return $this->getFactory()->createAccountStates( + $this->getApi()->getAccountStates($id) + ); + } + + /** + * This method lets users rate a movie. A valid session id or guest session id is required. + * + * @param integer $id + * @param float $rating + * @return Movie[] + */ + public function rate($id, $rating) + { + return $this->getFactory()->createResult( + $this->getApi()->rateMovie($id, $rating) + ); + } + /** * Return the Movies API Class * @@ -338,39 +380,39 @@ private function createCollection($data){ } /** - * @param mixed $alternativeTitlesFactory + * @param mixed $alternativeTitleFactory * @return $this */ - public function setAlternativeTitlesFactory($alternativeTitlesFactory) + public function setAlternativeTitleFactory($alternativeTitleFactory) { - $this->alternativeTitlesFactory = $alternativeTitlesFactory; + $this->alternativeTitleFactory = $alternativeTitleFactory; return $this; } /** * @return mixed */ - public function getAlternativeTitlesFactory() + public function getAlternativeTitleFactory() { - return $this->alternativeTitlesFactory; + return $this->alternativeTitleFactory; } /** - * @param mixed $imagesFactory + * @param mixed $imageFactory * @return $this */ - public function setImagesFactory($imagesFactory) + public function setImageFactory($imageFactory) { - $this->imagesFactory = $imagesFactory; + $this->imageFactory = $imageFactory; return $this; } /** * @return mixed */ - public function getImagesFactory() + public function getImageFactory() { - return $this->imagesFactory; + return $this->imageFactory; } /** diff --git a/test/Tmdb/Tests/Repository/MovieRepositoryTest.php b/test/Tmdb/Tests/Repository/MovieRepositoryTest.php index a44bf7f8..33c66db1 100644 --- a/test/Tmdb/Tests/Repository/MovieRepositoryTest.php +++ b/test/Tmdb/Tests/Repository/MovieRepositoryTest.php @@ -200,12 +200,12 @@ public function shouldBeAbleToSetFactories() $repository = $this->getRepositoryWithMockedHttpClient(); $class = new \stdClass(); - $repository->setAlternativeTitlesFactory($class); - $repository->setImagesFactory($class); + $repository->setAlternativeTitleFactory($class); + $repository->setImageFactory($class); $repository->setPeopleFactory($class); - $this->assertInstanceOf('stdClass', $repository->getAlternativeTitlesFactory()); - $this->assertInstanceOf('stdClass', $repository->getImagesFactory()); + $this->assertInstanceOf('stdClass', $repository->getAlternativeTitleFactory()); + $this->assertInstanceOf('stdClass', $repository->getImageFactory()); $this->assertInstanceOf('stdClass', $repository->getPeopleFactory()); }