message
This commit is contained in:
parent
06d17d9766
commit
2f75f83084
|
@ -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 = [
|
||||
|
|
|
@ -16,7 +16,7 @@ abstract class MessageInterface
|
|||
|
||||
protected $type;
|
||||
|
||||
protected $params;
|
||||
protected $params = [];
|
||||
protected $attr;
|
||||
|
||||
public function toUser($user)
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user