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