/**
  * @param string $type
  * @param Request $request
  * @return array
  * @throws \Exception
  */
 private function validateSettings($type, Request $request)
 {
     switch ($type) {
         case 'email':
             $this->validate($request, ['settings.email' => 'required']);
             return $request->request->get('settings');
         case 'slack':
         case 'hipchat':
             $this->validate($request, ['settings.webhook_url' => 'required']);
             return $request->request->get('settings');
         case 'sms':
             $this->validate($request, ['settings.recipient' => 'required', 'settings.country' => 'required']);
             $settings = $request->request->get('settings');
             $twilioService = new TwilioService();
             $settings['recipient'] = $twilioService->numberLookUp($settings['recipient'], $settings['country']);
             return $settings;
     }
     throw new \Exception('Invalid type');
 }
示例#2
0
 /**
  * @param Warning $warning
  */
 public function notify(Warning $warning)
 {
     $recipient = $this->settings->recipient;
     $this->twilioService->sendSMS($recipient, $warning->getTitle());
 }