Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
TLingC committed Mar 7, 2020
2 parents ebe387c + ba5a266 commit ae0b585
Show file tree
Hide file tree
Showing 20 changed files with 227 additions and 261 deletions.
18 changes: 5 additions & 13 deletions src/Actions/ManagesAllocations.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,13 @@ trait ManagesAllocations
* Get the collection of allocations for a given node.
*
* @param int $nodeId
* @param int $page
*
* @return array
*/
public function allocations($nodeId, int $page = 1)
public function allocations(int $nodeId, int $page = 1)
{
$data = $this->get("api/application/nodes/$nodeId".'/allocations?page='.$page);
$transform = $this->transformCollection(
$data['data'],
Allocation::class
);

return [
'data' => $transform,
'meta' => $data['meta'],
];
return $this->get("api/application/nodes/$nodeId".'/allocations?page='.$page);
}

/**
Expand All @@ -35,7 +27,7 @@ public function allocations($nodeId, int $page = 1)
*
* @return void
*/
public function createAllocation($nodeId, array $data)
public function createAllocation(int $nodeId, array $data)
{
return $this->post("api/application/nodes/$nodeId/allocations", $data);
}
Expand All @@ -49,7 +41,7 @@ public function createAllocation($nodeId, array $data)
*
* @return void
*/
public function deleteAllocation($nodeId, $allocationId)
public function deleteAllocation(int $nodeId, int $allocationId)
{
return $this->delete("api/application/nodes/$nodeId/allocations/$allocationId");
}
Expand Down
16 changes: 7 additions & 9 deletions src/Actions/ManagesEggs.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,22 @@ trait ManagesEggs
*
* @return Egg[]
*/
public function eggs($nestId)
public function eggs(int $nestId)
{
return $this->transformCollection(
$this->get("api/application/nests/$nestId/eggs")['data'],
Egg::class
);
return $this->get("api/application/nests/$nestId/eggs");
}

/**
* Get a egg instance.
*
* @param int $nestId
* @param int $eggId
* @param int $nestId
* @param int $eggId
* @param array $includes
*
* @return Egg
*/
public function egg($nestId, $eggId)
public function egg(int $nestId, int $eggId, array $includes = [])
{
return new Egg($this->get("api/application/nests/$nestId/eggs/$eggId"), $this);
return $this->get("api/application/nests/$nestId/eggs/$eggId".$this->include($includes));
}
}
28 changes: 11 additions & 17 deletions src/Actions/ManagesLocations.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,26 @@ trait ManagesLocations
/**
* Get a collection of locations.
*
* @param int $page
*
* @return array
*/
public function locations(int $page = 1)
{
$data = $this->get('api/application/locations?page='.$page);
$transform = $this->transformCollection(
$data['data'],
Location::class
);

return [
'data' => $transform,
'meta' => $data['meta'],
];
return $this->get('api/application/locations?page='.$page);
}

/**
* Get a location instance.
*
* @param int $locationId
* @param int $locationId
* @param array $includes
*
* @return Location
*/
public function location($locationId)
public function location(int $locationId, array $includes = [])
{
return new Location($this->get("api/application/locations/$locationId"), $this);
return $this->get("api/application/locations/$locationId".$this->include($includes));
}

/**
Expand All @@ -46,7 +40,7 @@ public function location($locationId)
*/
public function createLocation(array $data)
{
return new Location($this->post('api/application/locations', $data), $this);
return $this->post('api/application/locations', $data);
}

/**
Expand All @@ -57,9 +51,9 @@ public function createLocation(array $data)
*
* @return Location
*/
public function updateLocation($locationId, array $data)
public function updateLocation(int $locationId, array $data)
{
return new Location($this->patch("api/application/locations/$locationId", $data), $this);
return $this->patch("api/application/locations/$locationId", $data);
}

/**
Expand All @@ -69,7 +63,7 @@ public function updateLocation($locationId, array $data)
*
* @return void
*/
public function deleteLocation($locationId)
public function deleteLocation(int $locationId)
{
return $this->delete("api/application/locations/$locationId");
}
Expand Down
20 changes: 7 additions & 13 deletions src/Actions/ManagesNests.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,25 @@ trait ManagesNests
/**
* Get a collection of nests.
*
* @param int $page
*
* @return array
*/
public function nests(int $page = 1)
{
$data = $this->get('api/application/nests?page='.$page);
$transform = $this->transformCollection(
$data['data'],
Nest::class
);

return [
'data' => $transform,
'meta' => $data['meta'],
];
return $this->get('api/application/nests?page='.$page);
}

/**
* Get a nest instance.
*
* @param int $nestId
* @param int $nestId
* @param array $includes
*
* @return Nest
*/
public function nest($nestId)
public function nest(int $nestId, array $includes = [])
{
return new Nest($this->get("api/application/nests/$nestId"), $this);
return $this->get("api/application/nests/$nestId".$this->include($includes));
}
}
28 changes: 11 additions & 17 deletions src/Actions/ManagesNodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,26 @@ trait ManagesNodes
/**
* Get a collection of nodes.
*
* @param int $page
*
* @return array
*/
public function nodes(int $page = 1)
{
$data = $this->get('api/application/nodes?page='.$page);
$transform = $this->transformCollection(
$data['data'],
Node::class
);

return [
'data' => $transform,
'meta' => $data['meta'],
];
return $this->get('api/application/nodes?page='.$page);
}

/**
* Get a node instance.
*
* @param int $nodeId
* @param int $nodeId
* @param array $includes
*
* @return Node
*/
public function node($nodeId)
public function node(int $nodeId, array $includes = [])
{
return new Node($this->get("api/application/nodes/$nodeId"), $this);
return $this->get("api/application/nodes/$nodeId".$this->include($includes));
}

/**
Expand All @@ -46,7 +40,7 @@ public function node($nodeId)
*/
public function createNode(array $data)
{
return new Node($this->post('api/application/nodes', $data), $this);
return $this->post('api/application/nodes', $data);
}

/**
Expand All @@ -57,9 +51,9 @@ public function createNode(array $data)
*
* @return Node
*/
public function updateNode($nodeId, array $data)
public function updateNode(int $nodeId, array $data)
{
return new Node($this->patch("api/application/nodes/$nodeId", $data), $this);
return $this->patch("api/application/nodes/$nodeId", $data);
}

/**
Expand All @@ -69,7 +63,7 @@ public function updateNode($nodeId, array $data)
*
* @return void
*/
public function deleteNode($nodeId)
public function deleteNode(int $nodeId)
{
return $this->delete("api/application/nodes/$nodeId");
}
Expand Down
Loading

0 comments on commit ae0b585

Please sign in to comment.