Skip to content

Commit

Permalink
Adding account related methods
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfzdotnet committed Feb 26, 2014
1 parent d958f28 commit 53f109c
Show file tree
Hide file tree
Showing 20 changed files with 1,159 additions and 15 deletions.
26 changes: 26 additions & 0 deletions examples/account/model/account.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?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);

$accountRepository = new \Tmdb\Repository\AccountRepository($client);
$account = $accountRepository->getAccount();

var_dump($account);

29 changes: 29 additions & 0 deletions examples/account/model/favorite.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?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);

/**
* @var \Tmdb\Repository\AccountRepository $accountRepository
*/
$accountRepository = new \Tmdb\Repository\AccountRepository($client);
$lists = $accountRepository->favorite(TMDB_ACCOUNT_ID, 150);

var_dump($lists);

29 changes: 29 additions & 0 deletions examples/account/model/favorite_movies.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?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);

/**
* @var \Tmdb\Repository\AccountRepository $accountRepository
*/
$accountRepository = new \Tmdb\Repository\AccountRepository($client);
$lists = $accountRepository->getFavoriteMovies(TMDB_ACCOUNT_ID);

var_dump($lists);

29 changes: 29 additions & 0 deletions examples/account/model/lists.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?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);

/**
* @var \Tmdb\Repository\AccountRepository $accountRepository
*/
$accountRepository = new \Tmdb\Repository\AccountRepository($client);
$lists = $accountRepository->getLists(TMDB_ACCOUNT_ID);

var_dump($lists);

29 changes: 29 additions & 0 deletions examples/account/model/movie_watchlist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?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);

/**
* @var \Tmdb\Repository\AccountRepository $accountRepository
*/
$accountRepository = new \Tmdb\Repository\AccountRepository($client);
$lists = $accountRepository->getMovieWatchlist(TMDB_ACCOUNT_ID);

var_dump($lists);

29 changes: 29 additions & 0 deletions examples/account/model/rated_movies.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?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);

/**
* @var \Tmdb\Repository\AccountRepository $accountRepository
*/
$accountRepository = new \Tmdb\Repository\AccountRepository($client);
$lists = $accountRepository->getRatedMovies(TMDB_ACCOUNT_ID);

var_dump($lists);

29 changes: 29 additions & 0 deletions examples/account/model/watchlist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?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);

/**
* @var \Tmdb\Repository\AccountRepository $accountRepository
*/
$accountRepository = new \Tmdb\Repository\AccountRepository($client);
$lists = $accountRepository->watchlist(TMDB_ACCOUNT_ID, 49047);

var_dump($lists);

3 changes: 3 additions & 0 deletions examples/lists/model/get.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
5 changes: 4 additions & 1 deletion examples/lists/model/item_status.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
25 changes: 25 additions & 0 deletions examples/movies/model/account_states.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?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);

$repository = new \Tmdb\Repository\MovieRepository($client);
$accountStates = $repository->getAccountStates(97020);

var_dump($accountStates);
25 changes: 25 additions & 0 deletions examples/movies/model/rate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?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);

$repository = new \Tmdb\Repository\MovieRepository($client);
$rate = $repository->rate(49047, 6.5);

var_dump($rate);
97 changes: 97 additions & 0 deletions lib/Tmdb/Factory/AccountFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?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
*/
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;
}
}
Loading

0 comments on commit 53f109c

Please sign in to comment.