Task: Simplify code
This commit is contained in:
@@ -162,7 +162,7 @@ class GroupsSwissService implements SingletonInterface, LoggerAwareInterface
|
||||
return Contingent::STATUS_BLOCKED;
|
||||
}
|
||||
|
||||
if ($percentageAvailable > 20 && $percentageAvailable <= 80) {
|
||||
if ($percentageAvailable <= 80) {
|
||||
return $contingent::STATUS_ONREQUEST;
|
||||
}
|
||||
|
||||
@@ -177,25 +177,31 @@ class GroupsSwissService implements SingletonInterface, LoggerAwareInterface
|
||||
*/
|
||||
protected function addItem(array $item, $status, $apiKey, $houseNumber): void
|
||||
{
|
||||
$from = $item['from']->format('Y-m-d');
|
||||
$to = $item['to']->format('Y-m-d');
|
||||
|
||||
$this->logger->info(sprintf(
|
||||
'Adding status %d in %s-%s for %s',
|
||||
$status,
|
||||
$item['from']->format('Y-m-d'),
|
||||
$item['to']->format('Y-m-d'),
|
||||
$from,
|
||||
$to,
|
||||
$houseNumber
|
||||
));
|
||||
|
||||
$url = sprintf(
|
||||
'https://www.groups.swiss/api/1.0/json.php?apiKey=%s&method=setAvailabilityChart&house=%d&from=%s&till=%s&state=%d',
|
||||
$apiKey,
|
||||
$houseNumber,
|
||||
$item['from']->format('Y-m-d'),
|
||||
$item['to']->format('Y-m-d'),
|
||||
$status
|
||||
);
|
||||
|
||||
try {
|
||||
$response = $this->httpClient->request('GET', $url);
|
||||
$response = $this
|
||||
->httpClient
|
||||
->request('GET', 'https://www.groups.swiss/api/1.0/json.php', [
|
||||
'query' => [
|
||||
'apiKey' => $apiKey,
|
||||
'method' => 'setAvailabilityChart',
|
||||
'house' => $houseNumber,
|
||||
'from' => $from,
|
||||
'till' => $to,
|
||||
'state' => $status,
|
||||
],
|
||||
])
|
||||
;
|
||||
$this->logger->info($response->getContent());
|
||||
} catch (TransportExceptionInterface $e) {
|
||||
$this->logger->error(sprintf('A problem occured: %s', $e->getMessage()));
|
||||
|
||||
Reference in New Issue
Block a user