diff --git a/src/Wechat/Work/Chat.php b/src/Wechat/Work/Chat.php index 4b98456..757bc8f 100644 --- a/src/Wechat/Work/Chat.php +++ b/src/Wechat/Work/Chat.php @@ -4,18 +4,20 @@ namespace Wechat\Work; use Wechat\Work\Message\MessageInterface; -class Chat extends Base +class Chat { protected $id; + protected $work; - public function __construct($id = null) + public function __construct($id, $work) { - parent::__construct(); + $this->work = $work; $this->id = $id; } /** + * 发送消息 * @param $msg MessageInterface * @return mixed */ @@ -58,14 +60,6 @@ class Chat extends Base return json_decode($resp->getBody(), true); } - public function send(Message $message) - { - $request = $this->transformForJsonRequest('POST', 'appchat/send', - array_merge(['chatid' => $this->id], $message->toArray())); - $resp = $this->client->send($request); - return json_decode($resp->getBody(), true); - } - public function update($chatId, array $add = null, array $del = null, $name = null, $owner = null) { $params = [ diff --git a/src/Wechat/Work/Message/MessageInterface.php b/src/Wechat/Work/Message/MessageInterface.php index 6806c02..b61fc35 100644 --- a/src/Wechat/Work/Message/MessageInterface.php +++ b/src/Wechat/Work/Message/MessageInterface.php @@ -16,7 +16,7 @@ abstract class MessageInterface protected $type; - protected $params; + protected $params = []; protected $attr; public function toUser($user) diff --git a/src/Wechat/Work/Work.php b/src/Wechat/Work/Work.php index b0aa858..a54ee48 100644 --- a/src/Wechat/Work/Work.php +++ b/src/Wechat/Work/Work.php @@ -10,9 +10,21 @@ class Work extends Base parent::__construct($config); } + /** + * 消息推送 + * @return Message + */ public function message() { return new Message($this); } + /** + * 群聊接口 + */ + public function chat($id) + { + return new Chat($id, $this); + } + } \ No newline at end of file