Skip to content

Commit

Permalink
Adding Search API
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfzdotnet committed Feb 8, 2014
1 parent 86bc64e commit 0a2399f
Show file tree
Hide file tree
Showing 17 changed files with 854 additions and 2 deletions.
4 changes: 2 additions & 2 deletions PROGRESS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Overview of the current implementation status.
The states for now defined as;

- Done, stable?
- Review, requires another review before we can mark it as done.
- Partially done, means there are methods and / or classes missing and is intentional.
- Review, requires another review before we can mark it as done.
- Todo, requires everything still to be implemented.

| API Namespace | Status |
Expand Down Expand Up @@ -33,4 +33,4 @@ The states for now defined as;
| TV Seasons | Done |
| TV Episodes | Done |

__* Currently the account related functions are missing from these sections.__
__* Currently the account related functions are missing from these sections.__
26 changes: 26 additions & 0 deletions examples/search/model/collection.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);

$query = new \Tmdb\Model\Search\SearchQuery\CollectionSearchQuery();
$query->page(1);

$repository = new \Tmdb\Repository\SearchRepository($client);

$find = $repository->searchCollection('star wars', $query);

var_dump($find);
26 changes: 26 additions & 0 deletions examples/search/model/company.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);

$query = new \Tmdb\Model\Search\SearchQuery\CompanySearchQuery();
$query->page(1);

$repository = new \Tmdb\Repository\SearchRepository($client);

$find = $repository->searchCompany('warner bros', $query);

var_dump($find);
26 changes: 26 additions & 0 deletions examples/search/model/keyword.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);

$query = new \Tmdb\Model\Search\SearchQuery\KeywordSearchQuery();
$query->page(1);

$repository = new \Tmdb\Repository\SearchRepository($client);

$find = $repository->searchKeyword('scary', $query);

var_dump($find);
26 changes: 26 additions & 0 deletions examples/search/model/list.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);

$query = new \Tmdb\Model\Search\SearchQuery\ListSearchQuery();
$query->page(1);

$repository = new \Tmdb\Repository\SearchRepository($client);

$find = $repository->searchList('award', $query);

var_dump($find);
26 changes: 26 additions & 0 deletions examples/search/model/movie.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);

$query = new \Tmdb\Model\Search\SearchQuery\MovieSearchQuery();
$query->page(1);

$repository = new \Tmdb\Repository\SearchRepository($client);

$find = $repository->searchMovie('batman', $query);

var_dump($find);
26 changes: 26 additions & 0 deletions examples/search/model/person.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);

$query = new \Tmdb\Model\Search\SearchQuery\PersonSearchQuery();
$query->page(1);

$repository = new \Tmdb\Repository\SearchRepository($client);

$find = $repository->searchPerson('bruce lee', $query);

var_dump($find);
26 changes: 26 additions & 0 deletions examples/search/model/tv.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);

$query = new \Tmdb\Model\Search\SearchQuery\TvSearchQuery();
$query->page(1);

$repository = new \Tmdb\Repository\SearchRepository($client);

$find = $repository->searchTv('breaking bad', $query);

var_dump($find);
43 changes: 43 additions & 0 deletions lib/Tmdb/Model/Search/SearchQuery.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?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\Model\Search;

use Tmdb\Model\Collection\QueryParametersCollection;

class SearchQuery extends QueryParametersCollection {
/**
* CGI escaped string
*
* @param string
* @return $this
*/
public function query($query)
{
$this->set('query', $query);

return $this;
}

/**
* Minimum 1, maximum 1000.
*
* @param int
* @return $this
*/
public function page($page)
{
$this->set('page', $page);

return $this;
}
}
30 changes: 30 additions & 0 deletions lib/Tmdb/Model/Search/SearchQuery/CollectionSearchQuery.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?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\Model\Search\SearchQuery;

use Tmdb\Model\Search\SearchQuery;

class CollectionSearchQuery extends SearchQuery {
/**
* ISO 639-1 code.
*
* @param string
* @return $this
*/
public function language($language)
{
$this->set('language', $language);

return $this;
}
}
17 changes: 17 additions & 0 deletions lib/Tmdb/Model/Search/SearchQuery/CompanySearchQuery.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?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\Model\Search\SearchQuery;

use Tmdb\Model\Search\SearchQuery;

class CompanySearchQuery extends SearchQuery {}
17 changes: 17 additions & 0 deletions lib/Tmdb/Model/Search/SearchQuery/KeywordSearchQuery.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?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\Model\Search\SearchQuery;

use Tmdb\Model\Search\SearchQuery;

class KeywordSearchQuery extends SearchQuery {}
31 changes: 31 additions & 0 deletions lib/Tmdb/Model/Search/SearchQuery/ListSearchQuery.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?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\Model\Search\SearchQuery;

use Tmdb\Model\Search\SearchQuery;

class ListSearchQuery extends SearchQuery {

/**
* Toggle the inclusion of adult titles. Expected value is: true or false
*
* @param bool
* @return $this
*/
public function includeAdult($include_adult)
{
$this->set('include_adult', (bool) $include_adult);

return $this;
}
}
Loading

0 comments on commit 0a2399f

Please sign in to comment.