Exemplo n.º 1
0
 /**
  * Test transformNews().
  */
 public function testTransformNews()
 {
     $transformer = new Transformer();
     // one
     $result = $transformer->transform(new News(['title' => 'overtrue', 'description' => 'foobar']))['news']['articles'];
     $this->assertEquals('overtrue', $result[0]['title']);
     $this->assertEquals('foobar', $result[0]['description']);
     // more
     $news = [new News(['title' => 'foo']), new News(['title' => 'bar'])];
     $result = $transformer->transform($news)['news']['articles'];
     $this->assertEquals('foo', $result[0]['title']);
     $this->assertEquals('bar', $result[1]['title']);
 }
Exemplo n.º 2
0
 /**
  * Send the message.
  *
  * @return bool
  *
  * @throws RuntimeException
  */
 public function send()
 {
     if (empty($this->message)) {
         throw new RuntimeException('No message to send.');
     }
     $content = $this->transformer->transform($this->message);
     $message = ['touser' => $this->to, 'msgtype' => $this->message->type, $this->message->type => $content, 'customservice' => ['kf_account' => $this->account]];
     return $this->http->json(self::API_MESSAGE_SEND, $message);
 }
Exemplo n.º 3
0
 /**
  * Send the message.
  *
  * @return bool
  */
 public function send()
 {
     if (empty($this->message)) {
         throw new RuntimeException('No message to send.');
     }
     $this->message->to = $this->to;
     $this->message->account = $this->account;
     $message = $this->transformer->transform($this->message);
     return $this->http->jsonPost(self::API_MESSAGE_SEND, $message);
 }
Exemplo n.º 4
0
 /**
  * Send the message.
  *
  * @return bool
  *
  * @throws RuntimeException
  */
 public function send()
 {
     if (empty($this->message)) {
         throw new RuntimeException('No message to send.');
     }
     $transformer = new Transformer();
     if ($this->message instanceof RawMessage) {
         $message = $this->message->get('content');
     } else {
         $content = $transformer->transform($this->message);
         $message = array_merge(['touser' => $this->to, 'customservice' => ['kf_account' => $this->account]], $content);
     }
     return $this->staff->send($message);
 }
Exemplo n.º 5
0
 /**
  * Send the message.
  *
  * @return bool
  *
  * @throws RuntimeException
  */
 public function send()
 {
     if (empty($this->message)) {
         throw new RuntimeException('No message to send.');
     }
     $transformer = new Transformer();
     $content = $transformer->transform($this->message);
     $message = array_merge(['touser' => $this->to, 'msgtype' => $this->message->type, 'customservice' => ['kf_account' => $this->account]], $content);
     return $this->staff->send($message);
 }