diff --git a/src/Model/Entity/Tasks/TaskComment.php b/src/Model/Entity/Tasks/TaskComment.php index a394c10..ff163ec 100644 --- a/src/Model/Entity/Tasks/TaskComment.php +++ b/src/Model/Entity/Tasks/TaskComment.php @@ -9,6 +9,8 @@ namespace RetailCrm\Api\Model\Entity\Tasks; +use RetailCrm\Api\Component\Serializer\Annotation as JMS; + class TaskComment { /** diff --git a/src/Model/Entity/Tasks/TaskHistory.php b/src/Model/Entity/Tasks/TaskHistory.php index 2791408..52457c7 100644 --- a/src/Model/Entity/Tasks/TaskHistory.php +++ b/src/Model/Entity/Tasks/TaskHistory.php @@ -9,6 +9,9 @@ namespace RetailCrm\Api\Model\Entity\Tasks; +use DateTime; +use RetailCrm\Api\Component\Serializer\Annotation as JMS; + /** * Class TaskHistory * diff --git a/src/Model/Filter/Tasks/TaskHistoryFilter.php b/src/Model/Filter/Tasks/TaskHistoryFilter.php index 4186fb4..15d09d4 100644 --- a/src/Model/Filter/Tasks/TaskHistoryFilter.php +++ b/src/Model/Filter/Tasks/TaskHistoryFilter.php @@ -10,6 +10,7 @@ namespace RetailCrm\Api\Model\Filter\Tasks; use DateTime; +use RetailCrm\Api\Component\FormData\Mapping as Form; /** * Class TaskHistoryFilter diff --git a/src/Model/Request/Tasks/TaskHistoryRequest.php b/src/Model/Request/Tasks/TaskHistoryRequest.php index a9de66b..45fc7a6 100644 --- a/src/Model/Request/Tasks/TaskHistoryRequest.php +++ b/src/Model/Request/Tasks/TaskHistoryRequest.php @@ -12,10 +12,10 @@ namespace RetailCrm\Api\Model\Request\Tasks; use RetailCrm\Api\Interfaces\RequestInterface; use RetailCrm\Api\Model\Filter\Tasks\TaskHistoryFilter; use RetailCrm\Api\Model\Request\Traits\HistoryPageLimitTrait; +use RetailCrm\Api\Component\FormData\Mapping as Form; class TaskHistoryRequest implements RequestInterface { - use HistoryPageLimitTrait; /** diff --git a/src/Model/Response/Tasks/TasksHistoryResponse.php b/src/Model/Response/Tasks/TasksHistoryResponse.php index 3d8ef02..4f8d4a6 100644 --- a/src/Model/Response/Tasks/TasksHistoryResponse.php +++ b/src/Model/Response/Tasks/TasksHistoryResponse.php @@ -12,6 +12,7 @@ namespace RetailCrm\Api\Model\Response\Tasks; use DateTime; use RetailCrm\Api\Component\Serializer\Annotation as JMS; use RetailCrm\Api\Model\Response\AbstractPaginatedResponse; + class TasksHistoryResponse extends AbstractPaginatedResponse { /** diff --git a/tests/src/ResourceGroup/TasksTest.php b/tests/src/ResourceGroup/TasksTest.php index 0856bd3..1863298 100644 --- a/tests/src/ResourceGroup/TasksTest.php +++ b/tests/src/ResourceGroup/TasksTest.php @@ -14,6 +14,8 @@ use RetailCrm\Api\Enum\Tasks\TaskStatus; use RetailCrm\Api\Model\Entity\Tasks\AbstractCustomer; use RetailCrm\Api\Model\Entity\Tasks\Task; use RetailCrm\Api\Model\Filter\Tasks\TaskFilter; +use RetailCrm\Api\Model\Filter\Tasks\TaskHistoryFilter; +use RetailCrm\Api\Model\Request\Tasks\TaskHistoryRequest; use RetailCrm\Api\Model\Request\Tasks\TasksCreateRequest; use RetailCrm\Api\Model\Request\Tasks\TasksRequest; use RetailCrm\TestUtils\Factory\TestClientFactory; @@ -175,4 +177,54 @@ EOF; self::assertModelEqualsToResponse($json, $response); } + + public function testHistory(): void + { + $json = <<<'EOF' +{ + "success":true, + "history":[ + { + "id":1, + "createdAt":"2023-03-22 19:00:29", + "created":true, + "source":"rule", + "field":"id", + "oldValue":null, + "newValue":1, + "task":{ + "id":95978, + "text":"", + "commentary":"", + "createdAt":"2023-03-22 19:00:29", + "complete":false, + "performer":116, + "performerType":"user", + "customer":{ + "type":"customer", + "id":1 + } + } + } + ] +} +EOF; + + $mock = static::createApiMockBuilder('tasks/1'); + $mock->matchMethod(RequestMethod::GET) + ->reply(200) + ->withBody($json); + + $client = TestClientFactory::createClient($mock->getClient()); + + $request = new TaskHistoryRequest(); + $request->limit = 100; + $request->page = 1; + $request->filter = new TaskHistoryFilter(); + $request->filter->sinceId = 1; + + $response = $client->tasks->history($request); + + self::assertModelEqualsToResponse($json, $response); + } }