Add history method for task
This commit is contained in:
parent
fe18dce66a
commit
f926b59e36
29
src/Model/Entity/Tasks/TaskComment.php
Normal file
29
src/Model/Entity/Tasks/TaskComment.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHP version 7.3
|
||||||
|
*
|
||||||
|
* @category TaskHistory
|
||||||
|
* @package RetailCrm\Api\Model\Entity\TaskComment
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace RetailCrm\Api\Model\Entity\Tasks;
|
||||||
|
|
||||||
|
class TaskComment
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*
|
||||||
|
* @JMS\Type("int")
|
||||||
|
* @JMS\SerializedName("id")
|
||||||
|
*/
|
||||||
|
public $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*
|
||||||
|
* @JMS\Type("string")
|
||||||
|
* @JMS\SerializedName("comment")
|
||||||
|
*/
|
||||||
|
public $comment;
|
||||||
|
}
|
107
src/Model/Entity/Tasks/TaskHistory.php
Normal file
107
src/Model/Entity/Tasks/TaskHistory.php
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHP version 7.3
|
||||||
|
*
|
||||||
|
* @category TaskHistory
|
||||||
|
* @package RetailCrm\Api\Model\Entity\Tasks
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace RetailCrm\Api\Model\Entity\Tasks;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class TaskHistory
|
||||||
|
*
|
||||||
|
* @category TaskHistory
|
||||||
|
* @package RetailCrm\Api\Model\Entity\Tasks
|
||||||
|
*/
|
||||||
|
class TaskHistory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*
|
||||||
|
* @JMS\Type("int")
|
||||||
|
* @JMS\SerializedName("id")
|
||||||
|
*/
|
||||||
|
public $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var DateTime
|
||||||
|
*
|
||||||
|
* @JMS\Type("DateTime<'Y-m-d H:i:s'>")
|
||||||
|
* @JMS\SerializedName("createdAt")
|
||||||
|
*/
|
||||||
|
public $createdAt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var bool
|
||||||
|
*
|
||||||
|
* @JMS\Type("bool")
|
||||||
|
* @JMS\SerializedName("created")
|
||||||
|
*/
|
||||||
|
public $created;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*
|
||||||
|
* @JMS\Type("string")
|
||||||
|
* @JMS\SerializedName("source")
|
||||||
|
*/
|
||||||
|
public $source;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \RetailCrm\Api\Model\Entity\HistoryUser
|
||||||
|
*
|
||||||
|
* @JMS\Type("RetailCrm\Api\Model\Entity\HistoryUser")
|
||||||
|
* @JMS\SerializedName("user")
|
||||||
|
*/
|
||||||
|
public $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*
|
||||||
|
* @JMS\Type("string")
|
||||||
|
* @JMS\SerializedName("field")
|
||||||
|
*/
|
||||||
|
public $field;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var mixed
|
||||||
|
*
|
||||||
|
* @JMS\Type("mixed")
|
||||||
|
* @JMS\SerializedName("oldValue")
|
||||||
|
*/
|
||||||
|
public $oldValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var mixed
|
||||||
|
*
|
||||||
|
* @JMS\Type("mixed")
|
||||||
|
* @JMS\SerializedName("newValue")
|
||||||
|
*/
|
||||||
|
public $newValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \RetailCrm\Api\Model\Entity\HistoryApiKey
|
||||||
|
*
|
||||||
|
* @JMS\Type("RetailCrm\Api\Model\Entity\HistoryApiKey")
|
||||||
|
* @JMS\SerializedName("apiKey")
|
||||||
|
*/
|
||||||
|
public $apiKey;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \RetailCrm\Api\Model\Entity\Tasks\Task
|
||||||
|
*
|
||||||
|
* @JMS\Type("RetailCrm\Api\Model\Entity\Tasks\Task")
|
||||||
|
* @JMS\SerializedName("task")
|
||||||
|
*/
|
||||||
|
public $task;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \RetailCrm\Api\Model\Entity\Tasks\TaskComment
|
||||||
|
*
|
||||||
|
* @JMS\Type("RetailCrm\Api\Model\Entity\Tasks\TaskComment")
|
||||||
|
* @JMS\SerializedName("comment")
|
||||||
|
*/
|
||||||
|
public $comment;
|
||||||
|
}
|
53
src/Model/Filter/Tasks/TaskHistoryFilter.php
Normal file
53
src/Model/Filter/Tasks/TaskHistoryFilter.php
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHP version 7.3
|
||||||
|
*
|
||||||
|
* @category TaskHistoryFilter
|
||||||
|
* @package RetailCrm\Api\Model\Filter\Tasks
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace RetailCrm\Api\Model\Filter\Tasks;
|
||||||
|
|
||||||
|
use DateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class TaskHistoryFilter
|
||||||
|
*
|
||||||
|
* @category TaskHistoryFilter
|
||||||
|
* @package RetailCrm\Api\Model\Filter\Tasks
|
||||||
|
*/
|
||||||
|
class TaskHistoryFilter
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*
|
||||||
|
* @Form\Type("int")
|
||||||
|
* @Form\SerializedName("taskId")
|
||||||
|
*/
|
||||||
|
public $taskId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*
|
||||||
|
* @Form\Type("int")
|
||||||
|
* @Form\SerializedName("sinceId")
|
||||||
|
*/
|
||||||
|
public $sinceId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var DateTime|null
|
||||||
|
*
|
||||||
|
* @Form\Type("DateTime<'Y-m-d H:i:s'>")
|
||||||
|
* @Form\SerializedName("startDate")
|
||||||
|
*/
|
||||||
|
public $startDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var DateTime|null
|
||||||
|
*
|
||||||
|
* @Form\Type("DateTime<'Y-m-d H:i:s'>")
|
||||||
|
* @Form\SerializedName("endDate")
|
||||||
|
*/
|
||||||
|
public $endDate;
|
||||||
|
}
|
28
src/Model/Request/Tasks/TaskHistoryRequest.php
Normal file
28
src/Model/Request/Tasks/TaskHistoryRequest.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHP version 7.3
|
||||||
|
*
|
||||||
|
* @category TaskHistoryRequest
|
||||||
|
* @package RetailCrm\Api\Model\Request\Tasks
|
||||||
|
*/
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
class TaskHistoryRequest implements RequestInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
use HistoryPageLimitTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var TaskHistoryFilter
|
||||||
|
*
|
||||||
|
* @Form\Type("RetailCrm\Api\Model\Filter\Tasks\TaskHistoryFilter")
|
||||||
|
* @Form\SerializedName("filter")
|
||||||
|
*/
|
||||||
|
public $filter;
|
||||||
|
}
|
32
src/Model/Response/Tasks/TasksHistoryResponse.php
Normal file
32
src/Model/Response/Tasks/TasksHistoryResponse.php
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHP version 7.3
|
||||||
|
*
|
||||||
|
* @category TasksHistoryResponse
|
||||||
|
* @package RetailCrm\Api\Model\Response\Tasks
|
||||||
|
*/
|
||||||
|
|
||||||
|
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
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var DateTime
|
||||||
|
*
|
||||||
|
* @JMS\Type("DateTime<'Y-m-d H:i:s'>")
|
||||||
|
* @JMS\SerializedName("generatedAt")
|
||||||
|
*/
|
||||||
|
public $generatedAt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \RetailCrm\Api\Model\Entity\Tasks\TaskHistory[]
|
||||||
|
*
|
||||||
|
* @JMS\Type("array<RetailCrm\Api\Model\Entity\Tasks\TaskHistory>")
|
||||||
|
* @JMS\SerializedName("history")
|
||||||
|
*/
|
||||||
|
public $history;
|
||||||
|
}
|
@ -10,11 +10,13 @@
|
|||||||
namespace RetailCrm\Api\ResourceGroup;
|
namespace RetailCrm\Api\ResourceGroup;
|
||||||
|
|
||||||
use RetailCrm\Api\Enum\RequestMethod;
|
use RetailCrm\Api\Enum\RequestMethod;
|
||||||
|
use RetailCrm\Api\Model\Request\Tasks\TaskHistoryRequest;
|
||||||
use RetailCrm\Api\Model\Request\Tasks\TasksCreateRequest;
|
use RetailCrm\Api\Model\Request\Tasks\TasksCreateRequest;
|
||||||
use RetailCrm\Api\Model\Request\Tasks\TasksRequest;
|
use RetailCrm\Api\Model\Request\Tasks\TasksRequest;
|
||||||
use RetailCrm\Api\Model\Response\IdResponse;
|
use RetailCrm\Api\Model\Response\IdResponse;
|
||||||
use RetailCrm\Api\Model\Response\SuccessResponse;
|
use RetailCrm\Api\Model\Response\SuccessResponse;
|
||||||
use RetailCrm\Api\Model\Response\Tasks\TasksGetResponse;
|
use RetailCrm\Api\Model\Response\Tasks\TasksGetResponse;
|
||||||
|
use RetailCrm\Api\Model\Response\Tasks\TasksHistoryResponse;
|
||||||
use RetailCrm\Api\Model\Response\Tasks\TasksResponse;
|
use RetailCrm\Api\Model\Response\Tasks\TasksResponse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -264,4 +266,66 @@ class Tasks extends AbstractApiResourceGroup
|
|||||||
);
|
);
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Makes GET "/api/v5/tasks/history" request.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* ```php
|
||||||
|
* use RetailCrm\Api\Factory\SimpleClientFactory;
|
||||||
|
* use RetailCrm\Api\Interfaces\ApiExceptionInterface;
|
||||||
|
* use RetailCrm\Api\Model\Filter\Tasks\TaskHistoryFilter;
|
||||||
|
* use RetailCrm\Api\Model\Request\Tasks\TaskHistoryRequest;
|
||||||
|
*
|
||||||
|
* $client = SimpleClientFactory::createClient('https://test.retailcrm.pro', 'apiKey');
|
||||||
|
*
|
||||||
|
* $request = new TaskHistoryRequest();
|
||||||
|
* $request->limit = 100;
|
||||||
|
* $request->page = 1;
|
||||||
|
* $request->filter = new TaskHistoryFilter();
|
||||||
|
* $request->filter->sinceId = 1111;
|
||||||
|
*
|
||||||
|
* try {
|
||||||
|
* $response = $client->tasks->history($request);
|
||||||
|
* } catch (ApiExceptionInterface $exception) {
|
||||||
|
* echo sprintf(
|
||||||
|
* 'Error from RetailCRM API (status code: %d): %s',
|
||||||
|
* $exception->getStatusCode(),
|
||||||
|
* $exception->getMessage()
|
||||||
|
* );
|
||||||
|
*
|
||||||
|
* if (count($exception->getErrorResponse()->errors) > 0) {
|
||||||
|
* echo PHP_EOL . 'Errors: ' . implode(', ', $exception->getErrorResponse()->errors);
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* return;
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* echo 'Tasks history: ' . print_r($response->history, true);
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @param \RetailCrm\Api\Model\Request\Tasks\TaskHistoryRequest|null $request
|
||||||
|
*
|
||||||
|
* @return \RetailCrm\Api\Model\Response\Tasks\TasksHistoryResponse
|
||||||
|
* @throws \RetailCrm\Api\Interfaces\ApiExceptionInterface
|
||||||
|
* @throws \RetailCrm\Api\Interfaces\ClientExceptionInterface
|
||||||
|
* @throws \RetailCrm\Api\Exception\Api\AccountDoesNotExistException
|
||||||
|
* @throws \RetailCrm\Api\Exception\Api\ApiErrorException
|
||||||
|
* @throws \RetailCrm\Api\Exception\Api\MissingCredentialsException
|
||||||
|
* @throws \RetailCrm\Api\Exception\Api\MissingParameterException
|
||||||
|
* @throws \RetailCrm\Api\Exception\Api\ValidationException
|
||||||
|
* @throws \RetailCrm\Api\Exception\Client\HandlerException
|
||||||
|
* @throws \RetailCrm\Api\Exception\Client\HttpClientException
|
||||||
|
*/
|
||||||
|
public function history(?TaskHistoryRequest $request = null): TasksHistoryResponse
|
||||||
|
{
|
||||||
|
/** @var TasksHistoryResponse $response */
|
||||||
|
$response = $this->sendRequest(
|
||||||
|
RequestMethod::GET,
|
||||||
|
'tasks/history',
|
||||||
|
$request,
|
||||||
|
TasksHistoryResponse::class
|
||||||
|
);
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user