-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5972081
commit f6fba6d
Showing
7 changed files
with
193 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
|
||
namespace ProgrammatorDev\SportMonksFootball\Resource; | ||
|
||
use ProgrammatorDev\SportMonksFootball\Entity\Response\VenueCollection; | ||
use ProgrammatorDev\SportMonksFootball\Entity\Response\VenueItem; | ||
use ProgrammatorDev\SportMonksFootball\Resource\Util\PaginationTrait; | ||
use ProgrammatorDev\Validator\Exception\ValidationException; | ||
use Psr\Http\Client\ClientExceptionInterface; | ||
|
||
class VenueResource extends Resource | ||
{ | ||
use PaginationTrait; | ||
|
||
/** | ||
* @throws ClientExceptionInterface | ||
*/ | ||
public function getAll(): VenueCollection | ||
{ | ||
$data = $this->api->request( | ||
method: 'GET', | ||
path: '/v3/football/venues' | ||
); | ||
|
||
return new VenueCollection($data); | ||
} | ||
|
||
/** | ||
* @throws ClientExceptionInterface | ||
*/ | ||
public function getById(int $id): VenueItem | ||
{ | ||
$data = $this->api->request( | ||
method: 'GET', | ||
path: $this->api->buildPath('/v3/football/venues/{id}', [ | ||
'id' => $id | ||
]) | ||
); | ||
|
||
return new VenueItem($data); | ||
} | ||
|
||
/** | ||
* @throws ClientExceptionInterface | ||
*/ | ||
public function getAllBySeasonId(int $seasonId): VenueCollection | ||
{ | ||
$data = $this->api->request( | ||
method: 'GET', | ||
path: $this->api->buildPath('/v3/football/venues/seasons/{seasonId}', [ | ||
'seasonId' => $seasonId | ||
]) | ||
); | ||
|
||
return new VenueCollection($data); | ||
} | ||
|
||
/** | ||
* @throws ValidationException | ||
* @throws ClientExceptionInterface | ||
*/ | ||
public function getAllBySearchQuery(string $query): VenueCollection | ||
{ | ||
$this->validateQuery($query); | ||
|
||
$data = $this->api->request( | ||
method: 'GET', | ||
path: $this->api->buildPath('/v3/football/venues/search/{query}', [ | ||
'query' => $query | ||
]) | ||
); | ||
|
||
return new VenueCollection($data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
namespace ProgrammatorDev\SportMonksFootball\Test\Integration; | ||
|
||
use ProgrammatorDev\SportMonksFootball\Entity\Response\VenueCollection; | ||
use ProgrammatorDev\SportMonksFootball\Entity\Response\VenueItem; | ||
use ProgrammatorDev\SportMonksFootball\Test\AbstractTest; | ||
use ProgrammatorDev\SportMonksFootball\Test\MockResponse; | ||
use ProgrammatorDev\SportMonksFootball\Test\Util\TestCollectionResponseTrait; | ||
use ProgrammatorDev\SportMonksFootball\Test\Util\TestItemResponseTrait; | ||
use ProgrammatorDev\SportMonksFootball\Test\Util\TestValidationExceptionTrait; | ||
|
||
class VenueResourceTest extends AbstractTest | ||
{ | ||
use TestItemResponseTrait; | ||
use TestCollectionResponseTrait; | ||
use TestValidationExceptionTrait; | ||
|
||
public static function provideItemResponseData(): \Generator | ||
{ | ||
yield 'get by id' => [ | ||
VenueItem::class, | ||
MockResponse::VENUE_ITEM_DATA, | ||
'venues', | ||
'getById', | ||
[1] | ||
]; | ||
} | ||
|
||
public static function provideCollectionResponseData(): \Generator | ||
{ | ||
yield 'get all' => [ | ||
VenueCollection::class, | ||
MockResponse::VENUE_COLLECTION_DATA, | ||
'venues', | ||
'getAll' | ||
]; | ||
yield 'get all by season id' => [ | ||
VenueCollection::class, | ||
MockResponse::VENUE_COLLECTION_DATA, | ||
'venues', | ||
'getAllBySeasonId', | ||
[1] | ||
]; | ||
yield 'get all by search query' => [ | ||
VenueCollection::class, | ||
MockResponse::VENUE_COLLECTION_DATA, | ||
'venues', | ||
'getAllBySearchQuery', | ||
['test'] | ||
]; | ||
} | ||
|
||
public static function provideValidationExceptionData(): \Generator | ||
{ | ||
yield 'get all by search query, blank query' => [ | ||
'venues', | ||
'getAllBySearchQuery', | ||
[''] | ||
]; | ||
} | ||
} |
Oops, something went wrong.