Skip to content

Commit

Permalink
add event id implode
Browse files Browse the repository at this point in the history
  • Loading branch information
SethSharp committed Aug 2, 2024
1 parent fa0f331 commit 58db996
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/OddsClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
use GuzzleHttp\Psr7\Response;
use SethSharp\OddsApi\Enums\SportsEnum;
use GuzzleHttp\Exception\RequestException;
use SethSharp\OddsApi\Traits\EventHelpers;
use SethSharp\OddsApi\Traits\UseHandleHeaders;

class OddsClient
{
use EventHelpers;
use UseHandleHeaders;

private Client $client;
Expand Down Expand Up @@ -152,12 +154,16 @@ public function setBookmakers(mixed $bookmakers): self
}

/**
* @param string $eventId
* @param string|array $eventId
* @return $this
*/
public function setEvent(string $eventId): self
public function setEvents(string|array $eventId): self
{
$this->params['eventIds'] = $eventId;
if (is_array($eventId)) {
$this->params['eventIds'] = $this->buildEvents($eventId);
} else {
$this->params['eventIds'] = $eventId;
}

return $this;
}
Expand Down
11 changes: 11 additions & 0 deletions src/Traits/EventHelpers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace SethSharp\OddsApi\Traits;

trait EventHelpers
{
protected function buildEvents(array $eventIds): string
{
return implode(',', $eventIds);
}
}

0 comments on commit 58db996

Please sign in to comment.