-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(organization-webhooks): Added Organization webhook model and end…
…points (#161)
- Loading branch information
Showing
5 changed files
with
594 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?php | ||
|
||
namespace CrowdinApiClient\Api; | ||
|
||
use CrowdinApiClient\Model\OrganizationWebhook; | ||
use CrowdinApiClient\ModelCollection; | ||
|
||
/** | ||
* Webhooks allow you to collect information about events that happen in your Crowdin Enterprise organization. | ||
* You can select the request type, content type, and add a custom payload, which allows you to create integrations with other systems on your own. | ||
* | ||
* @package Crowdin\Api | ||
*/ | ||
class OrganizationWebhookApi extends AbstractApi | ||
{ | ||
/** | ||
* List Organization Webhooks | ||
* @link https://developer.crowdin.com/api/v2/#operation/api.webhooks.getMany API Documentation | ||
* @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.webhooks.getMany API Documentation Enterprise | ||
* | ||
* @param array $params | ||
* @return ModelCollection | ||
*/ | ||
public function list(array $params = []): ModelCollection | ||
{ | ||
return $this->_list('webhooks', OrganizationWebhook::class, $params); | ||
} | ||
|
||
/** | ||
* Get Organization Webhook | ||
* @link https://developer.crowdin.com/api/v2/#operation/api.webhooks.get API Documentation | ||
* @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.webhooks.get API Documentation Enterprise | ||
* | ||
* @param int $organizationWebhookId | ||
* @return OrganizationWebhook | ||
*/ | ||
public function get(int $organizationWebhookId): OrganizationWebhook | ||
{ | ||
return $this->_get(sprintf('webhooks/%d', $organizationWebhookId), OrganizationWebhook::class); | ||
} | ||
|
||
/** | ||
* Add Organization Webhook | ||
* @link https://developer.crowdin.com/api/v2/#operation/api.webhooks.post API Documentation | ||
* @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.webhooks.post API Documentation Enterprise | ||
* | ||
* @param array $data | ||
* string $data[name] required<br> | ||
* string $data[url] required<br> | ||
* string[] $data[events] required Enum: "project.created" "project.deleted" Enterprise onyl enum: "project.created" "project.deleted" "group.created" "group.deleted"<br> | ||
* string $data[requestType] required Enum: "POST" "GET"<br> | ||
* boolean $data[isActive]<br> | ||
* boolean $data[batchingEnabled]<br> | ||
* string $data[contentType] Default: "application/json" Enum: "multipart/form-data" "application/json" "application/x-www-form-urlencoded"<br> | ||
* array $data[headers]<br> | ||
* array $data[payload] | ||
* | ||
* @return OrganizationWebhook|null | ||
*/ | ||
public function create(array $data): ?OrganizationWebhook | ||
{ | ||
return $this->_create('webhooks', OrganizationWebhook::class, $data); | ||
} | ||
|
||
/** | ||
* Update Organization Webhook | ||
* @link https://developer.crowdin.com/api/v2/#operation/api.webhooks.patch API Documentation | ||
* @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.webhooks.patch API Documentation Enterprise | ||
* | ||
* @param OrganizationWebhook $organizationWebhook | ||
* @return OrganizationWebhook|null | ||
*/ | ||
public function update(OrganizationWebhook $organizationWebhook): ?OrganizationWebhook | ||
{ | ||
return $this->_update(sprintf('webhooks/%d', $organizationWebhook->getId()), $organizationWebhook); | ||
} | ||
|
||
/** | ||
* Delete Organization Webhook | ||
* @link https://developer.crowdin.com/api/v2/#operation/api.webhooks.delete API Documentation | ||
* @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.webhooks.delete API Documentation Enterprise | ||
* | ||
* @param int $organizationWebhookId | ||
* @return mixed | ||
*/ | ||
public function delete(int $organizationWebhookId) | ||
{ | ||
return $this->_delete(sprintf('webhooks/%d', $organizationWebhookId)); | ||
} | ||
} |
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,244 @@ | ||
<?php | ||
|
||
namespace CrowdinApiClient\Model; | ||
|
||
/** | ||
* @package Crowdin\Model | ||
*/ | ||
class OrganizationWebhook extends BaseModel | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $id; | ||
/** | ||
* @var string | ||
*/ | ||
protected $name; | ||
/** | ||
* @var string | ||
*/ | ||
protected $url; | ||
/** | ||
* @var array | ||
*/ | ||
protected $events; | ||
/** | ||
* @var array | ||
*/ | ||
protected $headers; | ||
/** | ||
* @var array | ||
*/ | ||
protected $payload; | ||
/** | ||
* @var bool | ||
*/ | ||
protected $isActive; | ||
/** | ||
* @var bool | ||
*/ | ||
protected $batchingEnabled; | ||
/** | ||
* @var string | ||
*/ | ||
protected $requestType; | ||
/** | ||
* @var string | ||
*/ | ||
protected $contentType; | ||
/** | ||
* @var string | ||
*/ | ||
protected $createdAt; | ||
/** | ||
* @var string | ||
*/ | ||
protected $updatedAt; | ||
|
||
public function __construct(array $data = []) | ||
{ | ||
parent::__construct($data); | ||
$this->id = (string)$this->getDataProperty('id'); | ||
$this->name = (string)$this->getDataProperty('name'); | ||
$this->url = (string)$this->getDataProperty('url'); | ||
$this->events = (array)$this->getDataProperty('events'); | ||
$this->headers = (array)$this->getDataProperty('headers'); | ||
$this->payload = (array)$this->getDataProperty('payload'); | ||
$this->isActive = (bool)$this->getDataProperty('isActive'); | ||
$this->batchingEnabled = (bool)$this->getDataProperty('batchingEnabled'); | ||
$this->requestType = (string)$this->getDataProperty('requestType'); | ||
$this->contentType = (string)$this->getDataProperty('contentType'); | ||
$this->createdAt = (string)$this->getDataProperty('createdAt'); | ||
$this->updatedAt = (string)$this->getDataProperty('updatedAt'); | ||
|
||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getId(): string | ||
{ | ||
return $this->id; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getName(): string | ||
{ | ||
return $this->name; | ||
} | ||
|
||
/** | ||
* @param string $name | ||
*/ | ||
public function setName(string $name): void | ||
{ | ||
$this->name = $name; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getUrl(): string | ||
{ | ||
return $this->url; | ||
} | ||
|
||
/** | ||
* @param string $url | ||
*/ | ||
public function setUrl(string $url): void | ||
{ | ||
$this->url = $url; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getEvents(): array | ||
{ | ||
return $this->events; | ||
} | ||
|
||
/** | ||
* @param array $events | ||
*/ | ||
public function setEvents(array $events): void | ||
{ | ||
$this->events = $events; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getHeaders(): array | ||
{ | ||
return $this->headers; | ||
} | ||
|
||
/** | ||
* @param array $headers | ||
*/ | ||
public function setHeaders(array $headers): void | ||
{ | ||
$this->headers = $headers; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getPayload(): array | ||
{ | ||
return $this->payload; | ||
} | ||
|
||
/** | ||
* @param array $payload | ||
*/ | ||
public function setPayload(array $payload): void | ||
{ | ||
$this->payload = $payload; | ||
} | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
public function isActive(): bool | ||
{ | ||
return $this->isActive; | ||
} | ||
|
||
/** | ||
* @param bool $isActive | ||
*/ | ||
public function setIsActive(bool $isActive): void | ||
{ | ||
$this->isActive = $isActive; | ||
} | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
public function isBatchingEnabled(): bool | ||
{ | ||
return $this->batchingEnabled; | ||
} | ||
|
||
/** | ||
* @param bool $batchingEnabled | ||
*/ | ||
public function setBatchingEnabled(bool $batchingEnabled): void | ||
{ | ||
$this->batchingEnabled = $batchingEnabled; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getRequestType(): string | ||
{ | ||
return $this->requestType; | ||
} | ||
|
||
/** | ||
* @param string $requestType | ||
*/ | ||
public function setRequestType(string $requestType): void | ||
{ | ||
$this->requestType = $requestType; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getContentType(): string | ||
{ | ||
return $this->contentType; | ||
} | ||
|
||
/** | ||
* @param string $contentType | ||
*/ | ||
public function setContentType(string $contentType): void | ||
{ | ||
$this->contentType = $contentType; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getCreatedAt(): string | ||
{ | ||
return $this->createdAt; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getUpdatedAt(): string | ||
{ | ||
return $this->updatedAt; | ||
} | ||
} |
Oops, something went wrong.