/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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; }
/** * 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)); }
/** * 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); }
/** * 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); }