-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathWebhookAdminApi.php
41 lines (34 loc) · 1.18 KB
/
WebhookAdminApi.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
namespace BigCommerce\ApiV3\Api\Webhooks;
use BigCommerce\ApiV3\Api\Generic\GetResource;
use BigCommerce\ApiV3\Api\Generic\V3ApiBase;
use BigCommerce\ApiV3\ResponseModels\Webhook\AdminInfoResponse;
use GuzzleHttp\RequestOptions;
class WebhookAdminApi extends V3ApiBase
{
use GetResource;
public const WEBHOOK_ADMIN_ENDPOINT = 'hooks/admin';
public function singleResourceUrl(): string
{
return self::WEBHOOK_ADMIN_ENDPOINT;
}
public function get(?bool $isActive = null): AdminInfoResponse
{
$filter = is_null($isActive) ? [] : ['is_active' => $isActive];
return new AdminInfoResponse($this->getResource($filter));
}
/**
* Update email addresses that are sent notification emails when any domain associated with the API account
* is denylisted or when a webhook is deactivated. Supports upsert functionality in the case that no email
* address exists yet.
*/
public function upsertEmails(array $emails): void
{
$this->getClient()->getRestClient()->put(
$this->singleResourceUrl(),
[
RequestOptions::JSON => ['emails' => $emails]
]
);
}
}