From a7733190ac792c6fb2653859dc8e02c3923aecba Mon Sep 17 00:00:00 2001 From: Joe Saunderson Date: Tue, 1 Oct 2019 12:28:38 +0100 Subject: [PATCH] Add Prediction API #7 --- README.md | 32 ++++++++++++++++++ src/Endpoint/Prediction.php | 66 +++++++++++++++++++++++++++++++++++++ src/SoccerApi.php | 9 +++++ 3 files changed, 107 insertions(+) create mode 100644 src/Endpoint/Prediction.php diff --git a/README.md b/README.md index fbb63f4..c80ba71 100644 --- a/README.md +++ b/README.md @@ -256,6 +256,38 @@ $response = SoccerApi::odds()->getInPlayByFixtureId($fixtureId); $response = SoccerApi::players()->getById($playerId); ``` +### Predictions + +##### Get Leagues [View Sportmonks Docs](https://sportmonks.com/docs/football/2.0/prediction-api/a/leagues-performance/211) + +```php +$response = SoccerApi::predictions()->getLeagues() +``` + +##### Get Probabilities [View Sportmonks Docs](https://sportmonks.com/docs/football/2.0/prediction-api/a/probabilities/212) + +```php +$response = SoccerApi::predictions()->getProbabilities() +``` + +##### Get Probabilities By Fixture Id [View Sportmonks Docs](https://sportmonks.com/docs/football/2.0/prediction-api/a/probability-by-fixture-id/214) + +```php +$response = SoccerApi::predictions()->getProbabilitiesByFixtureId($fixtureId) +``` + +##### Get Value Bets [View Sportmonks Docs](https://sportmonks.com/docs/football/2.0/prediction-api/a/value-bets/213) + +```php +$response = SoccerApi::predictions()->getValueBets() +``` + +##### Get Value Bets By Fixture Id [View Sportmonks Docs](https://sportmonks.com/docs/football/2.0/prediction-api/a/value-bet-by-fixture-id/215) + +```php +$response = SoccerApi::predictions()->getValueBetsByFixtureId($fixtureId) +``` + ### Rounds ##### Get By Id - [View Sportmonks Docs](https://sportmonks.com/docs/football/2.0/rounds/a/get-round-by-id/28) diff --git a/src/Endpoint/Prediction.php b/src/Endpoint/Prediction.php new file mode 100644 index 0000000..5aacf43 --- /dev/null +++ b/src/Endpoint/Prediction.php @@ -0,0 +1,66 @@ +call($url); + } + + /** + * @return stdClass + * @throws ApiRequestException + */ + public function getProbabilities() + { + $url = "predictions/probabilities/next"; + return $this->call($url); + } + + /** + * @param int $fixtureId + * @return stdClass + * @throws ApiRequestException + */ + public function getProbabilitiesByFixtureId(int $fixtureId) + { + $url = "predictions/probabilities/fixture/{$fixtureId}"; + return $this->call($url); + } + + /** + * @return stdClass + * @throws ApiRequestException + */ + public function getValueBets() + { + $url = "predictions/valuebets/next"; + return $this->call($url); + } + + /** + * @param int $fixtureId + * @return stdClass + * @throws ApiRequestException + */ + public function getValueBetsByFixtureId(int $fixtureId) + { + $url = "predictions/valuebets/fixture/{$fixtureId}"; + return $this->call($url); + } +} diff --git a/src/SoccerApi.php b/src/SoccerApi.php index 11abf94..1c15380 100644 --- a/src/SoccerApi.php +++ b/src/SoccerApi.php @@ -14,6 +14,7 @@ use Sportmonks\Soccer\Endpoint\Market; use Sportmonks\Soccer\Endpoint\Odd; use Sportmonks\Soccer\Endpoint\Player; +use Sportmonks\Soccer\Endpoint\Prediction; use Sportmonks\Soccer\Endpoint\Round; use Sportmonks\Soccer\Endpoint\Season; use Sportmonks\Soccer\Endpoint\Stage; @@ -127,6 +128,14 @@ public static function players() return new Player(); } + /** + * @return Prediction + */ + public static function predictions() + { + return new Prediction(); + } + /** * @return Round */