Skip to content

Commit

Permalink
Pending update (#90)
Browse files Browse the repository at this point in the history
Co-authored-by: Unknown <samuel.leite@pagar.me>
  • Loading branch information
magnomoreira and samuelleitemundipagg authored Mar 17, 2023
1 parent 3f1d3cc commit 7d49e53
Show file tree
Hide file tree
Showing 301 changed files with 31,969 additions and 4,353 deletions.
4,793 changes: 3,119 additions & 1,674 deletions README.md

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"apimatic/jsonmapper": "^1.3.1"
},
"require-dev": {
"squizlabs/php_codesniffer": "^2.7"
"squizlabs/php_codesniffer": "^2.7",
"phpunit/phpunit": "4.8.*"
},
"autoload": {
"psr-4": {
Expand Down
20 changes: 20 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="tests/bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
syntaxCheck="true"
verbose="true"
>
<testsuites>
<testsuite name="SDK Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
</phpunit>
20 changes: 1 addition & 19 deletions src/Controllers/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class BaseController
* User-agent to be sent with API calls
* @var string
*/
const USER_AGENT = 'MundiSDK - PHP 2.4.0';
const USER_AGENT = 'MundiSDK - PHP 2.4.1';

/**
* HttpCallBack instance associated with this controller
Expand Down Expand Up @@ -73,24 +73,6 @@ protected function getJsonMapper()

protected function validateResponse(HttpResponse $response, HttpContext $_httpContext)
{
if ($response->getStatusCode() == 400) {
throw new Exceptions\ErrorException('Invalid request', $_httpContext);
}
if ($response->getStatusCode() == 401) {
throw new Exceptions\ErrorException('Invalid API key', $_httpContext);
}
if ($response->getStatusCode() == 404) {
throw new Exceptions\ErrorException('An informed resource was not found', $_httpContext);
}
if ($response->getStatusCode() == 412) {
throw new Exceptions\ErrorException('Business validation error', $_httpContext);
}
if ($response->getStatusCode() == 422) {
throw new Exceptions\ErrorException('Contract validation error', $_httpContext);
}
if ($response->getStatusCode() == 500) {
throw new Exceptions\ErrorException('Internal server error', $_httpContext);
}
if (($response->getStatusCode() < 200) || ($response->getStatusCode() > 208)) { //[200,208] = HTTP OK
throw new APIException('HTTP Response Not OK', $_httpContext);
}
Expand Down
Loading

0 comments on commit 7d49e53

Please sign in to comment.