one-click-accessibility/modules/connect/rest/disconnect.php
Nirbhay Singh 2cf2e9d84b
[APP-1270] Delete transient and force info update (#236)
* add: force update site/info on mismatch url

* update: add a constant for the transient

* add: delete_transient for switch account as well

* add: delete_transient for disconnect as well
2025-03-19 18:33:29 +05:30

45 lines
818 B
PHP

<?php
namespace EA11y\Modules\Connect\Rest;
use EA11y\Modules\Settings\Module as Settings;
use EA11y\Modules\Connect\Classes\{
Route_Base,
Service,
};
use Throwable;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* Class Disconnect
*/
class Disconnect extends Route_Base {
public string $path = 'disconnect';
public function get_methods(): array {
return [ 'POST' ];
}
public function get_name(): string {
return 'disconnect';
}
public function POST() {
try {
Service::refresh_token();
Service::disconnect();
Settings::delete_plan_data_refresh_transient();
return $this->respond_success_json();
} catch ( Throwable $t ) {
return $this->respond_error_json( [
'message' => $t->getMessage(),
'code' => 'internal_server_error',
] );
}
}
}