Skip to content

Commit

Permalink
Add support for player upcoming chests (#14)
Browse files Browse the repository at this point in the history
* Updated README for new function and updated sample code for Player functions

* Added new function to get the upcoming chests for a Player

* Added punctuation to descriptions

* Removed superfluous newline
  • Loading branch information
chicohernando authored May 5, 2020
1 parent e07e019 commit 646c008
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ List [with all current war parameters](https://developer.clashroyale.com/api-doc

``` php
<?php
use Edbizarro\ClashRoyale\Clan;
use Edbizarro\ClashRoyale\Player;

$player = new Player('player_tag');
$player->get();
Expand All @@ -105,13 +105,24 @@ $player->get();

``` php
<?php
use Edbizarro\ClashRoyale\Clan;
use Edbizarro\ClashRoyale\Player;

$player = new Player('player_tag');
$player->battles();

```

### Upcoming Chests

``` php
<?php
use Edbizarro\ClashRoyale\Player;

$player = new Player('player_tag');
$player->upcomingChests();

```

## Changelog

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
Expand Down
22 changes: 22 additions & 0 deletions src/Player.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class Player extends Resource
protected $resourceName = 'players';

/**
* Returns a list of battles that the Player has recently participated in.
*
* @param array $options
*
* @return Collection
Expand All @@ -26,4 +28,24 @@ public function battles(array $options = []): Collection
)
);
}

/**
* Returns the chests that are upcoming for the Player.
*
* @param array $options
*
* @return Collection
* @throws Exception
*
* @see https://developer.clashroyale.com/api-docs/index.html#!/players/getPlayerUpcomingChests
*/
public function upcomingChests(array $options = []): Collection
{
return $this->response(
$this->api->makeRequest(
$this->getResourceFinalUrl().'/upcomingchests',
$options
)
);
}
}

0 comments on commit 646c008

Please sign in to comment.