Skip to content

Commit

Permalink
Merge pull request #13 from hcgcloud/develop
Browse files Browse the repository at this point in the history
Remove requirement of illuminate/support & Ability to merge required variables for resource
  • Loading branch information
tyson239 committed Feb 28, 2020
2 parents 36b1659 + aad7c34 commit ebe387c
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 16 deletions.
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.*",
Expand Down
4 changes: 2 additions & 2 deletions src/MakesHttpRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 3 additions & 3 deletions src/Resources/Allocation.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Allocation extends Resource
/**
* The id of the allocation.
*
* @var integer
* @var int
*/
public $id;

Expand All @@ -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;
}
7 changes: 6 additions & 1 deletion src/Resources/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,13 @@ 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);
}
}
39 changes: 36 additions & 3 deletions src/Resources/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,27 @@ class Server extends Resource
*/
public $limits = [];

/**
* The feature limits of the server.
*
* @var array
*/
public $featureLimits = [];

/**
* The allocations of the server.
*
* @var array
*/
public $allocations = [];

/**
* The container of the server.
*
* @var array
*/
public $container = [];

/**
* Delete the given server.
*
Expand Down Expand Up @@ -147,8 +161,13 @@ 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);
}

Expand All @@ -157,8 +176,14 @@ 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);
}

Expand All @@ -167,8 +192,16 @@ 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);
}

Expand Down
17 changes: 12 additions & 5 deletions src/Resources/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -63,7 +63,7 @@ class User extends Resource
/**
* If a user is an admin.
*
* @var integer
* @var int
*/
public $rootAdmin;

Expand Down Expand Up @@ -103,8 +103,15 @@ 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);
}
}

0 comments on commit ebe387c

Please sign in to comment.