Blame view

addons/antis/library/wework/Api/AppChat.php 1.34 KB
2db47680   hexiaodong   chore: 初始提交 php 遗...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
  <?php

  

  namespace WeWork\Api;

  

  use WeWork\Message\ResponseMessageInterface;

  use WeWork\Traits\HttpClientTrait;

  

  class AppChat

  {

      use HttpClientTrait;

  

      /**

       * 创建群聊会话

       *

       * @param array $json

       * @return array

       */

      public function create(array $json): array

      {

          return $this->httpClient->postJson('appchat/create', $json);

      }

  

      /**

       * 修改群聊会话

       *

       * @param array $json

       * @return array

       */

      public function update(array $json): array

      {

          return $this->httpClient->postJson('appchat/update', $json);

      }

  

      /**

       * 获取群聊会话

       *

       * @param string $id

       * @return array

       */

      public function get(string $id): array

      {

          return $this->httpClient->get('appchat/get', ['chatid' => $id]);

      }

  

      /**

       * 应用推送消息

       *

       * @param string $id

       * @param ResponseMessageInterface $responseMessage

       * @param bool $safe

       * @return array

       */

      public function send(string $id, ResponseMessageInterface $responseMessage, bool $safe = false): array

      {

          return $this->httpClient->postJson(

              'appchat/send',

              array_merge(['chatid' => $id], $responseMessage->formatForResponse(), ['safe' => (int)$safe])

          );

      }

  }