diff --git a/doc/index.md b/doc/index.md index e47327b..23d7770 100644 --- a/doc/index.md +++ b/doc/index.md @@ -321,12 +321,12 @@ $mailgun->webhooks()->show('example.com', 'accept'); #### Create a webhooks ```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 ```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 diff --git a/src/Api/Webhook.php b/src/Api/Webhook.php index 229e2f6..9c2565b 100644 --- a/src/Api/Webhook.php +++ b/src/Api/Webhook.php @@ -88,7 +88,7 @@ class Webhook extends HttpApi /** * @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($id); @@ -107,7 +107,7 @@ class Webhook extends HttpApi /** * @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($id); diff --git a/tests/Api/WebhookTest.php b/tests/Api/WebhookTest.php index 7753cf3..6ad83a5 100644 --- a/tests/Api/WebhookTest.php +++ b/tests/Api/WebhookTest.php @@ -79,12 +79,22 @@ class WebhookTest extends TestCase $this->setRequestUri('/v3/domains/example.com/webhooks'); $this->setHydrateClass(CreateResponse::class); $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->create('example.com', '4711', 'url'); + $api->create('example.com', 'opened', ['url_1', 'url_2']); } public function testUpdate() @@ -93,11 +103,18 @@ class WebhookTest extends TestCase $this->setRequestUri('/v3/domains/example.com/webhooks/4711'); $this->setHydrateClass(UpdateResponse::class); $this->setRequestBody([ - 'url' => 'url', + [ + 'name' => 'url', + 'content' => 'url_1' + ], + [ + 'name' => 'url', + 'content' => 'url_2' + ] ]); $api = $this->getApiInstance('key'); - $api->update('example.com', '4711', 'url'); + $api->update('example.com', '4711', ['url_1', 'url_2'] ); } public function testDelete()