-
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
25f2cfa
commit 2d26cf9
Showing
8 changed files
with
154 additions
and
177 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,60 @@ | ||
<?php | ||
|
||
namespace ProgrammatorDev\SportMonksFootball\Resource; | ||
|
||
use ProgrammatorDev\SportMonksFootball\Entity\Response\MarketCollection; | ||
use ProgrammatorDev\SportMonksFootball\Entity\Response\MarketItem; | ||
use ProgrammatorDev\SportMonksFootball\Resource\Util\PaginationTrait; | ||
use ProgrammatorDev\Validator\Exception\ValidationException; | ||
use Psr\Http\Client\ClientExceptionInterface; | ||
|
||
class MarketResource extends Resource | ||
{ | ||
use PaginationTrait; | ||
|
||
/** | ||
* @throws ClientExceptionInterface | ||
*/ | ||
public function getAll(): MarketCollection | ||
{ | ||
$data = $this->api->request( | ||
method: 'GET', | ||
path: '/v3/odds/markets' | ||
); | ||
|
||
return new MarketCollection($data); | ||
} | ||
|
||
/** | ||
* @throws ClientExceptionInterface | ||
*/ | ||
public function getById(int $id): MarketItem | ||
{ | ||
$data = $this->api->request( | ||
method: 'GET', | ||
path: $this->api->buildPath('/v3/odds/markets/{id}', [ | ||
'id' => $id | ||
]) | ||
); | ||
|
||
return new MarketItem($data); | ||
} | ||
|
||
/** | ||
* @throws ValidationException | ||
* @throws ClientExceptionInterface | ||
*/ | ||
public function getAllBySearchQuery(string $query): MarketCollection | ||
{ | ||
$this->validateQuery($query, 'query'); | ||
|
||
$data = $this->api->request( | ||
method: 'GET', | ||
path: $this->api->buildPath('/v3/odds/markets/search/{query}', [ | ||
'query' => $query | ||
]) | ||
); | ||
|
||
return new MarketCollection($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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
namespace ProgrammatorDev\SportMonksFootball\Test\Integration; | ||
|
||
use ProgrammatorDev\SportMonksFootball\Entity\Response\MarketCollection; | ||
use ProgrammatorDev\SportMonksFootball\Entity\Response\MarketItem; | ||
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 MarketResourceTest extends AbstractTest | ||
{ | ||
use TestItemResponseTrait; | ||
use TestCollectionResponseTrait; | ||
use TestValidationExceptionTrait; | ||
|
||
public static function provideItemResponseData(): \Generator | ||
{ | ||
yield 'get by id' => [ | ||
MarketItem::class, | ||
MockResponse::MARKET_ITEM_DATA, | ||
'markets', | ||
'getById', | ||
[1] | ||
]; | ||
} | ||
|
||
public static function provideCollectionResponseData(): \Generator | ||
{ | ||
yield 'get all' => [ | ||
MarketCollection::class, | ||
MockResponse::MARKET_COLLECTION_DATA, | ||
'markets', | ||
'getAll' | ||
]; | ||
yield 'get all by search query' => [ | ||
MarketCollection::class, | ||
MockResponse::MARKET_COLLECTION_DATA, | ||
'markets', | ||
'getAllBySearchQuery', | ||
['test'] | ||
]; | ||
} | ||
|
||
public static function provideValidationExceptionData(): \Generator | ||
{ | ||
yield 'get all by search query, blank query' => [ | ||
'markets', | ||
'getAllBySearchQuery', | ||
[''] | ||
]; | ||
} | ||
} |
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.
Oops, something went wrong.