allow vendord
All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 3m3s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 16s
Build, Push and Deploy / deploy-staging (push) Successful in 32s
Build, Push and Deploy / deploy-production (push) Has been skipped
Build, Push and Deploy / cleanup (push) Successful in 1s
All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 3m3s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 16s
Build, Push and Deploy / deploy-staging (push) Successful in 32s
Build, Push and Deploy / deploy-production (push) Has been skipped
Build, Push and Deploy / cleanup (push) Successful in 1s
This commit is contained in:
12
vendor/mercadopago/dx-php/src/MercadoPago/Generic/ErrorCause.php
vendored
Normal file
12
vendor/mercadopago/dx-php/src/MercadoPago/Generic/ErrorCause.php
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace MercadoPago;
|
||||
|
||||
class ErrorCause {
|
||||
|
||||
public $code = "";
|
||||
public $description = "";
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
56
vendor/mercadopago/dx-php/src/MercadoPago/Generic/RecuperableError.php
vendored
Normal file
56
vendor/mercadopago/dx-php/src/MercadoPago/Generic/RecuperableError.php
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace MercadoPago;
|
||||
|
||||
class RecuperableError {
|
||||
|
||||
public $message = "";
|
||||
public $status = "";
|
||||
public $error = "";
|
||||
|
||||
public $causes = [];
|
||||
|
||||
function __construct($message, $error, $status) {
|
||||
$this->message = $message;
|
||||
$this->status = $status;
|
||||
$this->error = $error;
|
||||
}
|
||||
|
||||
public function add_cause($code, $description) {
|
||||
$error_cause = new ErrorCause();
|
||||
$error_cause->code = $code;
|
||||
$error_cause->description = $description;
|
||||
array_push($this->causes, $error_cause);
|
||||
}
|
||||
|
||||
public function proccess_causes($causes){
|
||||
if(isset($causes['code']) && isset($causes['description'])){
|
||||
$this->add_cause($causes['code'], $causes['description']);
|
||||
}else{
|
||||
foreach ($causes as $cause){
|
||||
if(is_array($cause) && (!isset($cause['code']) && !isset($cause['description']))){
|
||||
$this->proccess_causes($cause);
|
||||
}else{
|
||||
$code = isset($cause['code']) ? $cause['code'] : "";
|
||||
$description = $cause;
|
||||
if (is_array($cause)) {
|
||||
if (isset($cause['description'])) {
|
||||
$description = $cause['description'];
|
||||
} elseif (isset($cause['message'])) {
|
||||
$description = $cause['message'];
|
||||
}
|
||||
}
|
||||
$this->add_cause($code, $description);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->error . ": " . $this->message;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
95
vendor/mercadopago/dx-php/src/MercadoPago/Generic/SearchResultsArray.php
vendored
Normal file
95
vendor/mercadopago/dx-php/src/MercadoPago/Generic/SearchResultsArray.php
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
namespace MercadoPago;
|
||||
|
||||
use ArrayObject;
|
||||
|
||||
class SearchResultsArray extends ArrayObject {
|
||||
|
||||
public $_filters;
|
||||
public $limit;
|
||||
public $total;
|
||||
public $offset;
|
||||
public $errors;
|
||||
public $_class;
|
||||
|
||||
|
||||
public function setEntityTypes($class){
|
||||
$this->_class = $class;
|
||||
}
|
||||
|
||||
public function setPaginateParams($params){
|
||||
$this->limit = $params["limit"];
|
||||
$this->total = $params["total"];
|
||||
$this->offset = $params["offset"];
|
||||
}
|
||||
|
||||
public function next() {
|
||||
$new_offset = $this->limit + $this->offset;
|
||||
$this->_filters['offset'] = $new_offset;
|
||||
$result = $this->_class::search($this->_filters);
|
||||
|
||||
$this->limit = $result->limit;
|
||||
$this->offset = $result->offset;
|
||||
$this->total = $result->total;
|
||||
|
||||
$this->exchangeArray($result->getArrayCopy());
|
||||
}
|
||||
|
||||
public function fetch($filters, $body) {
|
||||
$this->_filters = $filters;
|
||||
|
||||
if ($body) {
|
||||
$results = [];
|
||||
if (array_key_exists("results", $body)) {
|
||||
$results = $body["results"];
|
||||
} else if (array_key_exists("elements", $body)) {
|
||||
$results = $body["elements"];
|
||||
}
|
||||
|
||||
foreach ($results as $result) {
|
||||
$entity = new $this->_class();
|
||||
$entity->fillFromArray($entity, $result);
|
||||
$this->append($entity);
|
||||
}
|
||||
|
||||
$this->fetchPaging($filters, $body);
|
||||
}
|
||||
}
|
||||
|
||||
public function process_error_body($message){
|
||||
|
||||
$recuperable_error = new RecuperableError(
|
||||
$message['message'],
|
||||
$message['error'],
|
||||
$message['status']
|
||||
);
|
||||
|
||||
foreach ($message['cause'] as $causes) {
|
||||
if(is_array($causes)) {
|
||||
foreach ($causes as $cause) {
|
||||
$recuperable_error->add_cause($cause['code'], $cause['description']);
|
||||
}
|
||||
} else {
|
||||
$recuperable_error->add_cause($cause['code'], $cause['description']);
|
||||
}
|
||||
}
|
||||
|
||||
$this->errors = $recuperable_error;
|
||||
}
|
||||
|
||||
private function fetchPaging($filters, $body) {
|
||||
if (array_key_exists("paging", $body)) {
|
||||
$paging = $body["paging"];
|
||||
$this->limit = $paging["limit"];
|
||||
$this->total = $paging["total"];
|
||||
$this->offset = $paging["offset"];
|
||||
} else {
|
||||
$this->offset = array_key_exists("offset", $filters) ? $filters["offset"] : 0;
|
||||
$this->limit = array_key_exists("limit", $filters) ? $filters["limit"] : 20;
|
||||
$this->total = array_key_exists("total", $body) ? $body["total"] : 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user