Example #1
0
 /**
  * Send a notification.
  *
  * @param string $to
  * @param string $message
  *
  * @return \NotifyMeHQ\Contracts\ResponseInterface
  */
 public function notify($to, $message)
 {
     $params = ['token' => $this->config['token'], 'user' => $to, 'device' => Arr::get($this->config, 'device', ''), 'title' => Arr::get($this->config, 'title', ''), 'message' => $message];
     if (isset($this->config['sound'])) {
         $params['sound'] = in_array($this->config['sound'], $this->allowedSounds) ? ${$this}->config['sound'] : 'pushover';
     }
     return $this->send($this->buildUrlFromString('messages.json'), $params);
 }
Example #2
0
 /**
  * Send a notification.
  *
  * @param string $to
  * @param string $message
  *
  * @return \NotifyMeHQ\Contracts\ResponseInterface
  */
 public function notify($to, $message)
 {
     $params = ['id' => $to, 'from' => $this->config['from'], 'message' => $message, 'notify' => Arr::get($this->config, 'notify', false), 'message_format' => Arr::get($this->config, 'format', 'text')];
     $color = Arr::get($this->config, 'color', 'yellow');
     if (!in_array($color, $this->colours)) {
         $color = 'yellow';
     }
     $params['color'] = $color;
     $type = Arr::get($this->config, 'type', 'message');
     return $this->send($this->buildUrlFromString("room/{$to}/{$type}"), $params);
 }
Example #3
0
 /**
  * Send a notification.
  *
  * @param string $to
  * @param string $message
  *
  * @return \NotifyMeHQ\Contracts\ResponseInterface
  */
 public function notify($to, $message)
 {
     $type = Arr::get($this->config, 'type', 'TextMessage');
     if (!in_array($type, $this->allowedTypeMessages)) {
         $type = 'TextMessage';
     }
     $params = ['type' => $type];
     if ($type === 'SoundMessage') {
         $params['body'] = in_array($message, $this->allowedSounds) ? $message : 'horn';
     } else {
         $params['body'] = $message;
     }
     return $this->send($this->buildUrlFromString("room/{$to}/speak.json"), $params);
 }
Example #4
0
 /**
  * Create a new email gateway instance.
  *
  * @param string[] $config
  *
  * @return \NotifyMeHQ\Adapters\Email\EmailGateway
  */
 public function make(array $config)
 {
     Arr::requires($config, ['smtp', 'user', 'pass', 'subject']);
     $client = new PHPMailer();
     $client->isSMTP();
     $client->CharSet = 'UTF-8';
     $client->Host = Arr::get($config, 'smtp');
     $client->SMTPAuth = Arr::get($config, 'smtp_auth', true);
     $client->Username = Arr::get($config, 'user');
     $client->Password = Arr::get($config, 'pass');
     $client->SMTPSecure = Arr::get($config, 'smtp_secure', 'tls');
     $client->Port = Arr::get($config, 'port', 587);
     $client->isHTML(Arr::get($config, 'html', true));
     $client->setFrom(Arr::get($config, 'from', 'APP'), Arr::get($config, 'from_name', 'APP'));
     return new EmailGateway($client, $config);
 }
Example #5
0
 /**
  * Create a new Nexmo gateway instance.
  *
  * @param string[] $config
  *
  * @return \NotifyMeHQ\Adapters\Nexmo\NexmoGateway
  */
 public function make(array $config)
 {
     Arr::requires($config, ['api_key', 'api_secret', 'from']);
     $client = new Client();
     return new NexmoGateway($client, $config);
 }
Example #6
0
 /**
  * Create a new slack gateway instance.
  *
  * @param string[] $config
  *
  * @return \NotifyMeHQ\Adapters\Slack\SlackGateway
  */
 public function make(array $config)
 {
     Arr::requires($config, ['token']);
     $client = new Client();
     return new SlackGateway($client, $config);
 }
Example #7
0
 /**
  * Create a new webhook gateway instance.
  *
  * @param string[] $config
  *
  * @return \NotifyMeHQ\Adapters\Webhook\WebhookGateway
  */
 public function make(array $config)
 {
     Arr::requires($config, ['endpoint']);
     $client = new Client();
     return new WebhookGateway($client, $config);
 }
Example #8
0
 /**
  * Create a new campfire gateway instance.
  *
  * @param string[] $config
  *
  * @return \NotifyMeHQ\Adapters\Campfire\CampfireGateway
  */
 public function make(array $config)
 {
     Arr::requires($config, ['from', 'token']);
     $client = new Client();
     return new CampfireGateway($client, $config);
 }
Example #9
0
 /**
  * Get the configuration for a connection.
  *
  * @param string $name
  *
  * @return array
  */
 public function getConnectionConfig($name)
 {
     $name = $name ?: $this->default;
     if (!is_array($config = Arr::get($this->config, $name)) && !$config) {
         throw new InvalidArgumentException("Connection [{$name}] not configured.");
     }
     return $config;
 }
Example #10
0
 /**
  * Send a notification.
  *
  * @param string $to
  * @param string $message
  *
  * @return \NotifyMeHQ\Contracts\ResponseInterface
  */
 public function notify($to, $message)
 {
     $params = ['UN' => Arr::get($this->config, 'username', ''), 'PW' => Arr::get($this->config, 'password', ''), 'O' => urlencode(Arr::get($this->config, 'sender', '')), 'D' => Arr::get($this->config, 'D', $to), 'LONGSMS' => Arr::get($this->config, 'LONGSMS', ''), 'M' => $message];
     return $this->send($this->buildUrlFromString('http/get/SendSms.php'), array_filter($params));
 }
Example #11
0
 /**
  * Send a notification.
  *
  * @param string $to
  * @param string $message
  *
  * @return \NotifyMeHQ\Contracts\ResponseInterface
  */
 public function notify($to, $message)
 {
     $params = ['to' => $to, 'service_key' => $this->config['token'], 'event_type' => Arr::get($this->config, 'event_type', 'trigger'), 'client' => Arr::get($this->config, 'client', null), 'client_url' => Arr::get($this->config, 'client_url', null), 'details' => Arr::get($this->config, 'details', null), 'description' => $message];
     return $this->send($this->buildUrlFromString('create_event.json'), $params);
 }
Example #12
0
 /**
  * Send a notification.
  *
  * @param string $to
  * @param string $message
  *
  * @return \NotifyMeHQ\Contracts\ResponseInterface
  */
 public function notify($to, $message)
 {
     $params = ['username' => strtoupper($to), 'api_token' => $this->config['token'], 'location' => Arr::get($this->config, 'location'), 'link' => Arr::get($this->config, 'link')];
     return $this->send($this->buildUrlFromString('yo'), $params);
 }