. */ namespace SP\Services\Account; use SP\Core\Exceptions\SPException; use SP\Core\Traits\InjectableTrait; use SP\DataModel\AccountHistoryData; use SP\DataModel\ItemSearchData; use SP\Repositories\Account\AccountHistoryRepository; use SP\Repositories\Account\AccountToUserGroupRepository; use SP\Repositories\Account\AccountToUserRepository; /** * Class AccountHistoryService * * @package SP\Services\Account */ class AccountHistoryService { use InjectableTrait; /** * @var AccountHistoryRepository */ protected $accountHistoryRepository; /** * @var AccountToUserGroupRepository */ protected $accountToUserGroupRepository; /** * @var AccountToUserRepository */ protected $accountToUserRepository; /** * AccountHistoryService constructor. * * @throws \SP\Core\Dic\ContainerException */ public function __construct() { $this->injectDependencies(); } /** * @param AccountHistoryRepository $accountHistoryRepository * @param AccountToUserGroupRepository $accountToUserGroupRepository * @param AccountToUserRepository $accountToUserRepository */ public function inject(AccountHistoryRepository $accountHistoryRepository, AccountToUserGroupRepository $accountToUserGroupRepository, AccountToUserRepository $accountToUserRepository) { $this->accountHistoryRepository = $accountHistoryRepository; $this->accountToUserGroupRepository = $accountToUserGroupRepository; $this->accountToUserRepository = $accountToUserRepository; } /** * Returns the item for given id * * @param int $id * @return AccountHistoryData * @throws SPException * @throws \SP\Core\Exceptions\SPException */ public function getById($id) { return $this->accountHistoryRepository->getById($id); } /** * Obtiene el listado del histórico de una cuenta. * * @param $id * @return array|false Con los registros con id como clave y fecha - usuario como valor */ public function getHistoryForAccount($id) { return $this->accountHistoryRepository->getHistoryForAccount($id); } /** * @param $id * @return array */ public function getUsersByAccountId($id) { return $this->accountToUserRepository->getUsersByAccountId($id); } /** * @param $id * @return array */ public function getUserGroupsByAccountId($id) { return $this->accountToUserGroupRepository->getUserGroupsByAccountId($id); } /** * @param ItemSearchData $itemSearchData * @return mixed */ public function search(ItemSearchData $itemSearchData) { return $this->accountHistoryRepository->search($itemSearchData); } }