Skip to content

Commit

Permalink
Merge pull request #59 from fodderstompf/add-webserver-template-resource
Browse files Browse the repository at this point in the history
Add webserver template resource
  • Loading branch information
Cannonb4ll authored Mar 15, 2022
2 parents 58e8945 + 0746d67 commit 4d25a6f
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -688,3 +688,17 @@ $ploi->statusPage(123)->incident()->perPage($amountPerPage)->page($pageNumber);
// Delete incident
$ploi->statusPage(123)->incident(123)->delete();
```

### Webserver Templates

Available methods for webserver templates:
```php
// List webserver templates
$ploi->webserverTemplates()->get();

// Paginate webserver templates
$ploi->webserverTemplates()->perPage($amountPerPage)->page($pageNumber);

// Get webserver template
$ploi->webserverTemplates(123)->get();
```
6 changes: 6 additions & 0 deletions src/Ploi/Ploi.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Ploi\Exceptions\Http\NotFound;
use Ploi\Exceptions\Http\NotValid;
use Ploi\Exceptions\Http\NotAllowed;
use Ploi\Resources\WebserverTemplate;
use Psr\Http\Message\ResponseInterface;
use Ploi\Exceptions\Http\TooManyAttempts;
use Ploi\Exceptions\Http\Unauthenticated;
Expand Down Expand Up @@ -169,4 +170,9 @@ public function user()
{
return new User($this);
}

public function webserverTemplates(?int $id = null): WebserverTemplate
{
return new WebserverTemplate($this, $id);
}
}
34 changes: 34 additions & 0 deletions src/Ploi/Resources/WebserverTemplate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace Ploi\Resources;

use Ploi\Http\Response;
use Ploi\Ploi;
use Ploi\Traits\HasPagination;

class WebserverTemplate extends Resource
{
use HasPagination;

private $endpoint = 'webserver-templates';

public function __construct(Ploi $ploi = null, ?int $id = null)
{
parent::__construct($ploi, $id);

$this->setEndpoint($this->endpoint);
}

public function get(?int $id = null): Response
{
if ($id) {
$this->setId($id);
}

if ($this->getId()) {
$this->setEndpoint($this->getEndpoint() . '/' . $this->getId());
}

return $this->getPloi()->makeAPICall($this->getEndpoint());
}
}

0 comments on commit 4d25a6f

Please sign in to comment.