Skip to content

Commit

Permalink
[feature]企业微信更新模版卡片消息 (#2615)
Browse files Browse the repository at this point in the history
Co-authored-by: dengxit <[email protected]>
  • Loading branch information
dengxit and dengxit authored Nov 1, 2022
1 parent a4fe67f commit cfd0feb
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/Work/Message/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,33 @@ public function updateTaskcard(array $userids, int $agentId, string $taskId, str

return $this->httpPostJson('cgi-bin/message/update_taskcard', $params);
}

/**
* * 更新模版卡片消息状态
*
* @see https://developer.work.weixin.qq.com/document/path/94888
*
* @param array $userids
* @param int $agentId
* @param string $responseCode
* @param string $replaceName
*
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
*
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function updateTemplateCard(array $userids, int $agentId, string $responseCode, string $replaceName = '已收到')
{
$params = [
'userids' => $userids,
'agentid' => $agentId,
'response_code' => $responseCode,
'button' => [
'replace_name' => $replaceName
]
];

return $this->httpPostJson('cgi-bin/message/update_template_card', $params);
}
}
18 changes: 18 additions & 0 deletions tests/Work/Message/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,22 @@ public function testUpdateTaskcard()

$this->assertSame('mock-result', $client->updateTaskcard(['userid1','userid2'], 1, 'taskid1', '已收到'));
}

public function testTemplateCard()
{
$client = $this->mockApiClient(Client::class);

$params = [
'userids' => ['userid1','userid2'],
'agentid' => 1,
'response_code' => 'testcode',
'button' => [
'replace_name' => '已收到'
]
];

$client->expects()->httpPostJson('cgi-bin/message/update_template_card', $params)->andReturn('mock-result');

$this->assertSame('mock-result', $client->updateTemplateCard(['userid1','userid2'], 1, 'testcode', '已收到'));
}
}

0 comments on commit cfd0feb

Please sign in to comment.