Connect contact forms with buspro api
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\Service;
|
||||
|
||||
use Symfony\Component\HttpClient\HttpClient;
|
||||
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||
use TYPO3\CMS\Core\SingletonInterface;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
|
||||
|
||||
class BookingApiService implements SingletonInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $apiToken;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $apiEndpointUrl;
|
||||
|
||||
/**
|
||||
* @param ConfigurationManagerInterface $manager
|
||||
*/
|
||||
public function __construct(ConfigurationManagerInterface $manager)
|
||||
{
|
||||
$settings = GeneralUtility::removeDotsFromTS(
|
||||
$manager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT)
|
||||
);
|
||||
|
||||
$this->apiToken = $settings['plugin']['tx_eptheme']['settings']['myEpApiToken'];
|
||||
$this->apiEndpointUrl = $settings['plugin']['tx_eptheme']['settings']['myEpApiBaseUrl'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $addressData
|
||||
*/
|
||||
public function registerAddress(array $addressData)
|
||||
{
|
||||
$client = HttpClient::create();
|
||||
|
||||
try {
|
||||
$client->request('POST', $this->apiEndpointUrl . '/booking/address', [
|
||||
'headers' => [
|
||||
'X-AUTH-TOKEN' => $this->apiToken,
|
||||
],
|
||||
'body' => [
|
||||
'data' => $addressData,
|
||||
],
|
||||
]);
|
||||
}
|
||||
catch (TransportExceptionInterface $e)
|
||||
{}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user