Skip to content

Commit

Permalink
2.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
luannsr12 committed Oct 16, 2024
1 parent e25a347 commit c79eaa5
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Api Evolution: [Evolution-api](https://doc.evolution-api.com/v2/)

<hr>

SDK version: 2.0.5 <br />
SDK version: 2.0.6 <br />
PHP Version: >= 8.2

## Funções disponíveis
Expand Down
47 changes: 47 additions & 0 deletions src/Api/Evolution/Device.php
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,53 @@ public static function isConnected(): bool

}

public function exist(){
try {

if (ExceptionError::$error) {
return NULL;
}

$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => rtrim(self::$endpoint, '/') . '/instance/connectionState/' . trim(self::$name_instance),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => array(
'apikey: ' . trim(self::$instance)
),
)
);

$response = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);

try {

if($httpCode == 404){
return false;
}

return true;

} catch (\Exception $e) {
ExceptionError::setError(500, json_encode(['type' => 'Exception', 'class' => 'Api\Evolution\Device', 'method' => 'exist', 'message' => $e->getMessage()]));
return false;
}

} catch (\Exception $e) {
ExceptionError::setError(500, json_encode(['type' => 'Exception', 'class' => 'Api\Evolution\Device', 'method' => 'exist', 'message' => $e->getMessage()]));
return false;
}
}

public static function logout()
{

Expand Down
47 changes: 47 additions & 0 deletions src/Api/Evolution2/Device.php
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,53 @@ public static function delete()
}
}

public function exist(){
try {

if (ExceptionError::$error) {
return NULL;
}

$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => rtrim(self::$endpoint, '/') . '/instance/connectionState/' . trim(self::$name_instance),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => array(
'apikey: ' . trim(self::$instance)
),
)
);

$response = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);

try {

if($httpCode == 404){
return false;
}

return true;

} catch (\Exception $e) {
ExceptionError::setError(500, json_encode(['type' => 'Exception', 'class' => 'Api\Evolution\Device', 'method' => 'exist', 'message' => $e->getMessage()]));
return false;
}

} catch (\Exception $e) {
ExceptionError::setError(500, json_encode(['type' => 'Exception', 'class' => 'Api\Evolution\Device', 'method' => 'exist', 'message' => $e->getMessage()]));
return false;
}
}

public static function logout()
{

Expand Down

0 comments on commit c79eaa5

Please sign in to comment.