Initial commit
This commit is contained in:
41
Controller/Adminhtml/Connection/Index.php
Normal file
41
Controller/Adminhtml/Connection/Index.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?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() { }
|
||||
}
|
||||
Reference in New Issue
Block a user