From 19f21d5ddbb0b07dd3904fd6db3fb8fa74b4e729 Mon Sep 17 00:00:00 2001 From: Kyle Stevenson Date: Sun, 3 Sep 2017 02:15:24 -0700 Subject: [PATCH] Update WebhookChannel to use the json request option in Guzzle This will automatically set the appropriate Content-Type header[1] [1] http://docs.guzzlephp.org/en/stable/request-options.html#json --- src/WebhookChannel.php | 2 +- tests/ChannelTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/WebhookChannel.php b/src/WebhookChannel.php index b6bd5df..742db75 100644 --- a/src/WebhookChannel.php +++ b/src/WebhookChannel.php @@ -37,7 +37,7 @@ public function send($notifiable, Notification $notification) $webhookData = $notification->toWebhook($notifiable)->toArray(); $response = $this->client->post($url, [ - 'body' => json_encode(Arr::get($webhookData, 'data')), + 'json' => Arr::get($webhookData, 'data'), 'verify' => false, 'headers' => Arr::get($webhookData, 'headers'), ]); diff --git a/tests/ChannelTest.php b/tests/ChannelTest.php index 69a3ea1..1b0c3df 100644 --- a/tests/ChannelTest.php +++ b/tests/ChannelTest.php @@ -22,7 +22,7 @@ public function it_can_send_a_notification() ->once() ->with('https://notifiable-webhook-url.com', [ - 'body' => '{"payload":{"webhook":"data"}}', + 'json' => ['payload' => ['webhook' => 'data']], 'verify' => false, 'headers' => [ 'User-Agent' => 'WebhookAgent', @@ -42,7 +42,7 @@ public function it_can_send_a_notification_with_2xx_status() ->once() ->with('https://notifiable-webhook-url.com', [ - 'body' => '{"payload":{"webhook":"data"}}', + 'json' => ['payload' => ['webhook' => 'data']], 'verify' => false, 'headers' => [ 'User-Agent' => 'WebhookAgent',