Skip to content

Commit

Permalink
feat: Update easy-curl to Version 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexsLaboratory committed Aug 6, 2021
1 parent 9585559 commit 5e2f8cd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 23 deletions.
31 changes: 16 additions & 15 deletions Workspaces.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,24 @@
namespace Lowem\GeoserverPHP;

use Lowem\EasyCurl\EasyCurl;
use Lowem\EasyCurl\HTTPRequestException;

class Workspaces extends Wrapper {
public function __construct($baseURL) { parent::__construct($baseURL); }

/**
* @throws HTTPRequestException
*/
public function getAll(): string {
$curl = new EasyCurl($this->getBaseURL() . "/workspaces");
$curl->setBasicAuth($this->getUsername(), $this->getPassword());
$curl->get();
if ($curl->getErrorCode()) {
return $curl->getErrorCode();
}
return $curl->getExecMessage();
}

/**
* @throws HTTPRequestException
*/
public function create($workspaceName): string {
$curl = new EasyCurl($this->getBaseURL() . "/workspaces");
$curl->setBasicAuth($this->getUsername(), $this->getPassword());
Expand All @@ -26,22 +30,22 @@ public function create($workspaceName): string {
</workspace>", [
"Content-Type: application/xml"
]);
if ($curl->getErrorCode()) {
return $curl->getErrorCode();
}
return $curl->getExecMessage();
}

/**
* @throws HTTPRequestException
*/
public function get($workspaceName): string {
$curl = new EasyCurl($this->getBaseURL() . "/workspaces/{$workspaceName}");
$curl->setBasicAuth($this->getUsername(), $this->getPassword());
$curl->get();
if ($curl->getErrorCode()) {
return $curl->getErrorCode();
}
return $curl->getExecMessage();
}

/**
* @throws HTTPRequestException
*/
public function update($currentWorkspaceName, $newWorkspaceName): string {
$curl = new EasyCurl($this->getBaseURL() . "/workspaces/{$currentWorkspaceName}");
$curl->setBasicAuth($this->getUsername(), $this->getPassword());
Expand All @@ -51,20 +55,17 @@ public function update($currentWorkspaceName, $newWorkspaceName): string {
</workspace>", [
"Content-Type: application/xml"
]);
if ($curl->getErrorCode()) {
return $curl->getErrorCode();
}
return $curl->getExecMessage();
}

/**
* @throws HTTPRequestException
*/
public function delete($workspaceName, $recurse = FALSE): string {
$recurseString = $recurse ? "true" : "false";
$curl = new EasyCurl($this->getBaseURL() . "/workspaces/{$workspaceName}?recurse={$recurseString}");
$curl->setBasicAuth($this->getUsername(), $this->getPassword());
$curl->delete();
if ($curl->getErrorCode()) {
return $curl->getErrorCode();
}
return $curl->getExecMessage();
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Wrapper for Geoserver API",
"type": "library",
"require": {
"lowem/easy-curl": "^2.0"
"lowem/easy-curl": "^3.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5"
Expand Down
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5e2f8cd

Please sign in to comment.