. */ namespace SP\Services\Account; use SP\Core\Exceptions\QueryException; use SP\Core\Exceptions\SPException; use SP\DataModel\AccountHistoryData; use SP\DataModel\ItemData; use SP\DataModel\ItemSearchData; use SP\Repositories\Account\AccountHistoryRepository; use SP\Repositories\Account\AccountToUserGroupRepository; use SP\Repositories\Account\AccountToUserRepository; use SP\Services\Service; /** * Class AccountHistoryService * * @package SP\Services\Account */ class AccountHistoryService extends Service { /** * @var AccountHistoryRepository */ protected $accountHistoryRepository; /** * @var AccountToUserGroupRepository */ protected $accountToUserGroupRepository; /** * @var AccountToUserRepository */ protected $accountToUserRepository; /** * @throws \Psr\Container\ContainerExceptionInterface * @throws \Psr\Container\NotFoundExceptionInterface */ public function initialize() { $this->accountHistoryRepository = $this->dic->get(AccountHistoryRepository::class); $this->accountToUserRepository = $this->dic->get(AccountToUserRepository::class); $this->accountToUserGroupRepository = $this->dic->get(AccountToUserGroupRepository::class); } /** * 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 ItemData[] */ public function getUsersByAccountId($id) { return $this->accountToUserRepository->getUsersByAccountId($id); } /** * @param $id * @return ItemData[] */ public function getUserGroupsByAccountId($id) { return $this->accountToUserGroupRepository->getUserGroupsByAccountId($id); } /** * @param ItemSearchData $itemSearchData * @return mixed */ public function search(ItemSearchData $itemSearchData) { return $this->accountHistoryRepository->search($itemSearchData); } /** * Crea una nueva cuenta en la BBDD * * @param array $itemData ['id' => , 'isModify' => ,'isDelete' => , 'masterPassHash' => ] * @return bool * @throws QueryException * @throws \SP\Core\Exceptions\ConstraintException * @throws \SP\Core\Exceptions\QueryException */ public function create($itemData) { return $this->accountHistoryRepository->create($itemData); } /** * @return array */ public function getAccountsPassData() { return $this->accountHistoryRepository->getAccountsPassData(); } /** * @param AccountPasswordRequest $accountRequest * @return bool * @throws SPException * @throws \SP\Core\Exceptions\ConstraintException */ public function updatePasswordMasterPass(AccountPasswordRequest $accountRequest) { return $this->accountHistoryRepository->updatePassword($accountRequest); } }