Merge branch 'master' into develop

This commit is contained in:
Björn Fromme
2020-02-07 16:49:51 +01:00
@@ -26,6 +26,7 @@ namespace EP\EpProducts\Service;
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use CalendR\Period\Range;
use Doctrine\DBAL\DBALException;
use EP\EpProducts\Domain\Model\Contingent;
use EP\EpProducts\Domain\Model\Hotel;
@@ -119,6 +120,8 @@ class GroupsSwissService implements SingletonInterface, LoggerAwareInterface
$events = [];
}
$this->resetChart($range, $config['key'], $config['number']);
// $this->generateAvailabilityChart(
// $events,
// $config['key'],
@@ -172,6 +175,21 @@ class GroupsSwissService implements SingletonInterface, LoggerAwareInterface
$this->logger->info(sprintf('Published %d dates.', $itemCount));
}
/**
* @param Period $range
* @param string $apiKey
* @param string $houseNumber
*/
protected function resetChart(Period $range, $apiKey, $houseNumber): void
{
$item = [
'from' => $range->getStartDate()->format('Y-m-d'),
'to' => $range->getEndDate()->format('Y-m-d'),
];
$this->addItem($item, 0, $apiKey, $houseNumber);
}
/**
* @param array $events
* @param string $apiKey
@@ -210,10 +228,6 @@ class GroupsSwissService implements SingletonInterface, LoggerAwareInterface
*/
protected function addItem(array $item, $status, $apiKey, $houseNumber): void
{
if (0 === $item['occupancy']) {
return;
}
$url = sprintf(
'http://www.groups.swiss/api/1.0/json.php?apiKey=%s&method=setAvailabilityChart&house=%d&from=%s&till=%s&state=%d',
$apiKey,