Skip to content

Commit

Permalink
Merge pull request #64 from programmatordev/SPA-70-add-new-get-extend…
Browse files Browse the repository at this point in the history
…ed-team-squads-by-team-id-endpoint

Add new get extended team squads by team id endpoint
  • Loading branch information
andrepimpao authored Nov 29, 2023
2 parents ac119fe + 0c57315 commit 5d22354
Show file tree
Hide file tree
Showing 67 changed files with 201 additions and 127 deletions.
15 changes: 15 additions & 0 deletions docs/03-supported-endpoints.md
Original file line number Diff line number Diff line change
Expand Up @@ -1454,6 +1454,21 @@ foreach ($squad->getData() as $player) {
echo $player->getPlayerId();
}
```
#### `getAllExtendedByTeamId`

```php
getAllExtendedByTeamId(int $teamId): PlayerCollection
```

Get complete team squad entried based on the current season by team id:

```php
$squad = $sportMonksFootball->teamSquads()->getAllExtendedByTeamId(1);

foreach ($squad->getData() as $player) {
echo $player->getName();
}
```

#### `getAllBySeasonIdAndTeamId`

Expand Down
1 change: 1 addition & 0 deletions docs/05-objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@
- `getWeight()`: `?int`
- `getDateOfBirth()`: `?\DateTimeImmutable`
- `getGender()`: `?string`
- `inSquad()`: `?bool`
- `getSport()`: [`?Sport`](#sport) (`sport` include is required)
- `getCountry()`: [`?Country`](#country) (`country` include is required)
- `getCity()`: [`?City`](#city) (`city` include is required)
Expand Down
17 changes: 17 additions & 0 deletions src/Endpoint/TeamSquadEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use ProgrammatorDev\SportMonksFootball\Endpoint\Util\IncludeTrait;
use ProgrammatorDev\SportMonksFootball\Endpoint\Util\LanguageTrait;
use ProgrammatorDev\SportMonksFootball\Endpoint\Util\SelectTrait;
use ProgrammatorDev\SportMonksFootball\Entity\Response\PlayerCollection;
use ProgrammatorDev\SportMonksFootball\Entity\Response\TeamSquadCollection;
use ProgrammatorDev\SportMonksFootball\Exception\ApiErrorException;

Expand Down Expand Up @@ -35,6 +36,22 @@ public function getAllByTeamId(int $teamId): TeamSquadCollection
return new TeamSquadCollection($response);
}

/**
* @throws Exception
* @throws ApiErrorException
*/
public function getAllExtendedByTeamId(int $teamId): PlayerCollection
{
$response = $this->sendRequest(
method: 'GET',
path: $this->formatPath('/v3/football/squads/teams/{teamId}/extended', [
'teamId' => $teamId
])
);

return new PlayerCollection($response);
}

/**
* @throws Exception
* @throws ApiErrorException
Expand Down
4 changes: 2 additions & 2 deletions src/Entity/Coach.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace ProgrammatorDev\SportMonksFootball\Entity;

use ProgrammatorDev\SportMonksFootball\Util\CreateEntityCollectionTrait;
use ProgrammatorDev\SportMonksFootball\Util\EntityCollectionTrait;

class Coach
{
use CreateEntityCollectionTrait;
use EntityCollectionTrait;

private int $id;

Expand Down
4 changes: 2 additions & 2 deletions src/Entity/CoachStatistic.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace ProgrammatorDev\SportMonksFootball\Entity;

use ProgrammatorDev\SportMonksFootball\Util\CreateEntityCollectionTrait;
use ProgrammatorDev\SportMonksFootball\Util\EntityCollectionTrait;

class CoachStatistic extends ParticipantStatistic
{
use CreateEntityCollectionTrait;
use EntityCollectionTrait;

private int $coachId;

Expand Down
4 changes: 2 additions & 2 deletions src/Entity/Continent.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace ProgrammatorDev\SportMonksFootball\Entity;

use ProgrammatorDev\SportMonksFootball\Util\CreateEntityCollectionTrait;
use ProgrammatorDev\SportMonksFootball\Util\EntityCollectionTrait;

class Continent
{
use CreateEntityCollectionTrait;
use EntityCollectionTrait;

private int $id;

Expand Down
4 changes: 2 additions & 2 deletions src/Entity/Country.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace ProgrammatorDev\SportMonksFootball\Entity;

use ProgrammatorDev\SportMonksFootball\Util\CreateEntityCollectionTrait;
use ProgrammatorDev\SportMonksFootball\Util\EntityCollectionTrait;

class Country
{
use CreateEntityCollectionTrait;
use EntityCollectionTrait;

private int $id;

Expand Down
2 changes: 1 addition & 1 deletion src/Entity/FilterEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class FilterEntity
public function __construct(array $data)
{
// "_key" index is injected in data to get the key from an associative array response
// Check the CreateEntityCollectionTrait
// Check the EntityCollectionTrait
$this->name = $data['_key'];

// Remove injected "_key" to not pollute filters data
Expand Down
4 changes: 2 additions & 2 deletions src/Entity/Fixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace ProgrammatorDev\SportMonksFootball\Entity;

use ProgrammatorDev\SportMonksFootball\Util\CreateEntityCollectionTrait;
use ProgrammatorDev\SportMonksFootball\Util\EntityCollectionTrait;

class Fixture
{
use CreateEntityCollectionTrait;
use EntityCollectionTrait;

private int $id;

Expand Down
4 changes: 2 additions & 2 deletions src/Entity/League.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace ProgrammatorDev\SportMonksFootball\Entity;

use ProgrammatorDev\SportMonksFootball\Util\CreateEntityCollectionTrait;
use ProgrammatorDev\SportMonksFootball\Util\EntityCollectionTrait;

class League
{
use CreateEntityCollectionTrait;
use EntityCollectionTrait;

private int $id;

Expand Down
4 changes: 2 additions & 2 deletions src/Entity/Lineup.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace ProgrammatorDev\SportMonksFootball\Entity;

use ProgrammatorDev\SportMonksFootball\Util\CreateEntityCollectionTrait;
use ProgrammatorDev\SportMonksFootball\Util\EntityCollectionTrait;

class Lineup
{
use CreateEntityCollectionTrait;
use EntityCollectionTrait;

private int $id;

Expand Down
4 changes: 2 additions & 2 deletions src/Entity/Period.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace ProgrammatorDev\SportMonksFootball\Entity;

use ProgrammatorDev\SportMonksFootball\Util\CreateEntityCollectionTrait;
use ProgrammatorDev\SportMonksFootball\Util\EntityCollectionTrait;

class Period
{
use CreateEntityCollectionTrait;
use EntityCollectionTrait;

private int $id;

Expand Down
12 changes: 10 additions & 2 deletions src/Entity/Player.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace ProgrammatorDev\SportMonksFootball\Entity;

use ProgrammatorDev\SportMonksFootball\Util\CreateEntityCollectionTrait;
use ProgrammatorDev\SportMonksFootball\Util\EntityCollectionTrait;

class Player
{
use CreateEntityCollectionTrait;
use EntityCollectionTrait;

private int $id;

Expand Down Expand Up @@ -44,6 +44,8 @@ class Player

private ?string $gender;

private ?bool $inSquad;

private ?Sport $sport;

private ?Country $country;
Expand Down Expand Up @@ -102,6 +104,7 @@ public function __construct(array $data, string $timezone)
$this->weight = $data['weight'] ?? null;
$this->dateOfBirth = isset($data['date_of_birth']) ? new \DateTimeImmutable($data['date_of_birth']) : null;
$this->gender = $data['gender'] ?? null;
$this->inSquad = $data['in_squad'] ?? null;

// include
$this->sport = isset($data['sport']) ? new Sport($data['sport']) : null;
Expand Down Expand Up @@ -210,6 +213,11 @@ public function getGender(): ?string
return $this->gender;
}

public function inSquad(): ?bool
{
return $this->inSquad;
}

public function getSport(): ?Sport
{
return $this->sport;
Expand Down
4 changes: 2 additions & 2 deletions src/Entity/PlayerStatistic.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace ProgrammatorDev\SportMonksFootball\Entity;

use ProgrammatorDev\SportMonksFootball\Util\CreateEntityCollectionTrait;
use ProgrammatorDev\SportMonksFootball\Util\EntityCollectionTrait;

class PlayerStatistic extends ParticipantStatistic
{
use CreateEntityCollectionTrait;
use EntityCollectionTrait;

private int $playerId;

Expand Down
4 changes: 2 additions & 2 deletions src/Entity/Referee.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace ProgrammatorDev\SportMonksFootball\Entity;

use ProgrammatorDev\SportMonksFootball\Util\CreateEntityCollectionTrait;
use ProgrammatorDev\SportMonksFootball\Util\EntityCollectionTrait;

class Referee
{
use CreateEntityCollectionTrait;
use EntityCollectionTrait;

private int $id;

Expand Down
4 changes: 2 additions & 2 deletions src/Entity/RefereeStatistic.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace ProgrammatorDev\SportMonksFootball\Entity;

use ProgrammatorDev\SportMonksFootball\Util\CreateEntityCollectionTrait;
use ProgrammatorDev\SportMonksFootball\Util\EntityCollectionTrait;

class RefereeStatistic extends ParticipantStatistic
{
use CreateEntityCollectionTrait;
use EntityCollectionTrait;

private int $refereeId;

Expand Down
4 changes: 2 additions & 2 deletions src/Entity/Region.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace ProgrammatorDev\SportMonksFootball\Entity;

use ProgrammatorDev\SportMonksFootball\Util\CreateEntityCollectionTrait;
use ProgrammatorDev\SportMonksFootball\Util\EntityCollectionTrait;

class Region
{
use CreateEntityCollectionTrait;
use EntityCollectionTrait;

private int $id;

Expand Down
4 changes: 2 additions & 2 deletions src/Entity/Response/AbstractResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

use ProgrammatorDev\SportMonksFootball\Entity\RateLimit;
use ProgrammatorDev\SportMonksFootball\Entity\Subscription;
use ProgrammatorDev\SportMonksFootball\Util\CreateEntityCollectionTrait;
use ProgrammatorDev\SportMonksFootball\Util\EntityCollectionTrait;

class AbstractResponse
{
use CreateEntityCollectionTrait;
use EntityCollectionTrait;

private array $subscriptions;

Expand Down
4 changes: 2 additions & 2 deletions src/Entity/Response/BookmakerCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
namespace ProgrammatorDev\SportMonksFootball\Entity\Response;

use ProgrammatorDev\SportMonksFootball\Entity\Bookmaker;
use ProgrammatorDev\SportMonksFootball\Util\CreateEntityCollectionTrait;
use ProgrammatorDev\SportMonksFootball\Util\EntityCollectionTrait;

class BookmakerCollection extends AbstractCollectionResponse
{
use CreateEntityCollectionTrait;
use EntityCollectionTrait;

/** @var Bookmaker[] */
private array $data;
Expand Down
4 changes: 2 additions & 2 deletions src/Entity/Response/CityCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
namespace ProgrammatorDev\SportMonksFootball\Entity\Response;

use ProgrammatorDev\SportMonksFootball\Entity\City;
use ProgrammatorDev\SportMonksFootball\Util\CreateEntityCollectionTrait;
use ProgrammatorDev\SportMonksFootball\Util\EntityCollectionTrait;

class CityCollection extends AbstractCollectionResponse
{
use CreateEntityCollectionTrait;
use EntityCollectionTrait;

/** @var City[] */
private array $data;
Expand Down
4 changes: 2 additions & 2 deletions src/Entity/Response/CoachCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
namespace ProgrammatorDev\SportMonksFootball\Entity\Response;

use ProgrammatorDev\SportMonksFootball\Entity\Coach;
use ProgrammatorDev\SportMonksFootball\Util\CreateEntityCollectionTrait;
use ProgrammatorDev\SportMonksFootball\Util\EntityCollectionTrait;

class CoachCollection extends AbstractCollectionResponse
{
use CreateEntityCollectionTrait;
use EntityCollectionTrait;

/** @var Coach[] */
private array $data;
Expand Down
4 changes: 2 additions & 2 deletions src/Entity/Response/CoachStatisticCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
namespace ProgrammatorDev\SportMonksFootball\Entity\Response;

use ProgrammatorDev\SportMonksFootball\Entity\CoachStatistic;
use ProgrammatorDev\SportMonksFootball\Util\CreateEntityCollectionTrait;
use ProgrammatorDev\SportMonksFootball\Util\EntityCollectionTrait;

class CoachStatisticCollection extends AbstractCollectionResponse
{
use CreateEntityCollectionTrait;
use EntityCollectionTrait;

/** @var CoachStatistic[] */
private array $data;
Expand Down
4 changes: 2 additions & 2 deletions src/Entity/Response/CommentaryCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
namespace ProgrammatorDev\SportMonksFootball\Entity\Response;

use ProgrammatorDev\SportMonksFootball\Entity\Commentary;
use ProgrammatorDev\SportMonksFootball\Util\CreateEntityCollectionTrait;
use ProgrammatorDev\SportMonksFootball\Util\EntityCollectionTrait;

class CommentaryCollection extends AbstractCollectionResponse
{
use CreateEntityCollectionTrait;
use EntityCollectionTrait;

/** @var Commentary[] */
private array $data;
Expand Down
4 changes: 2 additions & 2 deletions src/Entity/Response/ContinentCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
namespace ProgrammatorDev\SportMonksFootball\Entity\Response;

use ProgrammatorDev\SportMonksFootball\Entity\Continent;
use ProgrammatorDev\SportMonksFootball\Util\CreateEntityCollectionTrait;
use ProgrammatorDev\SportMonksFootball\Util\EntityCollectionTrait;

class ContinentCollection extends AbstractCollectionResponse
{
use CreateEntityCollectionTrait;
use EntityCollectionTrait;

/** @var Continent[] */
private array $data;
Expand Down
4 changes: 2 additions & 2 deletions src/Entity/Response/CountryCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
namespace ProgrammatorDev\SportMonksFootball\Entity\Response;

use ProgrammatorDev\SportMonksFootball\Entity\Country;
use ProgrammatorDev\SportMonksFootball\Util\CreateEntityCollectionTrait;
use ProgrammatorDev\SportMonksFootball\Util\EntityCollectionTrait;

class CountryCollection extends AbstractCollectionResponse
{
use CreateEntityCollectionTrait;
use EntityCollectionTrait;

/** @var Country[] */
private array $data;
Expand Down
Loading

0 comments on commit 5d22354

Please sign in to comment.