mirror of
https://github.com/retailcrm/mailgun-php.git
synced 2024-11-29 08:26:06 +03:00
feat: add array support to webhook handling
Change webhook create() $url parameter from string to array to support multiple URLs Change webhook update() $url parameter from string to array yo support multiple URLs
This commit is contained in:
parent
4acac804bf
commit
562cda2504
@ -321,12 +321,12 @@ $mailgun->webhooks()->show('example.com', 'accept');
|
|||||||
|
|
||||||
#### Create a webhooks
|
#### Create a webhooks
|
||||||
```php
|
```php
|
||||||
$mailgun->webhooks()->create('example.com', 'accept', 'https://www.exmple.com/webhook');
|
$mailgun->webhooks()->create('example.com', 'opened', [ 'https://www.exmple.com/webhook' ]);
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Update a webhooks
|
#### Update a webhooks
|
||||||
```php
|
```php
|
||||||
$mailgun->webhooks()->update('example.com', 4711, 'https://www.exmple.com/webhook');
|
$mailgun->webhooks()->update('example.com', 4711, [ 'https://www.exmple.com/webhook' ]);
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Delete a webhooks
|
#### Delete a webhooks
|
||||||
|
@ -88,7 +88,7 @@ class Webhook extends HttpApi
|
|||||||
/**
|
/**
|
||||||
* @return CreateResponse|ResponseInterface
|
* @return CreateResponse|ResponseInterface
|
||||||
*/
|
*/
|
||||||
public function create(string $domain, string $id, string $url)
|
public function create(string $domain, string $id, array $url)
|
||||||
{
|
{
|
||||||
Assert::notEmpty($domain);
|
Assert::notEmpty($domain);
|
||||||
Assert::notEmpty($id);
|
Assert::notEmpty($id);
|
||||||
@ -107,7 +107,7 @@ class Webhook extends HttpApi
|
|||||||
/**
|
/**
|
||||||
* @return UpdateResponse|ResponseInterface
|
* @return UpdateResponse|ResponseInterface
|
||||||
*/
|
*/
|
||||||
public function update(string $domain, string $id, string $url)
|
public function update(string $domain, string $id, array $url)
|
||||||
{
|
{
|
||||||
Assert::notEmpty($domain);
|
Assert::notEmpty($domain);
|
||||||
Assert::notEmpty($id);
|
Assert::notEmpty($id);
|
||||||
|
@ -79,12 +79,22 @@ class WebhookTest extends TestCase
|
|||||||
$this->setRequestUri('/v3/domains/example.com/webhooks');
|
$this->setRequestUri('/v3/domains/example.com/webhooks');
|
||||||
$this->setHydrateClass(CreateResponse::class);
|
$this->setHydrateClass(CreateResponse::class);
|
||||||
$this->setRequestBody([
|
$this->setRequestBody([
|
||||||
'id' => '4711',
|
[
|
||||||
'url' => 'url',
|
'name' => 'id',
|
||||||
|
'content' => 'opened'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'url',
|
||||||
|
'content' => 'url_1'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'url',
|
||||||
|
'content' => 'url_2'
|
||||||
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$api = $this->getApiInstance('key');
|
$api = $this->getApiInstance('key');
|
||||||
$api->create('example.com', '4711', 'url');
|
$api->create('example.com', 'opened', ['url_1', 'url_2']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUpdate()
|
public function testUpdate()
|
||||||
@ -93,11 +103,18 @@ class WebhookTest extends TestCase
|
|||||||
$this->setRequestUri('/v3/domains/example.com/webhooks/4711');
|
$this->setRequestUri('/v3/domains/example.com/webhooks/4711');
|
||||||
$this->setHydrateClass(UpdateResponse::class);
|
$this->setHydrateClass(UpdateResponse::class);
|
||||||
$this->setRequestBody([
|
$this->setRequestBody([
|
||||||
'url' => 'url',
|
[
|
||||||
|
'name' => 'url',
|
||||||
|
'content' => 'url_1'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'url',
|
||||||
|
'content' => 'url_2'
|
||||||
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$api = $this->getApiInstance('key');
|
$api = $this->getApiInstance('key');
|
||||||
$api->update('example.com', '4711', 'url');
|
$api->update('example.com', '4711', ['url_1', 'url_2'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDelete()
|
public function testDelete()
|
||||||
|
Loading…
Reference in New Issue
Block a user