| 1 |
<?php |
| 2 |
|
| 3 |
namespace Texty\Api; |
| 4 |
|
| 5 |
use WP_REST_Server; |
| 6 |
|
| 7 |
class Status extends Base { |
| 8 |
|
| 9 |
/** |
| 10 |
* Initialize |
| 11 |
* |
| 12 |
* @return void |
| 13 |
*/ |
| 14 |
public function __construct() { |
| 15 |
$this->namespace = 'texty/v1'; |
| 16 |
$this->rest_base = 'status'; |
| 17 |
} |
| 18 |
|
| 19 |
/** |
| 20 |
* Registers the routes for the objects of the controller. |
| 21 |
* |
| 22 |
* @return void |
| 23 |
*/ |
| 24 |
public function register_routes() { |
| 25 |
register_rest_route( |
| 26 |
$this->namespace, |
| 27 |
'/' . $this->rest_base, |
| 28 |
[ |
| 29 |
[ |
| 30 |
'methods' => WP_REST_Server::READABLE, |
| 31 |
'callback' => [ $this, 'status' ], |
| 32 |
'permission_callback' => [ $this, 'admin_permissions_check' ], |
| 33 |
'args' => [], |
| 34 |
], |
| 35 |
] |
| 36 |
); |
| 37 |
} |
| 38 |
|
| 39 |
/* |
| 40 |
* Send a test. |
| 41 |
* |
| 42 |
* @param WP_Rest_Request $request |
| 43 |
* |
| 44 |
* @return WP_Rest_Response|WP_Error |
| 45 |
*/ |
| 46 |
public function status( $request ) { |
| 47 |
$gateway = texty()->settings()->gateway(); |
| 48 |
|
| 49 |
$response = [ |
| 50 |
'success' => $gateway ? true : false, |
| 51 |
]; |
| 52 |
|
| 53 |
return rest_ensure_response( $response ); |
| 54 |
} |
| 55 |
} |
| 56 |
|