Skip to content

Commit

Permalink
Merge pull request #8 from joesaunderson/feature/predictions
Browse files Browse the repository at this point in the history
Add Prediction API #7
  • Loading branch information
joesaunderson authored Oct 1, 2019
2 parents f169c75 + a773319 commit 99330ee
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 0 deletions.
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
66 changes: 66 additions & 0 deletions src/Endpoint/Prediction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

namespace Sportmonks\Soccer\Endpoint;

use Sportmonks\Soccer\Exception\ApiRequestException;
use Sportmonks\Soccer\SoccerClient;
use stdClass;

/**
* Class Prediction
* @package Sportmonks\Soccer\Endpoint
*/
class Prediction extends SoccerClient
{
/**
* @return stdClass
* @throws ApiRequestException
*/
public function getLeagues()
{
$url = "predictions/leagues";
return $this->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);
}
}
9 changes: 9 additions & 0 deletions src/SoccerApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -127,6 +128,14 @@ public static function players()
return new Player();
}

/**
* @return Prediction
*/
public static function predictions()
{
return new Prediction();
}

/**
* @return Round
*/
Expand Down

0 comments on commit 99330ee

Please sign in to comment.