From 612c208dc58afbd11accf4646156ea437c69685d Mon Sep 17 00:00:00 2001 From: TLingC Date: Fri, 28 Feb 2020 16:25:01 +0800 Subject: [PATCH 1/3] Remove requirement of illuminate/support --- composer.json | 3 +-- src/MakesHttpRequests.php | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 5d26927..c9a450e 100644 --- a/composer.json +++ b/composer.json @@ -15,8 +15,7 @@ ], "require": { "php": ">=5.6.4", - "guzzlehttp/guzzle": "~6.0", - "illuminate/support": "5.7.*" + "guzzlehttp/guzzle": "~6.0" }, "require-dev": { "mockery/mockery": "0.9.*", diff --git a/src/MakesHttpRequests.php b/src/MakesHttpRequests.php index 67ba8f0..3f5a090 100644 --- a/src/MakesHttpRequests.php +++ b/src/MakesHttpRequests.php @@ -92,8 +92,8 @@ private function request($verb, $uri, array $payload = []) $token = $this->apiKey; $options['body'] = $body; - $options = array_add($options, 'debug', false); - $options['headers'] = array_add($options, 'Authorization', 'Bearer '.$token); + $options['debug'] = false; + $options['headers']['Authorization'] = 'Bearer '.$token; $response = $this->guzzle->request($verb, $uri, $options); From dc2b08c12d088c571830df5815a415d10d0083d4 Mon Sep 17 00:00:00 2001 From: TLingC Date: Fri, 28 Feb 2020 17:11:06 +0800 Subject: [PATCH 2/3] Ability to merge required variables for resource --- src/Resources/Location.php | 6 +++++- src/Resources/Server.php | 36 +++++++++++++++++++++++++++++++++--- src/Resources/User.php | 8 +++++++- 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/src/Resources/Location.php b/src/Resources/Location.php index 7096b33..d868709 100644 --- a/src/Resources/Location.php +++ b/src/Resources/Location.php @@ -61,8 +61,12 @@ public function delete() * * @return void */ - public function update(array $data) + public function update(array $data = []) { + $data = array_merge([ + 'short' => $this->short, + 'long' => $this->long + ], $data); return $this->pterodactyl->updateLocation($this->id, $data); } } diff --git a/src/Resources/Server.php b/src/Resources/Server.php index 97cd838..9007229 100644 --- a/src/Resources/Server.php +++ b/src/Resources/Server.php @@ -94,6 +94,13 @@ class Server extends Resource * @var array */ public $limits = []; + + /** + * The feature limits of the server. + * + * @var array + */ + public $featureLimits = []; /** * The allocations of the server. @@ -101,6 +108,13 @@ class Server extends Resource * @var array */ public $allocations = []; + + /** + * The container of the server. + * + * @var array + */ + public $container = []; /** * Delete the given server. @@ -147,8 +161,12 @@ public function unsuspend() * * @return void */ - public function updateDetails(array $data) + public function updateDetails(array $data = []) { + $data = array_merge([ + 'name' => $this->name, + 'user' => $this->user + ], $data); return $this->pterodactyl->updateServerDetails($this->id, $data); } @@ -157,8 +175,13 @@ public function updateDetails(array $data) * * @return void */ - public function updateBuild(array $data) + public function updateBuild(array $data = []) { + $data = array_merge([ + 'allocation' => $this->allocation, + 'limits' => $this->limits, + 'feature_limits' => $this->featureLimits + ], $data); return $this->pterodactyl->updateServerBuild($this->id, $data); } @@ -167,8 +190,15 @@ public function updateBuild(array $data) * * @return void */ - public function updateStartup(array $data) + public function updateStartup(array $data = []) { + $data = array_merge([ + 'startup' => $this->container['startup_command'], + 'egg' => $this->egg, + 'image' => $this->container['image'], + 'environment' => $this->container['environment'], + 'skip_scripts' => 0 + ], $data); return $this->pterodactyl->updateServerStartup($this->id, $data); } diff --git a/src/Resources/User.php b/src/Resources/User.php index c64616d..e8824b5 100644 --- a/src/Resources/User.php +++ b/src/Resources/User.php @@ -103,8 +103,14 @@ public function delete() * * @return void */ - public function update(array $data) + public function update(array $data = []) { + $data = array_merge([ + 'username' => $this->username, + 'email' => $this->email, + 'first_name' => $this->firstName, + 'last_name' => $this->lastName + ], $data); return $this->pterodactyl->updateUser($this->id, $data); } } From aad7c347ba32a8982ad192d3fa7bbba5bd5d4dab Mon Sep 17 00:00:00 2001 From: TLingC Date: Fri, 28 Feb 2020 09:12:40 +0000 Subject: [PATCH 3/3] Apply fixes from StyleCI --- src/Resources/Allocation.php | 6 +++--- src/Resources/Location.php | 3 ++- src/Resources/Server.php | 25 ++++++++++++++----------- src/Resources/User.php | 15 ++++++++------- 4 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/Resources/Allocation.php b/src/Resources/Allocation.php index 8ba83eb..dfe11b2 100644 --- a/src/Resources/Allocation.php +++ b/src/Resources/Allocation.php @@ -7,7 +7,7 @@ class Allocation extends Resource /** * The id of the allocation. * - * @var integer + * @var int */ public $id; @@ -28,14 +28,14 @@ class Allocation extends Resource /** * The port of the allocation. * - * @var integer + * @var int */ public $port; /** * The assign status of the allocation. * - * @var boolean + * @var bool */ public $assigned; } diff --git a/src/Resources/Location.php b/src/Resources/Location.php index d868709..a1d2b7c 100644 --- a/src/Resources/Location.php +++ b/src/Resources/Location.php @@ -65,8 +65,9 @@ public function update(array $data = []) { $data = array_merge([ 'short' => $this->short, - 'long' => $this->long + 'long' => $this->long, ], $data); + return $this->pterodactyl->updateLocation($this->id, $data); } } diff --git a/src/Resources/Server.php b/src/Resources/Server.php index 9007229..f8a675a 100644 --- a/src/Resources/Server.php +++ b/src/Resources/Server.php @@ -94,7 +94,7 @@ class Server extends Resource * @var array */ public $limits = []; - + /** * The feature limits of the server. * @@ -108,7 +108,7 @@ class Server extends Resource * @var array */ public $allocations = []; - + /** * The container of the server. * @@ -165,8 +165,9 @@ public function updateDetails(array $data = []) { $data = array_merge([ 'name' => $this->name, - 'user' => $this->user + 'user' => $this->user, ], $data); + return $this->pterodactyl->updateServerDetails($this->id, $data); } @@ -178,10 +179,11 @@ public function updateDetails(array $data = []) public function updateBuild(array $data = []) { $data = array_merge([ - 'allocation' => $this->allocation, - 'limits' => $this->limits, - 'feature_limits' => $this->featureLimits + 'allocation' => $this->allocation, + 'limits' => $this->limits, + 'feature_limits' => $this->featureLimits, ], $data); + return $this->pterodactyl->updateServerBuild($this->id, $data); } @@ -193,12 +195,13 @@ public function updateBuild(array $data = []) public function updateStartup(array $data = []) { $data = array_merge([ - 'startup' => $this->container['startup_command'], - 'egg' => $this->egg, - 'image' => $this->container['image'], - 'environment' => $this->container['environment'], - 'skip_scripts' => 0 + 'startup' => $this->container['startup_command'], + 'egg' => $this->egg, + 'image' => $this->container['image'], + 'environment' => $this->container['environment'], + 'skip_scripts' => 0, ], $data); + return $this->pterodactyl->updateServerStartup($this->id, $data); } diff --git a/src/Resources/User.php b/src/Resources/User.php index e8824b5..3c4b13a 100644 --- a/src/Resources/User.php +++ b/src/Resources/User.php @@ -7,21 +7,21 @@ class User extends Resource /** * The id of the user. * - * @var integer + * @var int */ public $id; /** * The external id of the user. * - * @var integer + * @var int */ public $externalId; /** * The uuid of the user. * - * @var integer + * @var int */ public $uuid; @@ -63,7 +63,7 @@ class User extends Resource /** * If a user is an admin. * - * @var integer + * @var int */ public $rootAdmin; @@ -106,11 +106,12 @@ public function delete() public function update(array $data = []) { $data = array_merge([ - 'username' => $this->username, - 'email' => $this->email, + 'username' => $this->username, + 'email' => $this->email, 'first_name' => $this->firstName, - 'last_name' => $this->lastName + 'last_name' => $this->lastName, ], $data); + return $this->pterodactyl->updateUser($this->id, $data); } }