function it_gets_user(Client $client) { $mentionName = '@test'; $response = $this->getTestResponse(); $client->get("/v2/user/{$mentionName}")->shouldBeCalled()->willReturn($response); $this->getUser($mentionName)->shouldReturnAnInstanceOf('GorkaLaucirica\\HipchatAPIv2Client\\Model\\User'); }
/** * 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; }
/** * 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; }
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); }
/** * 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; }