Skip to content

Commit

Permalink
feat: added fixture resource
Browse files Browse the repository at this point in the history
  • Loading branch information
andrepimpao committed May 20, 2024
1 parent ff64f16 commit 241c2b5
Show file tree
Hide file tree
Showing 12 changed files with 449 additions and 651 deletions.
92 changes: 21 additions & 71 deletions docs/03-supported-endpoints.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,23 +217,17 @@ $response = $api->commentaries()->getAllByFixtureId(1);
### Fixtures

- [Official documentation](https://docs.sportmonks.com/football/endpoints-and-entities/endpoints/fixtures)
- Cache default max age: `1 hour`
- `getAllLastUpdated` cache max age: `10 seconds`

#### `getAll`

```php
getAll(int $page = 1, int $perPage = 25, string $order = 'asc'): FixtureCollection
getAll(): FixtureCollection
```

Get all fixtures:

```php
$fixtures = $sportMonksFootball->fixtures()->getAll();

foreach ($fixtures->getData() as $fixture) {
echo $fixture->getName();
}
$response = $api->fixtures()->getAll();
```

#### `getById`
Expand All @@ -245,8 +239,7 @@ getById(int $id): FixtureItem
Get fixture by id:

```php
$fixture = $sportMonksFootball->fixtures()->getById(1);
echo $fixture->getData()->getName();
$response = $api->fixtures()->getById(1);
```

#### `getAllByMultipleIds`
Expand All @@ -258,139 +251,103 @@ getAllByMultipleIds(array $ids): FixtureCollection
Get all fixtures by multiple ids:

```php
$fixtures = $sportMonksFootball->fixtures()->getAllByMultipleIds([1, 2, 3]);

foreach ($fixtures->getData() as $fixture) {
echo $fixture->getName();
}
$response = $api->fixtures()->getAllByMultipleIds([1, 2, 3]);
```

#### `getAllByDate`

```php
getAllByDate(\DateTimeInterface $date, int $page = 1, int $perPage = 25, string $order = 'asc'): FixtureCollection
getAllByDate(\DateTimeInterface $date): FixtureCollection
```

Get all fixtures by date:

```php
$fixtures = $sportMonksFootball->fixtures()->getAllByDate(new DateTime('today'));

foreach ($fixtures->getData() as $fixture) {
echo $fixture->getName();
}
$response = $api->fixtures()->getAllByDate(new DateTime('today'));
```

#### `getAllByDateRange`

```php
getAllByDateRange(\DateTimeInterface $startDate, \DateTimeInterface $endDate, int $page = 1, int $perPage = 25, string $order = 'asc'): FixtureCollection
getAllByDateRange(\DateTimeInterface $startDate, \DateTimeInterface $endDate): FixtureCollection
```

Get all fixtures by date range:

```php
$fixtures = $sportMonksFootball->fixtures()->getAllByDateRange(new DateTime('today'), new DateTime('+7 days'));

foreach ($fixtures->getData() as $fixture) {
echo $fixture->getName();
}
$response = $api->fixtures()->getAllByDateRange(new DateTime('today'), new DateTime('+7 days'));
```

#### `getAllByTeamIdAndDateRange`

```php
getAllByTeamIdAndDateRange(int $teamId, \DateTimeInterface $startDate, \DateTimeInterface $endDate, int $page = 1, int $perPage = 25, string $order = 'asc'): FixtureCollection
getAllByTeamIdAndDateRange(int $teamId, \DateTimeInterface $startDate, \DateTimeInterface $endDate): FixtureCollection
```

Get all fixtures by team id and date range:

```php
$fixtures = $sportMonksFootball->fixtures()->getAllByTeamIdAndDateRange(1, new DateTime('today'), new DateTime('+7 days'));

foreach ($fixtures->getData() as $fixture) {
echo $fixture->getName();
}
$response = $api->fixtures()->getAllByTeamIdAndDateRange(1, new DateTime('today'), new DateTime('+7 days'));
```

#### `getAllByHeadToHead`

```php
getAllByHeadToHead(int $teamIdOne, int $teamIdTwo): FixtureCollection
getAllByHeadToHead(int $teamId1, int $teamId2): FixtureCollection
```

Get all fixtures between two teams:

```php
$fixtures = $sportMonksFootball->fixtures()->getAllByHeadToHead(1, 2);

foreach ($fixtures->getData() as $fixture) {
echo $fixture->getName();
}
$response = $api->fixtures()->getAllByHeadToHead(1, 2);
```

#### `getAllBySearchQuery`

```php
getAllBySearchQuery(string $query, int $page = 1, int $perPage = 25, string $order = 'asc'): FixtureCollection
getAllBySearchQuery(string $query): FixtureCollection
```

Get all fixtures by search query:

```php
$fixtures = $sportMonksFootball->fixtures()->getAllBySearchQuery('sporting');

foreach ($fixtures->getData() as $fixture) {
echo $fixture->getName();
}
$response = $api->fixtures()->getAllBySearchQuery('team');
```

#### `getAllUpcomingByMarketId`

```php
getAllUpcomingByMarketId(int $marketId, int $page = 1, int $perPage = 25, string $order = 'asc'): FixtureCollection
getAllUpcomingByMarketId(int $marketId): FixtureCollection
```

Get all upcoming fixtures by market id:

```php
$fixtures = $sportMonksFootball->fixtures()->getAllUpcomingByMarketId(1);

foreach ($fixtures->getData() as $fixture) {
echo $fixture->getName();
}
$response = $api->fixtures()->getAllUpcomingByMarketId(1);
```

#### `getAllUpcomingByTvStationId`

```php
getAllUpcomingByTvStationId(int $tvStationId, int $page = 1, int $perPage = 25, string $order = 'asc'): FixtureCollection
getAllUpcomingByTvStationId(int $tvStationId): FixtureCollection
```

Get all upcoming fixtures by tv station id:

```php
$fixtures = $sportMonksFootball->fixtures()->getAllUpcomingByTvStationId(1);

foreach ($fixtures->getData() as $fixture) {
echo $fixture->getName();
}
$response = $api->fixtures()->getAllUpcomingByTvStationId(1);
```

#### `getAllPastByTvStationId`

```php
getAllPastByTvStationId(int $tvStationId, int $page = 1, int $perPage = 25, string $order = 'asc'): FixtureCollection
getAllPastByTvStationId(int $tvStationId): FixtureCollection
```

Get all past fixtures by tv station id:

```php
$fixtures = $sportMonksFootball->fixtures()->getAllPastByTvStationId(1);

foreach ($fixtures->getData() as $fixture) {
echo $fixture->getName();
}
$response = $api->fixtures()->getAllPastByTvStationId(1);
```

#### `getAllLastUpdated`
Expand All @@ -402,16 +359,9 @@ getAllLastUpdated(): FixtureCollection
Get all last updated fixtures:

```php
$fixtures = $sportMonksFootball->fixtures()->getAllLastUpdated();

foreach ($fixtures->getData() as $fixture) {
echo $fixture->getName();
}
$response = $api->fixtures()->getAllLastUpdated();
```

> **Note**
> Cache max age is forced to `10 seconds` on this endpoint.
### Leagues

- [Official documentation](https://docs.sportmonks.com/football/endpoints-and-entities/endpoints/leagues)
Expand Down
1 change: 1 addition & 0 deletions docs/05-entities.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@
- `getLength()`: `?int`
- `isPlaceholder()`: `?bool`
- `hasOdds()`: `?bool`
- `hasPremiumOdds()`: `?bool`
- `getSport()`: [`?Sport`](#sport) (`sport` include is required)
- `getStage()`: [`?Stage`](#stage) (`stage` include is required)
- `getLeague()`: [`?League`](#league) (`league` include is required)
Expand Down
Loading

0 comments on commit 241c2b5

Please sign in to comment.