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