-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from nstack-io/develop
Develop -> Master
- Loading branch information
Showing
20 changed files
with
163 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,14 +2,11 @@ | |
|
||
namespace NStack\Clients; | ||
|
||
use NStack\Exceptions\FailedToParseException; | ||
use NStack\Models\IpAddress; | ||
|
||
/** | ||
* Class CollectionsClient | ||
* | ||
* @package NStack\Clients | ||
* @author Tiago Araujo <[email protected]> | ||
* @author Tiago Araujo <[email protected]> | ||
*/ | ||
class CollectionsClient extends NStackClient | ||
{ | ||
|
@@ -26,22 +23,24 @@ public function view(int $collectionId): array | |
{ | ||
$response = $this->client->get($this->buildPath($this->path . '/' . $collectionId)); | ||
$contents = $response->getBody()->getContents(); | ||
|
||
return json_decode($contents, true)['data']; | ||
} | ||
|
||
/** | ||
* createItem | ||
* | ||
* @param int $collectionId | ||
* @param int $collectionId | ||
* @param array $params | ||
* @return array | ||
*/ | ||
public function createItem(int $collectionId, array $params): array | ||
{ | ||
$response = $this->client->post($this->buildPath($this->path . '/' . $collectionId . '/items'), [ | ||
'form_params' => $params | ||
'form_params' => $params, | ||
]); | ||
$contents = $response->getBody()->getContents(); | ||
|
||
return json_decode($contents, true)['data']; | ||
} | ||
|
||
|
@@ -59,17 +58,19 @@ public function deleteItem(int $collectionId, int $itemId) | |
/** | ||
* updateItem | ||
* | ||
* @param int $collectionId | ||
* @param int $itemId | ||
* @param int $collectionId | ||
* @param int $itemId | ||
* @param array $params | ||
* @return array | ||
*/ | ||
public function updateItem(int $collectionId, int $itemId, array $params): array | ||
{ | ||
$response = $this->client->post($this->buildPath($this->path . '/' . $collectionId . '/items/' . $itemId . '/update'), [ | ||
'form_params' => $params | ||
$response = $this->client->post($this->buildPath($this->path . '/' . $collectionId . '/items/' . $itemId . | ||
'/update'), [ | ||
'form_params' => $params, | ||
]); | ||
$contents = $response->getBody()->getContents(); | ||
|
||
return json_decode($contents, true)['data']; | ||
} | ||
|
||
|
@@ -84,6 +85,7 @@ public function viewItem(int $collectionId, int $itemId): array | |
{ | ||
$response = $this->client->get($this->buildPath($this->path . '/' . $collectionId . '/items/' . $itemId)); | ||
$contents = $response->getBody()->getContents(); | ||
|
||
return json_decode($contents, true)['data']; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
* Class IpAddressesClient | ||
* | ||
* @package NStack\Clients | ||
* @author Tiago Araujo <[email protected]> | ||
* @author Tiago Araujo <[email protected]> | ||
*/ | ||
class IpAddressesClient extends NStackClient | ||
{ | ||
|
@@ -28,13 +28,14 @@ public function index(): IpAddress | |
$response = $this->client->get($this->buildPath($this->path)); | ||
$contents = $response->getBody()->getContents(); | ||
$data = json_decode($contents, true); | ||
|
||
return new IpAddress($data['data']); | ||
} | ||
|
||
/** | ||
* show | ||
* | ||
* @param String $ip | ||
* @param String $ip | ||
* @return IpAddress | ||
* @throws FailedToParseException | ||
* @author Tiago Araujo <[email protected]> | ||
|
@@ -44,6 +45,7 @@ public function show(String $ip): IpAddress | |
$response = $this->client->get($this->buildPath($this->path . '?ip=' . $ip)); | ||
$contents = $response->getBody()->getContents(); | ||
$data = json_decode($contents, true); | ||
|
||
return new IpAddress($data['data']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
|
||
namespace NStack\Clients; | ||
|
||
use NStack\Models\Country; | ||
use NStack\Models\Resource; | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
* Class NotifyClient | ||
* | ||
* @package NStack\Clients | ||
* @author Tiago Araujo <[email protected]> | ||
* @author Tiago Araujo <[email protected]> | ||
*/ | ||
class NotifyClient extends NStackClient | ||
{ | ||
|
@@ -20,7 +20,7 @@ class NotifyClient extends NStackClient | |
/** | ||
* versionControlIndex | ||
* | ||
* @param String $platform | ||
* @param String $platform | ||
* @param String|null $currentVersion | ||
* @param String|null $lastVersion | ||
* @param String|null $test | ||
|
@@ -33,8 +33,7 @@ public function versionControlIndex( | |
String $currentVersion = null, | ||
String $lastVersion = null, | ||
String $test = null | ||
): VersionControlUpdate | ||
{ | ||
): VersionControlUpdate { | ||
$path = $this->buildPath($this->path) . "?platform=" . $platform; | ||
if ($currentVersion) { | ||
$path = $path . '¤t_version=' . $currentVersion; | ||
|
@@ -49,14 +48,15 @@ public function versionControlIndex( | |
$response = $this->client->get($path); | ||
$contents = $response->getBody()->getContents(); | ||
$data = json_decode($contents, true); | ||
|
||
return new VersionControlUpdate($data); | ||
} | ||
|
||
/** | ||
* markUpdateAsSeen | ||
* | ||
* @param String $guid | ||
* @param int $updateId | ||
* @param int $updateId | ||
* @param String $answer | ||
* @param String $type | ||
* @return SeenUpdate | ||
|
@@ -70,11 +70,11 @@ public function markUpdateAsSeen(String $guid, int $updateId, String $answer, St | |
'update_id' => $updateId, | ||
'answer' => $answer, | ||
'type' => $type, | ||
] | ||
], | ||
]); | ||
$contents = $response->getBody()->getContents(); | ||
$data = json_decode($contents, true); | ||
|
||
return new SeenUpdate($data['data']); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.