コード例 #1
0
ファイル: Push.php プロジェクト: mremi/flowdock
 /**
  * Sends a message to a flow
  *
  * @param BaseMessageInterface $message A message instance to send
  * @param string               $baseUrl A base URL
  * @param array                $options An array of options used by request
  *
  * @return boolean
  */
 protected function sendMessage(BaseMessageInterface $message, $baseUrl, array $options = array())
 {
     $client = $this->createClient(sprintf('%s/%s', $baseUrl, $this->flowApiToken));
     $request = $client->post(null, array('Content-Type' => 'application/json'), json_encode($message->getData()), $options);
     $message->setResponse($request->send());
     return !$message->hasResponseErrors();
 }
コード例 #2
0
ファイル: BaseMessageTest.php プロジェクト: mremi/flowdock
 /**
  * Tests an invalid response
  */
 public function testInvalidResponse()
 {
     $this->message->setResponse(new Response(400, null, '{"message": "Validation error", "errors": {"content": ["can\'t be blank"]}}'));
     $this->assertEquals(array('message' => 'Validation error', 'errors' => array('content' => array('can\'t be blank'))), $this->message->getResponseBody());
     $this->assertEquals('Validation error', $this->message->getResponseMessage());
     $this->assertTrue(is_array($this->message->getResponseErrors()));
     $this->assertEquals(array('content' => array('can\'t be blank')), $this->message->getResponseErrors());
     $this->assertTrue($this->message->hasResponseErrors());
 }