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