-
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
20b7b98
commit 826a12e
Showing
10 changed files
with
260 additions
and
390 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,104 @@ | ||
<?php | ||
|
||
namespace ProgrammatorDev\SportMonksFootball\Resource; | ||
|
||
use ProgrammatorDev\SportMonksFootball\Entity\Response\TransferCollection; | ||
use ProgrammatorDev\SportMonksFootball\Entity\Response\TransferItem; | ||
use ProgrammatorDev\SportMonksFootball\Resource\Util\PaginationTrait; | ||
use ProgrammatorDev\Validator\Exception\ValidationException; | ||
use Psr\Http\Client\ClientExceptionInterface; | ||
|
||
class TransferResource extends Resource | ||
{ | ||
use PaginationTrait; | ||
|
||
/** | ||
* @throws ClientExceptionInterface | ||
*/ | ||
public function getAll(): TransferCollection | ||
{ | ||
$data = $this->api->request( | ||
method: 'GET', | ||
path: '/v3/football/transfers' | ||
); | ||
|
||
return new TransferCollection($data); | ||
} | ||
|
||
/** | ||
* @throws ClientExceptionInterface | ||
*/ | ||
public function getById(int $id): TransferItem | ||
{ | ||
$data = $this->api->request( | ||
method: 'GET', | ||
path: $this->api->buildPath('/v3/football/transfers/{id}', [ | ||
'id' => $id | ||
]) | ||
); | ||
|
||
return new TransferItem($data); | ||
} | ||
|
||
/** | ||
* @throws ClientExceptionInterface | ||
*/ | ||
public function getAllLatest(): TransferCollection | ||
{ | ||
$data = $this->api->request( | ||
method: 'GET', | ||
path: '/v3/football/transfers/latest' | ||
); | ||
|
||
return new TransferCollection($data); | ||
} | ||
|
||
/** | ||
* @throws ValidationException | ||
* @throws ClientExceptionInterface | ||
*/ | ||
public function getAllByDateRange(\DateTimeInterface $startDate, \DateTimeInterface $endDate): TransferCollection | ||
{ | ||
$this->validateDateOrder($startDate, $endDate); | ||
|
||
$data = $this->api->request( | ||
method: 'GET', | ||
path: $this->api->buildPath('/v3/football/transfers/between/{startDate}/{endDate}', [ | ||
'startDate' => $startDate->format('Y-m-d'), | ||
'endDate' => $endDate->format('Y-m-d') | ||
]) | ||
); | ||
|
||
return new TransferCollection($data); | ||
} | ||
|
||
/** | ||
* @throws ClientExceptionInterface | ||
*/ | ||
public function getAllByTeamId(int $teamId): TransferCollection | ||
{ | ||
$data = $this->api->request( | ||
method: 'GET', | ||
path: $this->api->buildPath('/v3/football/transfers/teams/{teamId}', [ | ||
'teamId' => $teamId | ||
]) | ||
); | ||
|
||
return new TransferCollection($data); | ||
} | ||
|
||
/** | ||
* @throws ClientExceptionInterface | ||
*/ | ||
public function getAllByPlayerId(int $playerId): TransferCollection | ||
{ | ||
$data = $this->api->request( | ||
method: 'GET', | ||
path: $this->api->buildPath('/v3/football/transfers/players/{playerId}', [ | ||
'playerId' => $playerId | ||
]) | ||
); | ||
|
||
return new TransferCollection($data); | ||
} | ||
} |
Oops, something went wrong.