Skip to content

Commit

Permalink
企业微信审批应用新接口补充 (#1712)
Browse files Browse the repository at this point in the history
* 企业微信审批应该新接口补充

* 修改格式

* 修改数据类型

* 修改格式
  • Loading branch information
chengxiansheng authored and overtrue committed Oct 29, 2019
1 parent 8bf420d commit 770c522
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 0 deletions.
67 changes: 67 additions & 0 deletions src/Work/OA/Client.php
Expand Up @@ -45,6 +45,73 @@ public function checkinRecords(int $startTime, int $endTime, array $userList, in
return $this->httpPostJson('cgi-bin/checkin/getcheckindata', $params);
}

/**
* Get the checkin rules.
*
* @param int $datetime
* @param array $userList
*
* @return mixed
*
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function checkinRules(int $datetime, array $userList)
{
$params = [
'datetime' => $datetime,
'useridlist' => $userList,
];

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

/**
* Get Approval number.
*
* @param int $startTime
* @param int $endTime
* @param int $nextCursor
* @param int $size
* @param array $filters
*
* @return mixed
*
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function approvalNumbers(int $startTime, int $endTime, int $nextCursor = 0, int $size = 100, array $filters = [])
{
$params = [
'starttime' => $startTime,
'endtime' => $endTime,
'cursor' => $nextCursor,
'size' => $size > 100 ? 100 : $size,
'filters' => $filters,
];

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

/**
* Get approval detail.
*
* @param int $number
*
* @return mixed
*
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function approvalDetail(int $number)
{
$params = [
'sp_no' => $number,
];

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

/**
* Get Approval Data.
*
Expand Down
35 changes: 35 additions & 0 deletions tests/Work/OA/ClientTest.php
Expand Up @@ -29,6 +29,41 @@ public function testCheckinRecords()
$this->assertSame('mock-result', $client->checkinRecords(1408272000, 1408274000, ['overtrue', 'tianyong']));
}

public function testCheckinRules()
{
$client = $this->mockApiClient(Client::class);
$client->expects()->httpPostJson('cgi-bin/checkin/getcheckinoption', [
'datetime' => 1572192000,
'useridlist' => ['overtrue', 'tianyong'],
])->andReturn('mock-result');

$this->assertSame('mock-result', $client->checkinRules(1572192000, ['overtrue', 'tianyong']));
}

public function testApprovalNumbers()
{
$client = $this->mockApiClient(Client::class);
$client->expects()->httpPostJson('cgi-bin/oa/getapprovalinfo', [
'starttime' => 1408272000,
'endtime' => 1408274000,
'cursor' => 0,
'size' => 100,
'filters' => [],
])->andReturn('mock-result');

$this->assertSame('mock-result', $client->approvalNumbers(1408272000, 1408274000, 0, 100, []));
}

public function testApprovalDetail()
{
$client = $this->mockApiClient(Client::class);
$client->expects()->httpPostJson('cgi-bin/oa/getapprovaldetail', [
'sp_no' => 201910280001,
])->andReturn('mock-result');

$this->assertSame('mock-result', $client->approvalDetail(201910280001));
}

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

0 comments on commit 770c522

Please sign in to comment.