/**
  * Gets all webhooks for this room
  * More info: https://www.hipchat.com/docs/apiv2/method/get_all_webhooks
  *
  * @param string $roomId The id or name of the room
  *
  * @TODO should return a Collection
  * @return array Array of Webhook
  */
 public function getAllWebhooks($roomId)
 {
     $webhooks = array();
     $response = $this->client->get(sprintf('/v2/room/%s/webhook', $roomId));
     foreach ($response['items'] as $item) {
         $webhooks[] = new Webhook($item);
     }
     return $webhooks;
 }
Exemple #2
0
 /**
  * Fetch latest chat history for the 1:1 chat with the user
  * More info: https://www.hipchat.com/docs/apiv2/method/view_recent_privatechat_history
  *
  * @param string $userId The id, email address, or mention name (beginning with an '@')
  *                        of the user to send a message to
  * @param mixed $parameters Optional parameters, check above documentation for more info
  *
  * @return array Message
  */
 public function getRecentPrivateChatHistory($userId, array $parameters = array())
 {
     $response = $this->client->get(sprintf('/v2/user/%s/history/latest', $userId), $parameters);
     $messages = array();
     foreach ($response['items'] as $response) {
         $messages[] = new Message($response);
     }
     return $messages;
 }
 /**
  * Gets a user photo
  * More info: https://www.hipchat.com/docs/apiv2/method/get_photo
  *
  * @param string $userId The id, email address, or mention name (beginning with an '@') of the user
  * @param string $size   The size to retrieve ("small" or "big")
  *
  * @return string
  */
 public function getPhoto($userId, $size)
 {
     $response = $this->client->get(sprintf('/v2/user/%s/photo/%s', $userId, $size));
     return $response;
 }
 function it_gets_webhooks(Client $client, Webhook $webhook)
 {
     $response = $this->getWebhookArrayResponse();
     $client->get('/v2/room/234567/webhook')->shouldBeCalled()->willReturn($response);
     $this->getAllWebhooks('234567')->shouldHaveCount(2);
 }
 function it_sends_private_message_user(Client $client)
 {
     $client->post('/v2/user/123456/message', array('message' => 'Im testing!!'))->shouldBeCalled();
     $this->privateMessageUser('123456', 'Im testing!!');
 }