Example #1
0
 /**
  * @param  string $apiToken Your HipChat Room's API token
  * @param  string $room Your room name
  * @param  callable[] $filters
  */
 public function __construct($apiToken, $room, $filters = [])
 {
     $this->hipChat = HipChatFactory::instance();
     $this->hipChat->setAccessToken($apiToken);
     $this->room = $room;
     $this->filters = $filters;
 }
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $app = $this->app;
     $app->singleton('hipchat-v2.httpClient', function ($app) {
         $config = $app['config']->get('hipchat-php-v2::config');
         // Check for Base Url (self-hosted HipChat Server)
         if (!empty($config['baseUrl'])) {
             HipChatFactory::$baseUrl = $config['baseUrl'];
         }
         $httpClient = HipChatFactory::createHttpClient();
         // Check for default OAuth Token
         if (!empty($config['oauthToken'])) {
             $httpClient->setAccessToken($config['oauthToken']);
         }
         return $httpClient;
     });
     $app->singleton('hipchat-v2.emoticons', function ($app) {
         return new Emoticons(null, $app['hipchat-v2.httpClient']);
     });
     $app->singleton('hipchat-v2.sessions', function ($app) {
         return new Sessions(null, $app['hipchat-v2.httpClient']);
     });
     $app->singleton('hipchat-v2.rooms', function ($app) {
         return new Rooms(null, $app['hipchat-v2.httpClient']);
     });
     $app->singleton('hipchat-v2.users', function ($app) {
         return new Users(null, $app['hipchat-v2.httpClient']);
     });
     $app->singleton('hipchat-v2', function ($app) {
         $config = $app['config']->get('hipchat-php-v2::config');
         $hipchat = new HipChatLaravel($app['hipchat-v2.httpClient'], $app['hipchat-v2.emoticons'], $app['hipchat-v2.sessions'], $app['hipchat-v2.rooms'], $app['hipchat-v2.users']);
         // Check for Default OAuth ID and Secret
         if (!empty($config['oauthId']) and !empty($config['oauthSecret'])) {
             $hipchat->setDefaultOauthId($config['oauthId']);
             $hipchat->setDefaultOauthSecret($config['oauthSecret']);
         }
         return $hipchat;
     });
 }