Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature]企业微信更新模版卡片消息 #2615

Merged
merged 1 commit into from
Nov 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/Work/Message/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,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', '已收到'));
}
}