Method test_api_key
has 41 lines of code (exceeds 25 allowed). Consider refactoring.
public function test_api_key($api_key)
{
delete_transient('vindi_merchant');
$url = $this->base_path() . 'merchant';
Method request
has 32 lines of code (exceeds 25 allowed). Consider refactoring.
public function request($endpoint, $method = 'POST', $data = array(), $data_to_log = null)
{
$url = sprintf('%s%s', $this->base_path(), $endpoint);
$body = $this->build_body($data);
Function test_api_key
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
public function test_api_key($api_key)
{
delete_transient('vindi_merchant');
$url = $this->base_path() . 'merchant';
Function check_response
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
private function check_response($response)
{
if (isset($response['errors']) && !empty($response['errors'])) {
foreach ($response['errors'] as $error) {
$message = $this->get_error_message($error);
Avoid unused private fields such as '$recentRequest'.
private $recentRequest;
The property $errors_list is not named in camelCase.
class VindiApi
{
* @var string
*/
The property $accept_bank_slip is not named in camelCase.
class VindiApi
{
* @var string
*/
The property $last_error is not named in camelCase.
class VindiApi
{
* @var string
*/
The property $current_plan is not named in camelCase.
class VindiApi
{
* @var string
*/
Line exceeds 120 characters; contains 136 characters
$this->logger->log(sprintf("[Request #%s]: Nova Resposta da API.\n%s\n%s", $request_id, $status, print_r($response['body'], true)));
Line exceeds 120 characters; contains 128 characters
$this->logger->log(sprintf("[Request #%s]: Novo Request para a API.\n%s %s\n%s", $request_id, $method, $url, $data_to_log));
Inline control structures are not allowed
if (false === array_key_exists($error_identifier, $this->errors_list))
Line exceeds 120 characters; contains 130 characters
$this->logger->log(sprintf('[Request #%s]: Erro ao recuperar corpo do request! %s', $request_id, print_r($response, true)));
Line exceeds 120 characters; contains 136 characters
$this->logger->log(sprintf("[Request #%s]: Nova Resposta da API.\n%s\n%s", $request_id, $status, print_r($response['body'], true)));
Line exceeds 120 characters; contains 130 characters
$this->logger->log(sprintf('[Request #%s]: Erro ao recuperar corpo do request! %s', $request_id, print_r($response, true)));
Line exceeds 120 characters; contains 128 characters
$this->logger->log(sprintf("[Request #%s]: Novo Request para a API.\n%s %s\n%s", $request_id, $method, $url, $data_to_log));
Line indented incorrectly; expected 4 spaces, found 2
public function __construct($key, VindiLogger $logger, $sandbox)
Line indented incorrectly; expected at least 8 spaces, found 4
$this->logger = $logger;
Line indented incorrectly; expected 8 spaces, found 4
}
Line indented incorrectly; expected at least 4 spaces, found 2
{
Line indented incorrectly; expected 4 spaces, found 2
public $accept_bank_slip;
Line indented incorrectly; expected 4 spaces, found 2
public $current_plan;
Line indented incorrectly; expected 4 spaces, found 2
}
Line indented incorrectly; expected 4 spaces, found 2
}
Line indented incorrectly; expected 4 spaces, found 2
}
Line indented incorrectly; expected at least 8 spaces, found 4
$error_id = empty($error['id']) ? '' : $error['id'];
Line indented incorrectly; expected 4 spaces, found 2
public function test_api_key($api_key)
Line indented incorrectly; expected at least 8 spaces, found 4
return 'https://app.vindi.com.br/api/v1/';
Line indented incorrectly; expected at least 8 spaces, found 4
$body = null;
Line indented incorrectly; expected at least 4 spaces, found 2
{
Line indented incorrectly; expected at least 12 spaces, found 6
$this->logger->log(sprintf("[Request #%s]: Erro ao fazer request! %s", $request_id, print_r($response, true)));
Line indented incorrectly; expected at least 12 spaces, found 6
return 'https://sandbox-app.vindi.com.br/api/v1/';
Line indented incorrectly; expected at least 8 spaces, found 4
$body = null;
Line indented incorrectly; expected at least 8 spaces, found 4
return sprintf('Basic %s', base64_encode($this->key . ":"));
Line indented incorrectly; expected at least 8 spaces, found 4
$request_id = rand();
Line indented incorrectly; expected at least 8 spaces, found 4
$this->logger->log(sprintf("[Request #%s]: Novo Request para a API.\n%s %s\n%s", $request_id, $method, $url, $data_to_log));
Line indented incorrectly; expected 4 spaces, found 2
private $logger;
Line indented incorrectly; expected 8 spaces, found 4
if ('yes' === $this->sandbox) {
Line indented incorrectly; expected at least 4 spaces, found 2
{
Line indented incorrectly; expected at least 8 spaces, found 4
$this->key = $key;
Line indented incorrectly; expected 4 spaces, found 2
private function convert_body_to_json($data)
Line indented incorrectly; expected at least 8 spaces, found 4
return __($this->errors_list[$error_identifier], VINDI);
Line indented incorrectly; expected at least 8 spaces, found 4
$method = 'GET';
Line indented incorrectly; expected at least 8 spaces, found 4
$data_to_log = 'API Authorization Test';
Line indented incorrectly; expected at least 8 spaces, found 4
]);
Line indented incorrectly; expected at least 4 spaces, found 2
);
Line indented incorrectly; expected 4 spaces, found 2
public function base_path()
Line indented incorrectly; expected 4 spaces, found 2
}
Line indented incorrectly; expected 4 spaces, found 2
private function get_error_message($error)
Line indented incorrectly; expected at least 8 spaces, found 6
],
Line indented incorrectly; expected 4 spaces, found 2
private $recentRequest;
Line indented incorrectly; expected 4 spaces, found 2
private $sandbox;
Line indented incorrectly; expected at least 4 spaces, found 2
{
Line indented incorrectly; expected 8 spaces, found 4
if (!empty($data)) {
Line indented incorrectly; expected 8 spaces, found 4
if (is_wp_error($response)) {
Line indented incorrectly; expected 4 spaces, found 2
private $key;
Line indented incorrectly; expected at least 4 spaces, found 2
{
Line indented incorrectly; expected 4 spaces, found 2
}
Line indented incorrectly; expected at least 8 spaces, found 6
'method' => $method,
Line indented incorrectly; expected at least 8 spaces, found 6
'sslverify' => true,
Line indented incorrectly; expected at least 8 spaces, found 4
$this->logger->log(sprintf("[Request #%s]: Nova Resposta da API.\n%s\n%s", $request_id, $status, print_r($response['body'], true)));
Line indented incorrectly; expected 4 spaces, found 2
public $last_error = '';
Line indented incorrectly; expected 8 spaces, found 4
}
Line indented incorrectly; expected at least 8 spaces, found 4
$this->sandbox = $sandbox;
Line indented incorrectly; expected at least 8 spaces, found 4
$error_identifier = sprintf('%s|%s', $error_id, $error_parameter);
Line indented incorrectly; expected at least 8 spaces, found 6
'headers' => [
Line indented incorrectly; expected at least 12 spaces, found 6
$this->logger->log(sprintf('[Request #%s]: Erro ao recuperar corpo do request! %s', $request_id, print_r($response, true)));
Line indented incorrectly; expected at least 8 spaces, found 4
$error_parameter = empty($error['parameter']) ? '' : $error['parameter'];
Line indented incorrectly; expected 8 spaces, found 4
}
Line indented incorrectly; expected 8 spaces, found 4
if (!$response_body) {
Line indented incorrectly; expected at least 8 spaces, found 4
$url = $this->base_path() . 'merchant';
Line indented incorrectly; expected at least 12 spaces, found 6
$body = json_encode($data);
Line indented incorrectly; expected at least 8 spaces, found 6
return $error_identifier;
Line indented incorrectly; expected 4 spaces, found 2
}
Line indented incorrectly; expected at least 4 spaces, found 2
{
Line indented incorrectly; expected 8 spaces, found 4
if (!empty($data)) {
Line indented incorrectly; expected at least 8 spaces, found 4
return $body;
Line indented incorrectly; expected 8 spaces, found 4
}
Line indented incorrectly; expected at least 8 spaces, found 4
if (false === array_key_exists($error_identifier, $this->errors_list))
Line indented incorrectly; expected at least 8 spaces, found 4
$response = wp_remote_post($url, [
Line indented incorrectly; expected at least 12 spaces, found 6
return false;
Line indented incorrectly; expected at least 8 spaces, found 4
$status = $response['response']['code'] . ' ' . $response['response']['message'];
Line indented incorrectly; expected at least 8 spaces, found 4
$response_body = wp_remote_retrieve_body($response);
Line indented incorrectly; expected at least 12 spaces, found 6
return false;
Line indented incorrectly; expected 12 spaces, found 6
}
Line indented incorrectly; expected at least 8 spaces, found 4
$response = wp_remote_post($url, array(
Line indented incorrectly; expected 4 spaces, found 2
private $errors_list = array(
Line indented incorrectly; expected at least 8 spaces, found 4
return $body;
Line indented incorrectly; expected 4 spaces, found 2
private function get_auth_header()
Line indented incorrectly; expected at least 8 spaces, found 4
delete_transient('vindi_merchant');
Line indented incorrectly; expected at least 20 spaces, found 10
return $error['id'];
Line indented incorrectly; expected at least 8 spaces, found 4
return true;
Line indented incorrectly; expected at least 8 spaces, found 4
));
Line indented incorrectly; expected 8 spaces, found 4
if (!$response_body) {
Line indented incorrectly; expected at least 8 spaces, found 4
$response_body_array = json_decode($response_body, true);
Line indented incorrectly; expected at least 20 spaces, found 10
delete_transient('vindi_payment_methods');
Line indented incorrectly; expected at least 8 spaces, found 6
),
Line indented incorrectly; expected at least 8 spaces, found 4
return $response_body_array;
Line indented incorrectly; expected 4 spaces, found 2
}
Line indented incorrectly; expected at least 8 spaces, found 6
'headers' => array(
Line indented incorrectly; expected at least 8 spaces, found 4
$url = sprintf('%s%s', $this->base_path(), $endpoint);
Line indented incorrectly; expected at least 8 spaces, found 6
'body' => $body,
Line indented incorrectly; expected at least 12 spaces, found 6
$this->logger->log(sprintf("[Request #%s]: Erro ao fazer request! %s", $request_id, print_r($response, true)));
Line indented incorrectly; expected at least 4 spaces, found 2
{
Line indented incorrectly; expected 4 spaces, found 2
private function build_body($data)
Line indented incorrectly; expected at least 12 spaces, found 6
$body = json_encode($data);
Line indented incorrectly; expected at least 8 spaces, found 6
'timeout' => 60,
Line indented incorrectly; expected 8 spaces, found 4
}
Line indented incorrectly; expected at least 8 spaces, found 4
$request_id = rand();
Line indented incorrectly; expected at least 8 spaces, found 6
'method' => $method,
Line indented incorrectly; expected at least 12 spaces, found 6
return false;
Line indented incorrectly; expected at least 8 spaces, found 4
$response_body_array = json_decode($response_body, true);
Line indented incorrectly; expected at least 20 spaces, found 10
$this->last_error = $message;
Line indented incorrectly; expected at least 8 spaces, found 4
$body = $this->build_body($data);
Line indented incorrectly; expected at least 8 spaces, found 4
$this->logger->log(sprintf("[Request #%s]: Nova Resposta da API.\n%s\n%s", $request_id, $status, print_r($response['body'], true)));
Line indented incorrectly; expected 8 spaces, found 4
}
Line indented incorrectly; expected 12 spaces, found 6
foreach ($response_body_array['errors'] as $error) {
Line indented incorrectly; expected at least 8 spaces, found 4
set_transient('vindi_merchant', $response_body_array['merchant'], 1 * HOUR_IN_SECONDS);
Line indented incorrectly; expected at least 8 spaces, found 4
$data_to_log = null !== $data_to_log ? $this->build_body($data_to_log) : $body;
Line indented incorrectly; expected at least 20 spaces, found 10
delete_transient('vindi_plans');
Line indented incorrectly; expected 4 spaces, found 2
public function request($endpoint, $method = 'POST', $data = array(), $data_to_log = null)
Line indented incorrectly; expected at least 8 spaces, found 6
'sslverify' => true,
Line indented incorrectly; expected 16 spaces, found 8
if ('unauthorized' == $error['id'] and 'authorization' == $error['parameter']) {
Line indented incorrectly; expected 8 spaces, found 4
if (is_wp_error($response)) {
Line indented incorrectly; expected 8 spaces, found 4
}
Line indented incorrectly; expected 8 spaces, found 4
if (isset($response_body_array['errors']) && !empty($response_body_array['errors'])) {
Line indented incorrectly; expected at least 20 spaces, found 10
$message = $this->get_error_message($error);
Line indented incorrectly; expected at least 8 spaces, found 4
$response_body = wp_remote_retrieve_body($response);
Line indented incorrectly; expected 8 spaces, found 4
if (!$this->check_response($response_body_array)) {
Line indented incorrectly; expected at least 8 spaces, found 4
$this->logger->log(sprintf("[Request #%s]: Novo Request para a API.\n%s %s\n%s", $request_id, $method, $url, $data_to_log));
Line indented incorrectly; expected at least 12 spaces, found 6
$this->logger->log(sprintf('[Request #%s]: Erro ao recuperar corpo do request! %s', $request_id, print_r($response, true)));
Line indented incorrectly; expected 16 spaces, found 8
}
Line indented incorrectly; expected 8 spaces, found 4
}
Line indented incorrectly; expected at least 4 spaces, found 2
{
Line indented incorrectly; expected at least 8 spaces, found 6
'timeout' => 60,
Line indented incorrectly; expected at least 12 spaces, found 6
return false;
Line indented incorrectly; expected 8 spaces, found 4
}
Line indented incorrectly; expected 4 spaces, found 2
}
Line indented incorrectly; expected at least 8 spaces, found 4
$status = sprintf('%s %s', $response['response']['code'], $response['response']['message']);
Line indented incorrectly; expected at least 12 spaces, found 6
return false;
There are no issues that match your filters.