diff --git a/examples/tv/model/episode/credits.php b/examples/tv/model/episode/credits.php new file mode 100644 index 00000000..c5bfce65 --- /dev/null +++ b/examples/tv/model/episode/credits.php @@ -0,0 +1,22 @@ + + * @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); + +$repository = new \Tmdb\Repository\TvEpisodeRepository($client); +$tvShow = $repository->getCredits(1396, 1, 1); + +var_dump($tvShow); \ No newline at end of file diff --git a/examples/tv/model/episode/external_ids.php b/examples/tv/model/episode/external_ids.php new file mode 100644 index 00000000..617917b3 --- /dev/null +++ b/examples/tv/model/episode/external_ids.php @@ -0,0 +1,22 @@ + + * @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); + +$repository = new \Tmdb\Repository\TvEpisodeRepository($client); +$tvShow = $repository->getExternalIds(1396, 1, 1); + +var_dump($tvShow); \ No newline at end of file diff --git a/examples/tv/model/episode/images.php b/examples/tv/model/episode/images.php new file mode 100644 index 00000000..647a5513 --- /dev/null +++ b/examples/tv/model/episode/images.php @@ -0,0 +1,22 @@ + + * @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); + +$repository = new \Tmdb\Repository\TvEpisodeRepository($client); +$tvShow = $repository->getImages(1396, 1, 1); + +var_dump($tvShow); \ No newline at end of file diff --git a/examples/tv/model/season/credits.php b/examples/tv/model/season/credits.php new file mode 100644 index 00000000..cc1b43ff --- /dev/null +++ b/examples/tv/model/season/credits.php @@ -0,0 +1,22 @@ + + * @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); + +$repository = new \Tmdb\Repository\TvSeasonRepository($client); +$tvShow = $repository->getCredits(1396, 1); + +var_dump($tvShow); \ No newline at end of file diff --git a/examples/tv/model/season/external_ids.php b/examples/tv/model/season/external_ids.php new file mode 100644 index 00000000..ac07c45f --- /dev/null +++ b/examples/tv/model/season/external_ids.php @@ -0,0 +1,22 @@ + + * @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); + +$repository = new \Tmdb\Repository\TvSeasonRepository($client); +$tvShow = $repository->getExternalIds(1396, 1); + +var_dump($tvShow); \ No newline at end of file diff --git a/examples/tv/model/season/images.php b/examples/tv/model/season/images.php new file mode 100644 index 00000000..84ecddbe --- /dev/null +++ b/examples/tv/model/season/images.php @@ -0,0 +1,22 @@ + + * @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); + +$repository = new \Tmdb\Repository\TvSeasonRepository($client); +$tvShow = $repository->getImages(1396, 1); + +var_dump($tvShow); \ No newline at end of file diff --git a/lib/Tmdb/Api/TvEpisode.php b/lib/Tmdb/Api/TvEpisode.php index c17a82c2..8ca13954 100644 --- a/lib/Tmdb/Api/TvEpisode.php +++ b/lib/Tmdb/Api/TvEpisode.php @@ -40,7 +40,7 @@ public function getEpisode($tvshow_id, $season_number, $episode_number, array $p * @param array $headers * @return mixed */ - public function getEpisodeCredits($tvshow_id, $season_number, $episode_number, array $parameters = array(), array $headers = array()) + public function getCredits($tvshow_id, $season_number, $episode_number, array $parameters = array(), array $headers = array()) { return $this->get(sprintf('tv/%s/season/%s/episode/%s/credits', $tvshow_id, $season_number,$episode_number), $parameters, $headers); } @@ -55,7 +55,7 @@ public function getEpisodeCredits($tvshow_id, $season_number, $episode_number, a * @param array $headers * @return mixed */ - public function getEpisodeExternalIds($tvshow_id, $season_number, $episode_number, array $parameters = array(), array $headers = array()) + public function getExternalIds($tvshow_id, $season_number, $episode_number, array $parameters = array(), array $headers = array()) { return $this->get(sprintf('tv/%s/season/%s/episode/%s/external_ids', $tvshow_id, $season_number,$episode_number), $parameters, $headers); } @@ -70,7 +70,7 @@ public function getEpisodeExternalIds($tvshow_id, $season_number, $episode_numbe * @param array $headers * @return mixed */ - public function getEpisodeImages($tvshow_id, $season_number, $episode_number, array $parameters = array(), array $headers = array()) + public function getImages($tvshow_id, $season_number, $episode_number, array $parameters = array(), array $headers = array()) { return $this->get(sprintf('tv/%s/season/%s/episode/%s/images', $tvshow_id, $season_number,$episode_number), $parameters, $headers); } diff --git a/lib/Tmdb/Api/TvSeason.php b/lib/Tmdb/Api/TvSeason.php index 0f504ca7..11181dea 100644 --- a/lib/Tmdb/Api/TvSeason.php +++ b/lib/Tmdb/Api/TvSeason.php @@ -38,7 +38,7 @@ public function getSeason($tvshow_id, $season_number, array $parameters = array( * @param array $headers * @return mixed */ - public function getSeasonCredits($tvshow_id, $season_number, array $parameters = array(), array $headers = array()) + public function getCredits($tvshow_id, $season_number, array $parameters = array(), array $headers = array()) { return $this->get(sprintf('tv/%s/season/%s/credits', $tvshow_id, $season_number), $parameters, $headers); } @@ -52,7 +52,7 @@ public function getSeasonCredits($tvshow_id, $season_number, array $parameters = * @param array $headers * @return mixed */ - public function getSeasonExternalIds($tvshow_id, $season_number, array $parameters = array(), array $headers = array()) + public function getExternalIds($tvshow_id, $season_number, array $parameters = array(), array $headers = array()) { return $this->get(sprintf('tv/%s/season/%s/external_ids', $tvshow_id, $season_number), $parameters, $headers); } @@ -66,7 +66,7 @@ public function getSeasonExternalIds($tvshow_id, $season_number, array $paramete * @param array $headers * @return mixed */ - public function getSeasonImages($tvshow_id, $season_number, array $parameters = array(), array $headers = array()) + public function getImages($tvshow_id, $season_number, array $parameters = array(), array $headers = array()) { return $this->get(sprintf('tv/%s/season/%s/images', $tvshow_id, $season_number), $parameters, $headers); } diff --git a/lib/Tmdb/Repository/TvEpisodeRepository.php b/lib/Tmdb/Repository/TvEpisodeRepository.php index ccbdd5be..8ee68002 100644 --- a/lib/Tmdb/Repository/TvEpisodeRepository.php +++ b/lib/Tmdb/Repository/TvEpisodeRepository.php @@ -67,6 +67,62 @@ public function load($tvShow, $season, $episode, array $parameters = array(), ar return $this->getFactory()->create($data); } + /** + * Get the cast & crew information about a TV series. + * + * Just like the website, we pull this information from the last season of the series. + * + * @param $id + * @param $season + * @param $episode + * @param $parameters + * @param $headers + * @return null|\Tmdb\Model\AbstractModel + */ + public function getCredits($id, $season, $episode, array $parameters = array(), array $headers = array()) + { + $data = $this->getApi()->getCredits($id, $season, $episode, $this->parseQueryParameters($parameters), $headers); + $episode = $this->getFactory()->create(array('credits' => $data)); + + return $episode->getCredits(); + } + + /** + * Get the external ids that we have stored for a TV series. + * + * @param $id + * @param $season + * @param $episode + * @param $parameters + * @param $headers + * @return null|\Tmdb\Model\AbstractModel + */ + public function getExternalIds($id, $season, $episode, array $parameters = array(), array $headers = array()) + { + $data = $this->getApi()->getExternalIds($id, $season, $episode, $this->parseQueryParameters($parameters), $headers); + $episode = $this->getFactory()->create(array('external_ids' => $data)); + + return $episode->getExternalIds(); + } + + /** + * Get the images (posters and backdrops) for a TV series. + * + * @param $id + * @param $season + * @param $episode + * @param $parameters + * @param $headers + * @return null|\Tmdb\Model\AbstractModel + */ + public function getImages($id, $season, $episode, array $parameters = array(), array $headers = array()) + { + $data = $this->getApi()->getImages($id, $season, $episode, $this->parseQueryParameters($parameters), $headers); + $episode = $this->getFactory()->create(array('images' => $data)); + + return $episode->getImages(); + } + /** * Return the Seasons API Class * diff --git a/lib/Tmdb/Repository/TvSeasonRepository.php b/lib/Tmdb/Repository/TvSeasonRepository.php index ff03f855..1d34b2c2 100644 --- a/lib/Tmdb/Repository/TvSeasonRepository.php +++ b/lib/Tmdb/Repository/TvSeasonRepository.php @@ -62,6 +62,60 @@ public function load($tvShow, $season, array $parameters = array(), array $heade return $this->getFactory()->create($data); } + + /** + * Get the cast & crew information about a TV series. + * + * Just like the website, we pull this information from the last season of the series. + * + * @param $id + * @param $season + * @param $parameters + * @param $headers + * @return null|\Tmdb\Model\AbstractModel + */ + public function getCredits($id, $season, array $parameters = array(), array $headers = array()) + { + $data = $this->getApi()->getCredits($id, $season, $this->parseQueryParameters($parameters), $headers); + $season = $this->getFactory()->create(array('credits' => $data)); + + return $season->getCredits(); + } + + /** + * Get the external ids that we have stored for a TV series. + * + * @param $id + * @param $season + * @param $parameters + * @param $headers + * @return null|\Tmdb\Model\AbstractModel + */ + public function getExternalIds($id, $season, array $parameters = array(), array $headers = array()) + { + $data = $this->getApi()->getExternalIds($id, $season, $this->parseQueryParameters($parameters), $headers); + $season = $this->getFactory()->create(array('external_ids' => $data)); + + return $season->getExternalIds(); + } + + /** + * Get the images (posters and backdrops) for a TV series. + * + * @param $id + * @param $season + * @param $parameters + * @param $headers + * @return null|\Tmdb\Model\AbstractModel + */ + public function getImages($id, $season, array $parameters = array(), array $headers = array()) + { + $data = $this->getApi()->getImages($id, $season, $this->parseQueryParameters($parameters), $headers); + $season = $this->getFactory()->create(array('images' => $data)); + + return $season->getImages(); + } + /** * Return the Seasons API Class * diff --git a/test/Tmdb/Tests/Api/TvEpisodeTest.php b/test/Tmdb/Tests/Api/TvEpisodeTest.php index 21e8cf9f..636d8120 100644 --- a/test/Tmdb/Tests/Api/TvEpisodeTest.php +++ b/test/Tmdb/Tests/Api/TvEpisodeTest.php @@ -41,7 +41,7 @@ public function shouldGetEpisodeCredits() ->method('get') ->with('tv/' . self::TV_ID . '/season/' . self::SEASON_ID . '/episode/' . self::EPISODE_ID . '/credits'); - $api->getEpisodeCredits(self::TV_ID, self::SEASON_ID, self::EPISODE_ID); + $api->getCredits(self::TV_ID, self::SEASON_ID, self::EPISODE_ID); } /** @@ -54,7 +54,7 @@ public function shouldGetEpisodeExternalIds() ->method('get') ->with('tv/' . self::TV_ID . '/season/' . self::SEASON_ID . '/episode/' . self::EPISODE_ID . '/external_ids'); - $api->getEpisodeExternalIds(self::TV_ID, self::SEASON_ID, self::EPISODE_ID); + $api->getExternalIds(self::TV_ID, self::SEASON_ID, self::EPISODE_ID); } /** @@ -67,7 +67,7 @@ public function shouldGetEpisodeImages() ->method('get') ->with('tv/' . self::TV_ID . '/season/' . self::SEASON_ID . '/episode/' . self::EPISODE_ID . '/images'); - $api->getEpisodeImages(self::TV_ID, self::SEASON_ID, self::EPISODE_ID); + $api->getImages(self::TV_ID, self::SEASON_ID, self::EPISODE_ID); } protected function getApiClass() { diff --git a/test/Tmdb/Tests/Api/TvSeasonTest.php b/test/Tmdb/Tests/Api/TvSeasonTest.php index e2c2f177..727e84c4 100644 --- a/test/Tmdb/Tests/Api/TvSeasonTest.php +++ b/test/Tmdb/Tests/Api/TvSeasonTest.php @@ -40,7 +40,7 @@ public function shouldGetSeasonCredits() ->method('get') ->with('tv/' . self::TV_ID . '/season/' . self::SEASON_ID . '/credits'); - $api->getSeasonCredits(self::TV_ID, self::SEASON_ID); + $api->getCredits(self::TV_ID, self::SEASON_ID); } /** @@ -53,7 +53,7 @@ public function shouldGetSeasonExternalIds() ->method('get') ->with('tv/' . self::TV_ID . '/season/' . self::SEASON_ID . '/external_ids'); - $api->getSeasonExternalIds(self::TV_ID, self::SEASON_ID); + $api->getExternalIds(self::TV_ID, self::SEASON_ID); } /** @@ -66,7 +66,7 @@ public function shouldGetSeasonImages() ->method('get') ->with('tv/' . self::TV_ID . '/season/' . self::SEASON_ID . '/images'); - $api->getSeasonImages(self::TV_ID, self::SEASON_ID); + $api->getImages(self::TV_ID, self::SEASON_ID); } protected function getApiClass() {