Skip to content

Commit

Permalink
Initial base commit
Browse files Browse the repository at this point in the history
- Already finished up all basic API methods for movies
  • Loading branch information
wtfzdotnet committed Nov 1, 2013
1 parent 710fa72 commit 0d4e0d7
Show file tree
Hide file tree
Showing 16 changed files with 1,122 additions and 49 deletions.
24 changes: 24 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
The MIT License

Copyright (c) 2013 Michael Roterman
Copyright (c) 2013 Matt Humphrey
Copyright (c) 2012 KnpLabs
Copyright (c) 2010 Thibault Duplessis

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
22 changes: 22 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "wtfzdotnet/php-tmdb-api",
"type": "library",
"description": "TMDB API client",
"homepage": "https://github.com/wtfzdotnet/php-tmdb-api",
"keywords": ["tmdb", "api", "php"],
"license": "MIT",
"authors": [
{
"name": "Michael Roterman",
"homepage": "http://wtfz.net"
}
],
"require": {
"php": ">=5.3.2",
"ext-curl": "*",
"guzzle/guzzle": ">=0.7"
},
"autoload": {
"psr-0": { "Tmdb\\": "lib/" }
}
}
124 changes: 124 additions & 0 deletions lib/Tmdb/Api/AbstractApi.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<?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\Api;

use Tmdb\Client;

abstract class AbstractApi
implements ApiInterface
{
/**
* The client
*
* @var Client
*/
protected $client;

/**
* Constructor
*
* @param Client $client
*/
public function __construct(Client $client)
{
$this->client = $client;
}

/**
* Send a GET request
*
* @param $path
* @param array $parameters
* @param array $headers
* @return mixed
*/
public function get($path, array $parameters = array(), $headers = array())
{
$response = $this->client->getHttpClient()->get($path, $parameters, $headers);
return $response->json();
}

/**
* Send a HEAD request
*
* @param $path
* @param array $parameters
* @param array $headers
* @return mixed
*/
public function head($path, array $parameters = array(), $headers = array())
{
$response = $this->client->getHttpClient()->head($path, $parameters, $headers);
return $response->json();
}

/**
* Send a POST request
*
* @param $path
* @param null $postBody
* @param array $parameters
* @param array $headers
* @return mixed
*/
public function post($path, $postBody = null, array $parameters = array(), $headers = array())
{
$response = $this->client->getHttpClient()->post($path, $postBody, $parameters, $headers);
return $response->json();
}

/**
* Send a PUT request
*
* @param $path
* @param null $body
* @param array $parameters
* @param array $headers
* @return mixed
*/
public function put($path, $body = null, array $parameters = array(), $headers = array())
{
$response = $this->client->getHttpClient()->put($path, $body, $parameters, $headers);
return $response->json();
}

/**
* Send a DELETE request
*
* @param $path
* @param null $body
* @param array $parameters
* @param array $headers
* @return mixed
*/
public function delete($path, $body = null, array $parameters = array(), $headers = array())
{
$response = $this->client->getHttpClient()->delete($path, $body, $parameters, $headers);
return $response->json();
}

/**
* Send a PATCH request
*
* @param $path
* @param null $body
* @param array $parameters
* @param array $headers
* @return mixed
*/
public function patch($path, $body = null, array $parameters = array(), $headers = array())
{
$response = $this->client->getHttpClient()->patch($path, $body, $parameters, $headers);
return $response->json();
}
}
12 changes: 5 additions & 7 deletions lib/Tmdb/Api/ApiInterface.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
<?php
/**
* This file is part of the Wrike PHP API created by B-Found IM&S.
* 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 Wrike
* @author Michael Roterman <michael@b-found.nl>
* @copyright (c) 2013, B-Found Internet Marketing & Services
* @package Tmdb
* @author Michael Roterman <michael@wtfz.net>
* @copyright (c) 2013, Michael Roterman
* @version 0.0.1
*/

namespace Tmdb\Api;


interface ApiInterface {

}
}
Loading

0 comments on commit 0d4e0d7

Please sign in to comment.