Skip to content

Commit

Permalink
events: support region
Browse files Browse the repository at this point in the history
  • Loading branch information
dakur committed Jul 16, 2024
1 parent ccac76d commit 09d9a3f
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ foreach ($events as $event) {

#### Filters

Events can be filtered by group, category, program or intended for:
Events can be filtered by group, category, program, intended for and other options:

```php
$parameters = new \HnutiBrontosaurus\BisClient\Event\Request\EventParameters();
Expand All @@ -93,6 +93,9 @@ $parameters->setIntendedFor(\HnutiBrontosaurus\BisClient\Event\IntendedFor::FIRS
// only for some administration units
$parameters->setAdministrationUnit(5);

// only in "Vysočina" region
$parameters->setRegion(\HnutiBrontosaurus\BisClient\Event\Request\Region::VYSOCINA());

$events = $client->getEvents($parameters);
```

Expand Down
24 changes: 24 additions & 0 deletions src/Event/Request/EventParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,27 @@ public function setAdministrationUnits(array $ids): self
}


// region

/** @var Region[] */
private array $regions = [];

public function setRegion(Region $region): self
{
$this->regions = [$region];
return $this;
}

/**
* @param Region[] $regions
*/
public function setRegions(array $regions): self
{
$this->regions = $regions;
return $this;
}


// groups

/** @var Group[] */
Expand Down Expand Up @@ -258,6 +279,9 @@ public function toArray(): array
if (count($this->administrationUnits) > 0) {
$array['administration_unit'] = implode(',', $this->administrationUnits);
}
if (count($this->regions) > 0) {
$array['region'] = implode(',', $this->regions);
}
if (count($this->groups) > 0) {
$array['group'] = implode(',', $this->groups);
}
Expand Down
44 changes: 44 additions & 0 deletions src/Event/Request/Region.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php declare(strict_types = 1);

namespace HnutiBrontosaurus\BisClient\Event\Request;

use Grifart\Enum\AutoInstances;
use Grifart\Enum\Enum;


/**
* @method static Region PRAHA()
* @method static Region STREDOCESKY()
* @method static Region JIHOCESKY()
* @method static Region PLZENSKY()
* @method static Region KARLOVARSKY()
* @method static Region USTECKY()
* @method static Region LIBERECKY()
* @method static Region KRALOVEHRADECKY()
* @method static Region PARDUBICKY()
* @method static Region VYSOCINA()
* @method static Region JIHOMORAVSKY()
* @method static Region OLOMOUCKY()
* @method static Region MORAVSKOSLEZSKY()
* @method static Region ZLINSKY()
*/
final class Region extends Enum
{
use AutoInstances;

protected const PRAHA = 1;
protected const STREDOCESKY = 2;
protected const JIHOCESKY = 3;
protected const PLZENSKY = 4;
protected const KARLOVARSKY = 5;
protected const USTECKY = 6;
protected const LIBERECKY = 7;
protected const KRALOVEHRADECKY = 8;
protected const PARDUBICKY = 9;
protected const VYSOCINA = 10;
protected const JIHOMORAVSKY = 11;
protected const OLOMOUCKY = 12;
protected const MORAVSKOSLEZSKY = 13;
protected const ZLINSKY = 14;

}

0 comments on commit 09d9a3f

Please sign in to comment.