From 646c00858b9d580a64e9501f204a9853400cc868 Mon Sep 17 00:00:00 2001 From: Eric Sanders Date: Tue, 5 May 2020 06:00:00 -0500 Subject: [PATCH] Add support for player upcoming chests (#14) * 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 --- README.md | 15 +++++++++++++-- src/Player.php | 22 ++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e2ef279..57d7533 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,7 @@ List [with all current war parameters](https://developer.clashroyale.com/api-doc ``` php get(); @@ -105,13 +105,24 @@ $player->get(); ``` php battles(); ``` +### Upcoming Chests + +``` php +upcomingChests(); + +``` + ## Changelog Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. diff --git a/src/Player.php b/src/Player.php index 6f66a69..ce0f17b 100644 --- a/src/Player.php +++ b/src/Player.php @@ -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 @@ -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 + ) + ); + } }