コード例 #1
0
ファイル: UserAPI.php プロジェクト: kireol/stashCalendar
 /**
  * Sends a user a private message
  * More info: https://www.hipchat.com/docs/apiv2/method/private_message_user
  *
  * @param string $user The id, email address, or mention name (beginning with an '@')
  *                        of the user to send a message to
  * @param mixed $message The message to send as plain text
  *
  * @return void
  */
 public function privateMessageUser($user, $message)
 {
     if (is_string($message)) {
         $content = array('message' => $message);
     } else {
         // Assuming its a Message
         $content = $message->toJson();
     }
     $this->client->post(sprintf('/v2/user/%s/message', $user), $content);
 }
コード例 #2
0
 /**
  * Creates a new webhook
  * More info: https://www.hipchat.com/docs/apiv2/method/create_webhook
  *
  * @param string $roomId The id or name of the room
  * @param Webhook $webhook The webhook to create
  *
  * @return int Just created webhook id
  */
 public function createWebhook($roomId, Webhook $webhook)
 {
     $response = $this->client->post(sprintf('/v2/room/%s/webhook', $roomId), $webhook->toJson());
     return $response['id'];
 }
コード例 #3
0
 function it_creates_webhook(Client $client, Webhook $webhook)
 {
     $request = array('url' => 'http://example.com/webhook', 'pattern' => '/phpspec/', 'event' => 'room_message', 'name' => '112233');
     $webhook->toJson()->shouldBeCalled()->willReturn($request);
     $client->post('/v2/room/123456/webhook', $request)->shouldBeCalled();
     $this->createWebhook('123456', $webhook);
 }
コード例 #4
0
 function it_sends_private_message_user(Client $client)
 {
     $client->post('/v2/user/123456/message', array('message' => 'Im testing!!'))->shouldBeCalled();
     $this->privateMessageUser('123456', 'Im testing!!');
 }