Skip to content

Commit

Permalink
event: support tags in request
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Kurowski committed Nov 28, 2023
1 parent fdf3072 commit 31735bf
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ $parameters->setGroup(\HnutiBrontosaurus\BisClient\Event\Group::CAMP());
// only events of "voluntary" category
$parameters->setCategory(\HnutiBrontosaurus\BisClient\Event\Category::VOLUNTEERING());

// only events of "region_event" tag
$parameters->setTag(\HnutiBrontosaurus\BisClient\Event\Tag::REGION_EVENT());

// only events of "PsB" program
$parameters->setProgram(\HnutiBrontosaurus\BisClient\Event\Program::HOLIDAYS_WITH_BRONTOSAURUS());

Expand Down
25 changes: 25 additions & 0 deletions src/Event/Request/EventParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use HnutiBrontosaurus\BisClient\Event\Group;
use HnutiBrontosaurus\BisClient\Event\IntendedFor;
use HnutiBrontosaurus\BisClient\Event\Program;
use HnutiBrontosaurus\BisClient\Event\Tag;
use HnutiBrontosaurus\BisClient\LimitParameter;
use HnutiBrontosaurus\BisClient\QueryParameters;
use function count;
Expand Down Expand Up @@ -95,6 +96,27 @@ public function setCategories(array $categories): self
}


// tag

/** @var Tag[] */
private array $tags = [];

public function setTag(Tag $tag): self
{
$this->tags = [$tag];
return $this;
}

/**
* @param Tag[] $tags
*/
public function setTags(array $tags): self
{
$this->tags = $tags;
return $this;
}


// program

/** @var Program[] */
Expand Down Expand Up @@ -242,6 +264,9 @@ public function toArray(): array
if (count($this->categories) > 0) {
$array['category'] = implode(',', $this->categories);
}
if (count($this->tags) > 0) {
$array['tags'] = implode(',', $this->tags);
}
if (count($this->programs) > 0) {
$array['program'] = implode(',', $this->programs);
}
Expand Down
19 changes: 19 additions & 0 deletions src/Event/Tag.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php declare(strict_types = 1);

namespace HnutiBrontosaurus\BisClient\Event;

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


/**
* @method static Tag RETRO_EVENT()
* @method static Tag REGION_EVENT()
*/
final class Tag extends Enum
{
use AutoInstances;

protected const RETRO_EVENT = 'retro_event';
protected const REGION_EVENT = 'region_event';
}

0 comments on commit 31735bf

Please sign in to comment.