Conditions | 4 |
Paths | 3 |
Total Lines | 21 |
Lines | 0 |
Ratio | 0 % |
Tests | 3 |
CRAP Score | 10.75 |
Changes | 0 |
1 | <?php |
||
34 | 1 | public function send($notifiable, Notification $notification) |
|
35 | { |
||
36 | 1 | if (! $url = $notifiable->routeNotificationFor(HangoutsChatChannel::class)) { |
|
37 | 1 | return; |
|
38 | } |
||
39 | |||
40 | $webhookData = $notification->{'toHangoutsChat'}($notifiable)->toArray(); |
||
41 | |||
42 | $response = $this->client->post($url, [ |
||
43 | 'query' => Arr::get($webhookData, 'query'), |
||
44 | 'body' => json_encode(Arr::get($webhookData, 'data')), |
||
45 | 'verify' => Arr::get($webhookData, 'verify'), |
||
46 | 'headers' => Arr::get($webhookData, 'headers'), |
||
47 | ]); |
||
48 | |||
49 | if ($response->getStatusCode() >= 300 || $response->getStatusCode() < 200) { |
||
50 | throw CouldNotSendNotification::serviceRespondedWithAnError($response); |
||
51 | } |
||
52 | |||
53 | return $response; |
||
54 | } |
||
55 | } |
||
56 |