-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
287 additions
and
1 deletion.
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
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
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 |
---|---|---|
@@ -0,0 +1,150 @@ | ||
<?php | ||
|
||
namespace Rebilly\Entities; | ||
|
||
use Rebilly\Rest\Entity; | ||
|
||
/** | ||
* Class WebsiteWebhook | ||
* | ||
* ```json | ||
* { | ||
* "id" | ||
* "eventsFilter" | ||
* "status" | ||
* "method" | ||
* "url" | ||
* "headers" | ||
* "credentialHash" | ||
* "createdTime" | ||
* "updatedTime" | ||
* "_links" | ||
* } | ||
* ``` | ||
*/ | ||
final class Webhook extends Entity | ||
{ | ||
/** | ||
* @return array | ||
*/ | ||
public function getEventsFilter() | ||
{ | ||
return $this->getAttribute('eventsFilter'); | ||
} | ||
|
||
/** | ||
* @param array $value | ||
* | ||
* @return $this | ||
*/ | ||
public function setEventsFilter($value) | ||
{ | ||
return $this->setAttribute('eventsFilter', $value); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getStatus() | ||
{ | ||
return $this->getAttribute('status'); | ||
} | ||
|
||
/** | ||
* @param string $value | ||
* | ||
* @return string | ||
*/ | ||
public function setStatus($value) | ||
{ | ||
return $this->setAttribute('status', $value); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getMethod() | ||
{ | ||
return $this->getAttribute('method'); | ||
} | ||
|
||
/** | ||
* @param string $value | ||
* | ||
* @return $this | ||
*/ | ||
public function setMethod($value) | ||
{ | ||
return $this->setAttribute('method', $value); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getUrl() | ||
{ | ||
return $this->getAttribute('url'); | ||
} | ||
|
||
/** | ||
* @param string $value | ||
* | ||
* @return $this | ||
*/ | ||
public function setUrl($value) | ||
{ | ||
return $this->setAttribute('url', $value); | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getHeaders() | ||
{ | ||
return $this->getAttribute('headers'); | ||
} | ||
|
||
/** | ||
* @param array $value | ||
* | ||
* @return $this | ||
*/ | ||
public function setHeaders($value) | ||
{ | ||
return $this->setAttribute('headers', $value); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getCredentialHash() | ||
{ | ||
return $this->getAttribute('credentialHash'); | ||
} | ||
|
||
/** | ||
* @param string $value | ||
* | ||
* @return $this | ||
*/ | ||
public function setCredentialHash($value) | ||
{ | ||
return $this->setAttribute('credentialHash', $value); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getCreatedTime() | ||
{ | ||
return $this->getAttribute('createdTime'); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getSelfLink() | ||
{ | ||
return $this->getLink('self'); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<?php | ||
/** | ||
* This file is part of the PHP Rebilly API package. | ||
* | ||
* (c) 2015 Rebilly SRL | ||
* | ||
* For the full copyright and license information, please view the LICENSE.md | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Rebilly\Services; | ||
|
||
use ArrayObject; | ||
use JsonSerializable; | ||
use Rebilly\Http\Exception\NotFoundException; | ||
use Rebilly\Http\Exception\UnprocessableEntityException; | ||
use Rebilly\Paginator; | ||
use Rebilly\Rest\Collection; | ||
use Rebilly\Rest\Service; | ||
|
||
/** | ||
* Class WebhooksService | ||
*/ | ||
final class WebhooksService extends Service | ||
{ | ||
/** | ||
* @param array|ArrayObject $params | ||
* | ||
* @return Webkook[][]|Collection[]|Paginator | ||
*/ | ||
public function paginator($params = []) | ||
{ | ||
return new Paginator($this->client(), 'webhooks', $params); | ||
} | ||
|
||
/** | ||
* @param array|ArrayObject $params | ||
* | ||
* @return Webkook[]|Collection | ||
*/ | ||
public function search($params = []) | ||
{ | ||
return $this->client()->get('webhooks', $params); | ||
} | ||
|
||
/** | ||
* @param string $webhookId | ||
* | ||
* @throws NotFoundException The resource data does exist | ||
* | ||
* @return Webkook | ||
*/ | ||
public function load($webhookId) | ||
{ | ||
return $this->client()->get('webhooks/{webhookId}', ['webhookId' => $webhookId]); | ||
} | ||
|
||
/** | ||
* @param array|JsonSerializable|Webkook $data | ||
* @param null $webhookId | ||
* | ||
* @return Webkook | ||
*/ | ||
public function create($data, $webhookId = null) | ||
{ | ||
if (isset($webhookId)) { | ||
return $this->client()->put($data, 'webhooks/{webhookId}', ['webhookId' => $webhookId]); | ||
} | ||
|
||
return $this->client()->post($data, 'webhooks'); | ||
} | ||
|
||
/** | ||
* @param string $webhookId | ||
* @param array|JsonSerializable|Webkook $data | ||
* | ||
* @throws UnprocessableEntityException The input data does not valid | ||
* | ||
* @return Webkook | ||
*/ | ||
public function update($webhookId, $data) | ||
{ | ||
return $this->client()->put($data, 'webhooks/{webhookId}', ['webhookId' => $webhookId]); | ||
} | ||
|
||
/** | ||
* @param $data | ||
* | ||
* @return mixed | ||
*/ | ||
public function preview($data) | ||
{ | ||
return $this->client()->post($data, 'previews/webhooks'); | ||
} | ||
} |
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