-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor #2
Open
dvalchanov
wants to merge
16
commits into
master
Choose a base branch
from
refactor
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Refactor #2
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
a3309c4
Add some todo items
vesln 750c45d
Refactor the url assemblation
dvalchanov d4478e5
Change the resource structure
dvalchanov 7a49d0a
Adding response code switching
dvalchanov dd9c858
Add exceptions and comments
dvalchanov c6a5bae
Add license to each file
dvalchanov 8d1dbd6
Add comments and fix some stuff
dvalchanov 05f9de5
Add more attributes to the schema of the errors
dvalchanov 3567b14
Fixing some test cases
dvalchanov 99ec1cf
Add travis configuration
dvalchanov 326f488
Remove the features, since they are not used anymore
dvalchanov 58cfd04
Add phpunit.xml
dvalchanov 4f65d62
Add options holder in the engine
dvalchanov 5f84057
Add build status to the readme
dvalchanov c4c6b0d
Stub more methods of the Http Engine
dvalchanov 388e72b
Convert missed tabs to spaces
dvalchanov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
language: php | ||
php: | ||
- "5.4" | ||
- "5.3" | ||
- "5.2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<phpunit backupGlobals="false" | ||
colors="true" | ||
backupStaticAttributes="false" | ||
syntaxCheck="false"> | ||
<testsuites> | ||
<testsuite name="test"> | ||
<directory suffix=".php">test</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?php | ||
|
||
/** | ||
* Aero.io API client for PHP | ||
* | ||
* @copyright Copyright 2012, aero.io (http://aero.io) | ||
* @license The MIT License | ||
*/ | ||
|
||
require_once 'src/ExceptionHandler.php'; | ||
require_once 'src/Connection.php'; | ||
require_once 'src/engines/Curl.php'; | ||
|
||
/** | ||
* AeroIO class. | ||
* | ||
* Base class for the client. | ||
*/ | ||
class AeroIO { | ||
|
||
/** | ||
* Type of the engine used for the request execution. | ||
* | ||
* @var object | ||
*/ | ||
public static $engine; | ||
|
||
/** | ||
* Url address for the request. | ||
* | ||
* @var string | ||
*/ | ||
public static $site; | ||
|
||
/** | ||
* Auth token for the user authentication. | ||
* | ||
* @var string | ||
*/ | ||
public static $auth_token; | ||
|
||
/** | ||
* Sid for the user authentication. | ||
* | ||
* @var string | ||
*/ | ||
public static $sid; | ||
|
||
/** | ||
* Id of the project to be handled. | ||
* | ||
* @var integer | ||
*/ | ||
public static $project; | ||
|
||
/** | ||
* Set up the options for the request. | ||
* | ||
* @param array $options | ||
* @return void | ||
*/ | ||
public static function configure(Array $options = array()) { | ||
foreach ($options as $key => $value) { | ||
self::$$key = $value; | ||
} | ||
|
||
if (!self::$engine) self::$engine = new Aero_Curl(); | ||
|
||
self::setOptions(); | ||
} | ||
|
||
/** | ||
* Set exception handler for certain project. | ||
* | ||
* @return void | ||
*/ | ||
public static function handleExceptions() { | ||
Aero_ExceptionHandler::for_project(self::$project); | ||
} | ||
|
||
/** | ||
* Set the options for the request. | ||
* | ||
* @return void | ||
*/ | ||
protected static function setOptions() { | ||
Aero_Connection::$site = self::$site; | ||
Aero_Connection::$engine = self::$engine; | ||
Aero_Connection::$credentials = array( | ||
'auth_token' => self::$auth_token, | ||
'sid' => self::$sid | ||
); | ||
} | ||
} | ||
|
||
?> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,56 @@ | ||
<?php | ||
require_once 'src/UrlBuilder.php'; | ||
|
||
/** | ||
* Aero.io API client for PHP | ||
* | ||
* @copyright Copyright 2012, aero.io (http://aero.io) | ||
* @license The MIT License | ||
*/ | ||
|
||
/** | ||
* Aero_Connection class. | ||
* | ||
* This class connects the components and executes them. | ||
*/ | ||
class Aero_Connection { | ||
public static function persist($resource, $type) { | ||
$request = Aero_Request($type, $resource, $credentials); | ||
//$url = UrlBuilder::assemble($resource); | ||
|
||
//$params = array( | ||
//'type' => $type, | ||
//'url' => $url, | ||
//'auth_token' => self::$credentials['auth_token'], | ||
//'sid' => self::$credentials['sid'], | ||
//'attributes' => $resource | ||
//); | ||
/** | ||
* Base url of the application. | ||
* | ||
* @static string | ||
*/ | ||
public static $site = 'https://aero.io/api/v1'; | ||
|
||
/** | ||
* Credentials to be used for user authorization. | ||
* | ||
* @static array | ||
*/ | ||
public static $credentials; | ||
|
||
//$request = new Aero_Request($params); | ||
/** | ||
* Engine to be used for the request execution. | ||
* | ||
* @static object | ||
*/ | ||
public static $engine; | ||
|
||
/** | ||
* Create a request object, to be used by the engine for execution and | ||
* handle the response. | ||
* | ||
* @param object $resource | ||
* @param string $type | ||
* @return object | ||
*/ | ||
public static function persist($resource, $type) { | ||
$request = new Aero_Request($type, $resource, self::$credentials, self::$site); | ||
|
||
$engine = new self::$engine(); | ||
$response = $engine->execute($request); | ||
|
||
return Aero_Response::handle($response); | ||
} | ||
|
||
public static $engine; | ||
public static $credentials; | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
/** | ||
* Aero.io API client for PHP | ||
* | ||
* @copyright Copyright 2012, aero.io (http://aero.io) | ||
* @license The MIT License | ||
*/ | ||
|
||
require_once 'src/resources/Error.php'; | ||
|
||
/** | ||
* Aero_ExceptionHandler class. | ||
* | ||
* Set up the handling of errors for certain project. | ||
*/ | ||
class Aero_ExceptionHandler { | ||
|
||
/** | ||
* Id of the project to be handled. | ||
* | ||
* @var integer | ||
*/ | ||
public static $project_id; | ||
|
||
/** | ||
* Save an error belonging to certain project. | ||
* | ||
* @param object $exception | ||
* @return void | ||
*/ | ||
public function handle($exception) { | ||
$params = array( | ||
'project_id' => self::$project_id, | ||
'message' => $exception->getMessage(), | ||
'resolved' => false | ||
); | ||
|
||
$error = new Aero_Error($params); | ||
$error->save(); | ||
} | ||
|
||
/** | ||
* Set exception handler for certain project. | ||
* | ||
* @param integer $id | ||
* @return void | ||
*/ | ||
public static function for_project($id) { | ||
self::$project_id = $id; | ||
|
||
set_exception_handler(array(get_called_class(), "handle")); | ||
} | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
/** | ||
* Aero.io API client for PHP | ||
* | ||
* @copyright Copyright 2012, aero.io (http://aero.io) | ||
* @license The MIT License | ||
*/ | ||
|
||
/** | ||
* Client side exceptions. | ||
*/ | ||
class ClientException extends Exception {} | ||
|
||
/** | ||
* Server side exceptions. | ||
*/ | ||
class ServerException extends Exception {} | ||
|
||
/** | ||
* Exceptions, when the connection has timed out or something uncaught happened. | ||
*/ | ||
class ConnectionException extends Exception {} | ||
|
||
/** | ||
* Exception, when new URI was assigned. | ||
*/ | ||
class RedirectionException extends ConnectionException {} | ||
|
||
/** | ||
* Exception, when the request cannot be understood by the server. | ||
*/ | ||
class BadRequestException extends ClientException {} | ||
|
||
/** | ||
* Exception, when user authentications is required. | ||
*/ | ||
class UnauthorizedException extends ClientException {} | ||
|
||
/** | ||
* Exception, when the server is refusing to fulfill the request. | ||
*/ | ||
class ForbiddenAccessException extends ClientException {} | ||
|
||
/** | ||
* Exception, when nothing mathing is found. | ||
*/ | ||
class ResourceNotFoundException extends ClientException {} | ||
|
||
/** | ||
* Exception, when the method type is not allowed. | ||
*/ | ||
class MethodNotAllowedException extends ClientException {} | ||
|
||
/** | ||
* Exception, when the request cannot be fulfiled due to a resource conflict. | ||
*/ | ||
class ResourceConflictException extends ClientException {} | ||
|
||
/** | ||
* Exception, when the resource is no longer available. | ||
*/ | ||
class ResourceGoneException extends ClientException {} | ||
|
||
/** | ||
* Exception, when there were semantic errors in the request. | ||
*/ | ||
class ResourceInvalidException extends ClientException {} | ||
|
||
?> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't be lazy. Add comments :)