Files
2025-04-12 10:34:26 -04:00

41 lines
1.1 KiB
PHP

<?php
namespace SoundPress\WHIOrders\Controller\Adminhtml\Connection;
use Magento\Backend\App\Action\Context;
use SoundPress\WHIOrders\Helper\ConfigHelper;
use GuzzleHttp\ClientFactory;
class Index extends \Magento\Backend\App\Action
{
protected $clientFactory;
protected $configHelper;
public function __construct(
Context $context,
ClientFactory $clientFactory,
ConfigHelper $configHelper,
) {
$this->clientFactory = $clientFactory;
$this->configHelper = $configHelper;
parent::__construct($context);
$baseUrl = $this->configHelper->getBaseUrl();
$token = $this->configHelper->getApiToken();
$client = $this->clientFactory->create(['config' => [
'http_errors' => false,
'base_uri' => $baseUrl,
'headers' => [
'Content-type' => 'application/json',
'Authorization' => "Bearer $token"
]
]]);
$result = $client->request('GET', 'whi/connectiontest');
http_response_code($result->getStatusCode());
exit;
}
public function execute() { }
}