diff --git a/src/Api/AbstractAlphaTrader.php b/src/Api/AbstractAlphaTrader.php deleted file mode 100644 index 1c1090f..0000000 --- a/src/Api/AbstractAlphaTrader.php +++ /dev/null @@ -1,189 +0,0 @@ -getTimestamp() * 1000) : ((int)$time * 1000)) ?: null; - } - - /** - * @return BankAccountController - */ - public function getBankAccountController() - { - return new BankAccountController($this->config, $this->jwt); - } - - /** - * @return CashTransferLogController - */ - public function getCashTransferLogController() - { - - return new CashTransferLogController($this->config, $this->jwt); - } - - /** - * @return CashGenerationController - */ - public function getCashGenerationController() - { - return new CashGenerationController($this->config, $this->jwt); - } - - /** - * @return ChatController - */ - public function getChatController() - { - return new ChatController($this->config, $this->jwt); - } - - /** - * @return UserAccountController - */ - public function getUserAccountController() - { - return new UserAccountController($this->config, $this->jwt); - } - - /** - * @return CompanyController - */ - public function getCompanyController() - { - return new CompanyController($this->config, $this->jwt); - } - - /** - * @return EventController - */ - public function getEventController() - { - return new EventController($this->config, $this->jwt); - } - - /** - * @return PortfolioController - */ - public function getPortfolioController() - { - return new PortfolioController($this->config, $this->jwt); - } - - /** - * @return ListingController - */ - public function getListingController() - { - return new ListingController($this->config, $this->jwt); - } - - /** - * @return SecurityOrderLogController - */ - public function getSecurityOrderLogController() - { - return new SecurityOrderLogController($this->config, $this->jwt); - } - - /** - * @return BondController - */ - public function getBondController() - { - return new BondController($this->config, $this->jwt); - } - - /** - * @return SystemBondController - */ - public function getSystemBondController() - { - return new SystemBondController($this->config, $this->jwt); - } - - /** - * @return BankingLicenseController - */ - public function getBankingLicenseController() - { - return new BankingLicenseController($this->config, $this->jwt); - } - - /** - * @return MainInterestRateController - */ - public function getMainInterestRateController() - { - return new MainInterestRateController($this->config, $this->jwt); - } - - /** - * @return CentralBankReservesController - */ - public function getCentralBankReservesController() - { - return new CentralBankReservesController($this->config, $this->jwt); - } - - /** - * @return NotificationsController - */ - public function getNotificationsController() - { - return new NotificationsController($this->config, $this->jwt); - } - - /** - * @return SecurityOrderController - */ - public function getSecurityOrderContrller() - { - return new SecurityOrderController($this->config, $this->jwt); - } - - /** - * @return VotingController - */ - public function getVotingController() - { - return new VotingController($this->config, $this->jwt); - } -} diff --git a/src/Api/AlphaTrader.php b/src/Api/AlphaTrader.php index 7d01d67..058e749 100644 --- a/src/Api/AlphaTrader.php +++ b/src/Api/AlphaTrader.php @@ -2,17 +2,38 @@ namespace Alphatrader\ApiBundle\Api; -use Alphatrader\ApiBundle\Model\Company; use Symfony\Component\HttpFoundation\Session\SessionInterface; /** * Class AlphaTrader * @package Alphatrader\ApiBundle\Api - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - * @SuppressWarnings(PHPMD.ExcessivePublicCount) */ -class AlphaTrader extends AbstractAlphaTrader +class AlphaTrader { + use Traits\BankAccountTrait; + use Traits\BankingLicenseTrait; + use Traits\BondTrait; + use Traits\CashGenerationTrait; + use Traits\CashTransferLogTrait; + use Traits\CentralBankReservesTrait; + use Traits\ChatTrait; + use Traits\CompanyTrait; + use Traits\EventsTrait; + use Traits\ListingTrait; + use Traits\MainInterestRateTrait; + use Traits\NotificationTrait; + use Traits\PortfolioTrait; + use Traits\SecurityOrderLogTrait; + use Traits\SecurityOrderTrait; + use Traits\SystemBondTrait; + use Traits\UserTrait; + use Traits\TimeStampTrait; + use Traits\VotingTrait; + + protected $config; + + protected $jwt; + /** * @param $config * @param SessionInterface $session @@ -25,612 +46,4 @@ public function __construct($config, SessionInterface $session = null, $jwt = nu $this->jwt = $session->get('_attoken') ? : $jwt; } } - - /** - * @return \Alphatrader\ApiBundle\Model\Bankaccount - */ - public function getBankAccount() - { - return $this->getBankAccountController()->getBankAccount(); - } - - /** - * @param \DateTime $startDate - * @param \DateTime $endDate - * @param null $senderBankAccId - * @param null $receiverBankAccId - * - * @return \Alphatrader\ApiBundle\Model\CashTransferLogEntry[] - */ - public function getCashTransferLogs( - \DateTime $startDate = null, - \DateTime $endDate = null, - $senderBankAccId = null, - $receiverBankAccId = null - ) { - $controller = $this->getCashTransferLogController(); - - return $controller->getCashTransferLogs( - $this->formatTimeStamp($startDate), - $this->formatTimeStamp($endDate), - $senderBankAccId, - $receiverBankAccId - ); - } - - /** - * @param $cashAmount - * - * @return \Alphatrader\ApiBundle\Model\BankAccount - */ - public function generateCash($cashAmount) - { - return $this->getCashGenerationController()->generateCash($cashAmount); - } - - /** - * @return \Alphatrader\ApiBundle\Model\Chats[] - */ - public function getChats() - { - return $this->getChatController()->getChats(); - } - - /** - * @param int $chatID - * - * @return \Alphatrader\ApiBundle\Model\Chats - */ - public function getChat($chatID) - { - return $this->getChatController()->getChat($chatID); - } - - /** - * @return \Alphatrader\ApiBundle\Model\UserAccount - */ - public function getCurrentUser() - { - return $this->getUserAccountController()->getCurrentUser(); - } - - /** - * @return \Alphatrader\ApiBundle\Model\UserAccount - */ - public function getUsers() - { - return $this->getUserAccountController()->getUsers(); - } - - /** - * @param $part - * - * @return \Alphatrader\ApiBundle\Model\UserAccount - */ - public function getUsersByNamePart($part) - { - return $this->getUserAccountController()->searchUsersByNamePart($part); - } - - /** - * @param string $username - * - * @return \Alphatrader\ApiBundle\Model\UserAccount - */ - public function getUserByUsername($username) - { - return $this->getUserAccountController()->getUserByUsername($username); - } - - /** - * @param bool $all - * @SuppressWarnings(PHPMD.BooleanArgumentFlag) - * - * @return Company[] - */ - public function getCompanies($all = true) - { - return $this->getCompanyController()->getCompanies($all); - } - - /** - * @param int $companyID - * - * @return Company - */ - public function getCompany($companyID) - { - return $this->getCompanyController()->getCompany($companyID); - } - - /** - * @param int $userId - * - * @return Company[] - */ - public function getCompaniesByUserId($userId) - { - $user = $this->getUserAccountController()->getUserById($userId); - - return $this->getCompanyController()->getCompanyByUserId($user); - } - - /** - * @param string $username - * - * @return Company[] - */ - public function getCompaniesByUserName($username) - { - return $this->getCompanyController()->getCompanyByUserName($username); - } - - /** - * @param int $secAccId - * - * @return Company - */ - public function getCompanyBySecurityAccountId($secAccId) - { - return $this->getCompanyController()->getCompanyBySecurityAccountId($secAccId); - } - - /** - * @param int $secIdent - * - * @return Company - */ - public function getCompanyBySecurityIdentifier($secIdent) - { - return $this->getCompanyController()->getCompanyBySecurityIdentifier($secIdent); - } - - /** - * @param int $companyId - * - * @return \Alphatrader\ApiBundle\Model\CompanyProfile - */ - public function getCompanyProfile($companyId) - { - return $this->getCompanyController()->getCompanyProfile($companyId); - } - - /** - * @param $name - * @param $cashDeposit - * - * @return Company - */ - public function createCompany($name, $cashDeposit) - { - return $this->getCompanyController()->createCompany($name, $cashDeposit); - } - - /** - * @param $companyId - * @param $logoUrl - * - * @return Company|\Alphatrader\ApiBundle\Model\Error - */ - public function addLogoToCompany($companyId,$logoUrl){ - return $this->getCompanyController()->addLogo($companyId,$logoUrl); - } - - /** - * @param $companyId - * @return Company|\Alphatrader\ApiBundle\Model\Error - */ - public function removeLogoFromCompany($companyId){ - return $this->getCompanyController()->removeLogo($companyId); - } - - /** - * @param $username - * @param $email - * @param $password - * - * @return \Alphatrader\ApiBundle\Model\UserAccount - */ - public function registerUser($username, $email, $password) - { - return $this->getUserAccountController()->registerUser($username, $email, $password); - } - - /** - * @param $username - * @param $password - * - * @return mixed - */ - public function getUserJwt($username, $password) - { - return $this->getUserAccountController()->getUserToken($username, $password); - } - - /** - * @param $username - * - * @return \Alphatrader\ApiBundle\Model\UserProfile - */ - public function getUserProfile($username) - { - return $this->getUserAccountController()->getUserProfile($username); - } - - /** - * @param \DateTime $afterDate - * - * @return \Alphatrader\ApiBundle\Model\Events[] - */ - public function getEvents(\DateTime $afterDate = null) - { - return $this->getEventController()->getEvents($this->formatTimeStamp($afterDate)); - } - - /** - * @param $realms - * @param \DateTime $afterDate - * - * @return \Alphatrader\ApiBundle\Model\Events[] - */ - public function getEventsByRealms($realms, \DateTime $afterDate = null) - { - return $this->getEventController()->searchEvents($realms, $this->formatTimeStamp($afterDate)); - } - - /** - * @param $eventtype - * @param string $realms - * @param \DateTime $afterDate - * - * @return \Alphatrader\ApiBundle\Model\Events[] - */ - public function getEventsByType($eventtype, $realms = '', \DateTime $afterDate = null) - { - return $this->getEventController()->searchEventsByType($eventtype, $realms, $this->formatTimeStamp($afterDate)); - } - - /** - * @param $secAccId - * - * @return \Alphatrader\ApiBundle\Model\Portfolio - */ - public function getPortfolio($secAccId) - { - return $this->getPortfolioController()->getPortfolio($secAccId); - } - - /** - * @param $secIdentPart - * - * @return \Alphatrader\ApiBundle\Model\Listing[] - */ - public function getListing($secIdentPart) - { - return $this->getListingController()->getListing($secIdentPart); - } - - /** - * @param $securityIdent - * - * @return \Alphatrader\ApiBundle\Model\ListingProfile - */ - public function getListingProfile($securityIdent) - { - return $this->getListingController()->getProfile($securityIdent); - } - - /** - * @param string $securityIdentifier - * @param \DateTime $startDate - * @param \DateTime $endDate - * @param string $buyerSecAccId - * @param string $sellerSecAccId - * - * @return \Alphatrader\ApiBundle\Model\SecurityOrderLogEntry[] - */ - public function getSecurityOrderLogs( - $securityIdentifier = '', - \DateTime $startDate = null, - \DateTime $endDate = null, - $buyerSecAccId = '', - $sellerSecAccId = '' - ) { - $controller = $this->getSecurityOrderLogController(); - - return $controller->getSecurityOrderLogs( - $securityIdentifier, - $this->formatTimeStamp($startDate), - $this->formatTimeStamp($endDate), - $buyerSecAccId, - $sellerSecAccId - ); - } - - /** - * @param Company $company - * @param $numberOfBonds - * @param $faceValue - * @param $interestRate - * @param \DateTime $maturityDate - * - * @return \Alphatrader\ApiBundle\Model\Bond - */ - public function createBond( - Company $company, - $numberOfBonds, - $faceValue, - $interestRate, - \DateTime $maturityDate - ) { - $controller = $this->getBondController(); - - return $controller->createBond( - $company, - $numberOfBonds, - $faceValue, - $interestRate, - $this->formatTimeStamp($maturityDate) - ); - } - - /** - * @return array - */ - public function repayBond() - { - return $this->getBondController()->repayBond(); - } - - /** - * @param $bondid - * - * @return \Alphatrader\ApiBundle\Model\Bond - */ - public function getBond($bondid) - { - return $this->getBondController()->getBond($bondid); - } - - /** - * @return \Alphatrader\ApiBundle\Model\Bond[]|\Alphatrader\ApiBundle\Model\Error - */ - public function getBonds() - { - return $this->getBondController()->getBonds(); - } - - /** - * @param Company $company - * @param $numberOfBonds - * - * @return Listing - */ - public function createSystemBond(Company $company, $numberOfBonds) - { - $controller = $this->getSystemBondController(); - - return $controller->createBond( - $company, - $numberOfBonds - ); - } - - /** - * @return array - */ - public function repaySystemBond() - { - return $this->getSystemBondController()->repayBond(); - } - - /** - * @param $bondid - * - * @return \Alphatrader\ApiBundle\Model\Bond - */ - public function getSystemBond($bondid) - { - return $this->getSystemBondController()->getBond($bondid); - } - - /** - * @param Company $company - * - * @return \Alphatrader\ApiBundle\Model\BankingLicense - */ - public function createBankingLicense(Company $company) - { - return $this->getBankingLicenseController()->createBankingLicense($company); - } - - /** - * @param Company $company - * - * @return \Alphatrader\ApiBundle\Model\BankingLicense - */ - public function getBankingLicense(Company $company) - { - return $this->getBankingLicenseController()->getBankingLicense($company); - } - - /** - * @return \Alphatrader\ApiBundle\Model\MainInterestRate[] - */ - public function getMainInterestRate() - { - return $this->getMainInterestRateController()->getMainInterestRate(); - } - - /** - * @return \Alphatrader\ApiBundle\Model\MainInterestRate - */ - public function getLatestMainInterestRate() - { - return $this->getMainInterestRateController()->getLatestMainInterestRate(); - } - - /** - * @param $reserveid - * - * @return \Alphatrader\ApiBundle\Model\CentralBankReserve - */ - public function getCentralBankReservesById($reserveid) - { - return $this->getCentralBankReservesController()->getReserveById($reserveid); - } - - /** - * @param Company $company - * @param $cashAmount - * - * @return \Alphatrader\ApiBundle\Model\CentralBankReserve - */ - public function setCompanyCentralBankReserves(Company $company, $cashAmount) - { - return $this->getCentralBankReservesController()->increaseReserves($company, $cashAmount); - } - - /** - * @return mixed - */ - public function setNotificationsasRead() - { - return $this->getNotificationsController()->markAsRead(); - } - - /** - * @return \Alphatrader\ApiBundle\Model\Notifications[] - */ - public function getNotifications() - { - return $this->getNotificationsController()->getNotifications(); - } - - /** - * @return \Alphatrader\ApiBundle\Model\Notifications[]|\Alphatrader\ApiBundle\Model\Error - */ - public function getUnreadNotifications() - { - return $this->getNotificationsController()->getUnreadNotifications(); - } - - /** - * @param $secIdent - * - * @return \Alphatrader\ApiBundle\Model\SecurityOrder - */ - public function getOrder($secIdent) - { - return $this->getSecurityOrderContrller()->getSecurityOrder($secIdent); - } - - /** - * @param $owner - * @param $secIdent - * @param $action - * @param $type - * @param $price - * @param $numberOfShares - * @param $counterparty - * - * @return \Alphatrader\ApiBundle\Model\SecurityOrder - */ - public function createOrder($owner, $secIdent, $action, $type, $price, $numberOfShares, $counterparty) - { - return $this->getSecurityOrderContrller()->createSecurityOrder( - $owner, - $secIdent, - $action, - $type, - $price, - $numberOfShares, - $counterparty - ); - } - - /** - * @return \Doctrine\Common\Collections\ArrayCollection - */ - public function getMyPolls() - { - return $this->getVotingController()->getMyPolls(); - } - - /** - * @return \Doctrine\Common\Collections\ArrayCollection - */ - public function getAllKnownPolls() - { - return $this->getVotingController()->getAllKnownPolls(); - } - - /** - * @param Company $company - * - * @return \Alphatrader\ApiBundle\Model\AbstractPoll - */ - public function setCompanyCashoutPoll(Company $company) - { - return $this->getVotingController()->setCompanyCashoutPoll($company); - } - - /** - * @param Company $company - * @param $dailyWage - * - * @return \Alphatrader\ApiBundle\Model\AbstractPoll - */ - public function setCompanyEmployCeo(Company $company, $dailyWage) - { - return $this->getVotingController()->setCompanyEmployCeo($company, $dailyWage); - } - - /** - * @param Company $company - * - * @return \Alphatrader\ApiBundle\Model\AbstractPoll - */ - public function setCompanyLiquidation(Company $company) - { - return $this->getVotingController()->setCompanyLiquidation($company); - } - - /** - * @param $pollid - * - * @return \Alphatrader\ApiBundle\Model\AbstractPoll - */ - public function getPoll($pollid) - { - return $this->getVotingController()->getPoll($pollid); - } - - /** - * @param $pollid - */ - public function setExecutePoll($pollid) - { - $this->getVotingController()->executePoll($pollid); - } - - /** - * @param $pollid - */ - public function setdeletePoll($pollid) - { - $this->getVotingController()->deletePoll($pollid); - } - - /** - * @param $pollid - * @param $voices - * @param $votingType - * - * @return AbstractPoll - */ - public function setvotePoll($pollid, $voices, $votingType) - { - return $this->getVotingController()->votePoll($pollid, $voices, $votingType); - } } diff --git a/src/Api/Methods/CompanyController.php b/src/Api/Methods/CompanyController.php index 5316aa9..cecd564 100644 --- a/src/Api/Methods/CompanyController.php +++ b/src/Api/Methods/CompanyController.php @@ -218,11 +218,12 @@ public function createCompany($name, $cashDeposit) /** * @param $companyId * @param $logoUrl - * + * * @return Company|Error */ - public function addLogo($companyId,$logoUrl){ - $data = $this->put('companies/logo/'.$companyId,['companyId' => $companyId,'logoUrl' => $logoUrl]); + public function addLogo($companyId, $logoUrl) + { + $data = $this->put('companies/logo/'.$companyId, ['companyId' => $companyId,'logoUrl' => $logoUrl]); /** @var Company $oResult */ $oResult = $this->getSerializer()->deserialize( $data, @@ -246,20 +247,20 @@ public function addLogo($companyId,$logoUrl){ */ public function removeLogo($companyId) { - $data = $this->delete('companies/logo/'.$companyId,['companyId' => $companyId]); + $data = $this->delete('companies/logo/'.$companyId, ['companyId' => $companyId]); /** @var Company $oResult */ $oResult = $this->getSerializer()->deserialize( $data, 'Alphatrader\ApiBundle\Model\Company', 'json' ); - if ($oResult->getId() == null) { - $oResult = $this->getSerializer()->deserialize( - $data, - 'Alphatrader\ApiBundle\Model\Error', - 'json' - ); - } + if ($oResult->getId() == null) { + $oResult = $this->getSerializer()->deserialize( + $data, + 'Alphatrader\ApiBundle\Model\Error', + 'json' + ); + } return $oResult; } } diff --git a/src/Api/Methods/UserAccountController.php b/src/Api/Methods/UserAccountController.php index a751732..9d8940e 100644 --- a/src/Api/Methods/UserAccountController.php +++ b/src/Api/Methods/UserAccountController.php @@ -34,7 +34,11 @@ public function getCurrentUser() public function getUsers() { $data = $this->get('users'); - $oResult = $this->getSerializer()->deserialize($data, 'Alphatrader\ApiBundle\Model\UserAccount', 'json'); + $oResult = $this->getSerializer()->deserialize( + $data, + 'ArrayCollection', + 'json' + ); return $oResult; } diff --git a/src/Api/Traits/BankAccountTrait.php b/src/Api/Traits/BankAccountTrait.php new file mode 100644 index 0000000..405bfc0 --- /dev/null +++ b/src/Api/Traits/BankAccountTrait.php @@ -0,0 +1,29 @@ +getBankAccountController()->getBankAccount(); + } + + /** + * @return BankAccountController + */ + public function getBankAccountController() + { + return new BankAccountController($this->config, $this->jwt); + } +} diff --git a/src/Api/Traits/BankingLicenseTrait.php b/src/Api/Traits/BankingLicenseTrait.php new file mode 100644 index 0000000..a3b4040 --- /dev/null +++ b/src/Api/Traits/BankingLicenseTrait.php @@ -0,0 +1,42 @@ +getBankingLicenseController()->createBankingLicense($company); + } + + /** + * @param Company $company + * + * @return \Alphatrader\ApiBundle\Model\BankingLicense + */ + public function getBankingLicense(Company $company) + { + return $this->getBankingLicenseController()->getBankingLicense($company); + } + + /** + * @return BankingLicenseController + */ + public function getBankingLicenseController() + { + return new BankingLicenseController($this->config, $this->jwt); + } +} diff --git a/src/Api/Traits/BondTrait.php b/src/Api/Traits/BondTrait.php new file mode 100644 index 0000000..23bf0e5 --- /dev/null +++ b/src/Api/Traits/BondTrait.php @@ -0,0 +1,74 @@ +getBondController(); + + return $controller->createBond( + $company, + $numberOfBonds, + $faceValue, + $interestRate, + $this->formatTimeStamp($maturityDate) + ); + } + + /** + * @return array + */ + public function repayBond() + { + return $this->getBondController()->repayBond(); + } + + /** + * @param $bondid + * + * @return \Alphatrader\ApiBundle\Model\Bond + */ + public function getBond($bondid) + { + return $this->getBondController()->getBond($bondid); + } + + /** + * @return \Alphatrader\ApiBundle\Model\Bond[]|\Alphatrader\ApiBundle\Model\Error + */ + public function getBonds() + { + return $this->getBondController()->getBonds(); + } + + /** + * @return BondController + */ + public function getBondController() + { + return new BondController($this->config, $this->jwt); + } +} diff --git a/src/Api/Traits/CashGenerationTrait.php b/src/Api/Traits/CashGenerationTrait.php new file mode 100644 index 0000000..949fcc6 --- /dev/null +++ b/src/Api/Traits/CashGenerationTrait.php @@ -0,0 +1,31 @@ +getCashGenerationController()->generateCash($cashAmount); + } + + /** + * @return CashGenerationController + */ + public function getCashGenerationController() + { + return new CashGenerationController($this->config, $this->jwt); + } +} diff --git a/src/Api/Traits/CashTransferLogTrait.php b/src/Api/Traits/CashTransferLogTrait.php new file mode 100644 index 0000000..a13e1b0 --- /dev/null +++ b/src/Api/Traits/CashTransferLogTrait.php @@ -0,0 +1,46 @@ +getCashTransferLogController(); + + return $controller->getCashTransferLogs( + $this->formatTimeStamp($startDate), + $this->formatTimeStamp($endDate), + $senderBankAccId, + $receiverBankAccId + ); + } + + /** + * @return CashTransferLogController + */ + public function getCashTransferLogController() + { + + return new CashTransferLogController($this->config, $this->jwt); + } +} diff --git a/src/Api/Traits/CentralBankReservesTrait.php b/src/Api/Traits/CentralBankReservesTrait.php new file mode 100644 index 0000000..46229fd --- /dev/null +++ b/src/Api/Traits/CentralBankReservesTrait.php @@ -0,0 +1,43 @@ +getCentralBankReservesController()->getReserveById($reserveid); + } + + /** + * @param Company $company + * @param $cashAmount + * + * @return \Alphatrader\ApiBundle\Model\CentralBankReserve + */ + public function setCompanyCentralBankReserves(Company $company, $cashAmount) + { + return $this->getCentralBankReservesController()->increaseReserves($company, $cashAmount); + } + + /** + * @return CentralBankReservesController + */ + public function getCentralBankReservesController() + { + return new CentralBankReservesController($this->config, $this->jwt); + } +} diff --git a/src/Api/Traits/ChatTrait.php b/src/Api/Traits/ChatTrait.php new file mode 100644 index 0000000..c9707a8 --- /dev/null +++ b/src/Api/Traits/ChatTrait.php @@ -0,0 +1,39 @@ +getChatController()->getChats(); + } + + /** + * @param int $chatID + * + * @return \Alphatrader\ApiBundle\Model\Chats + */ + public function getChat($chatID) + { + return $this->getChatController()->getChat($chatID); + } + + /** + * @return ChatController + */ + public function getChatController() + { + return new ChatController($this->config, $this->jwt); + } +} diff --git a/src/Api/Traits/CompanyTrait.php b/src/Api/Traits/CompanyTrait.php new file mode 100644 index 0000000..f7a46a5 --- /dev/null +++ b/src/Api/Traits/CompanyTrait.php @@ -0,0 +1,127 @@ +getCompanyController()->getCompanies($all); + } + + /** + * @param int $companyID + * + * @return Company + */ + public function getCompany($companyID) + { + return $this->getCompanyController()->getCompany($companyID); + } + + /** + * @param int $userId + * + * @return Company[] + */ + public function getCompaniesByUserId($userId) + { + $user = $this->getUserAccountController()->getUserById($userId); + + return $this->getCompanyController()->getCompanyByUserId($user); + } + + /** + * @param string $username + * + * @return Company[] + */ + public function getCompaniesByUserName($username) + { + return $this->getCompanyController()->getCompanyByUserName($username); + } + + /** + * @param int $secAccId + * + * @return Company + */ + public function getCompanyBySecurityAccountId($secAccId) + { + return $this->getCompanyController()->getCompanyBySecurityAccountId($secAccId); + } + + /** + * @param int $secIdent + * + * @return Company + */ + public function getCompanyBySecurityIdentifier($secIdent) + { + return $this->getCompanyController()->getCompanyBySecurityIdentifier($secIdent); + } + + /** + * @param int $companyId + * + * @return \Alphatrader\ApiBundle\Model\CompanyProfile + */ + public function getCompanyProfile($companyId) + { + return $this->getCompanyController()->getCompanyProfile($companyId); + } + + /** + * @param $name + * @param $cashDeposit + * + * @return Company + */ + public function createCompany($name, $cashDeposit) + { + return $this->getCompanyController()->createCompany($name, $cashDeposit); + } + + /** + * @param $companyId + * @param $logoUrl + * + * @return Company|\Alphatrader\ApiBundle\Model\Error + */ + public function addLogoToCompany($companyId, $logoUrl) + { + return $this->getCompanyController()->addLogo($companyId, $logoUrl); + } + + /** + * @param $companyId + * @return Company|\Alphatrader\ApiBundle\Model\Error + */ + public function removeLogoFromCompany($companyId) + { + return $this->getCompanyController()->removeLogo($companyId); + } + + + /** + * @return CompanyController + */ + public function getCompanyController() + { + return new CompanyController($this->config, $this->jwt); + } +} diff --git a/src/Api/Traits/EventsTrait.php b/src/Api/Traits/EventsTrait.php new file mode 100644 index 0000000..99ef2ec --- /dev/null +++ b/src/Api/Traits/EventsTrait.php @@ -0,0 +1,54 @@ +getEventController()->getEvents($this->formatTimeStamp($afterDate)); + } + + /** + * @param $realms + * @param \DateTime $afterDate + * + * @return \Alphatrader\ApiBundle\Model\Events[] + */ + public function getEventsByRealms($realms, \DateTime $afterDate = null) + { + return $this->getEventController()->searchEvents($realms, $this->formatTimeStamp($afterDate)); + } + + /** + * @param $eventtype + * @param string $realms + * @param \DateTime $afterDate + * + * @return \Alphatrader\ApiBundle\Model\Events[] + */ + public function getEventsByType($eventtype, $realms = '', \DateTime $afterDate = null) + { + return $this->getEventController()->searchEventsByType($eventtype, $realms, $this->formatTimeStamp($afterDate)); + } + + /** + * @return EventController + */ + public function getEventController() + { + return new EventController($this->config, $this->jwt); + } +} diff --git a/src/Api/Traits/ListingTrait.php b/src/Api/Traits/ListingTrait.php new file mode 100644 index 0000000..69f70e3 --- /dev/null +++ b/src/Api/Traits/ListingTrait.php @@ -0,0 +1,41 @@ +getListingController()->getListing($secIdentPart); + } + + /** + * @param $securityIdent + * + * @return \Alphatrader\ApiBundle\Model\ListingProfile + */ + public function getListingProfile($securityIdent) + { + return $this->getListingController()->getProfile($securityIdent); + } + + /** + * @return ListingController + */ + public function getListingController() + { + return new ListingController($this->config, $this->jwt); + } +} diff --git a/src/Api/Traits/MainInterestRateTrait.php b/src/Api/Traits/MainInterestRateTrait.php new file mode 100644 index 0000000..fce8906 --- /dev/null +++ b/src/Api/Traits/MainInterestRateTrait.php @@ -0,0 +1,37 @@ +getMainInterestRateController()->getMainInterestRate(); + } + + /** + * @return \Alphatrader\ApiBundle\Model\MainInterestRate + */ + public function getLatestMainInterestRate() + { + return $this->getMainInterestRateController()->getLatestMainInterestRate(); + } + + /** + * @return MainInterestRateController + */ + public function getMainInterestRateController() + { + return new MainInterestRateController($this->config, $this->jwt); + } +} diff --git a/src/Api/Traits/NotificationTrait.php b/src/Api/Traits/NotificationTrait.php new file mode 100644 index 0000000..0b7ef20 --- /dev/null +++ b/src/Api/Traits/NotificationTrait.php @@ -0,0 +1,45 @@ +getNotificationsController()->markAsRead(); + } + + /** + * @return \Alphatrader\ApiBundle\Model\Notifications[] + */ + public function getNotifications() + { + return $this->getNotificationsController()->getNotifications(); + } + + /** + * @return \Alphatrader\ApiBundle\Model\Notifications[]|\Alphatrader\ApiBundle\Model\Error + */ + public function getUnreadNotifications() + { + return $this->getNotificationsController()->getUnreadNotifications(); + } + + /** + * @return NotificationsController + */ + public function getNotificationsController() + { + return new NotificationsController($this->config, $this->jwt); + } +} diff --git a/src/Api/Traits/PortfolioTrait.php b/src/Api/Traits/PortfolioTrait.php new file mode 100644 index 0000000..9975c91 --- /dev/null +++ b/src/Api/Traits/PortfolioTrait.php @@ -0,0 +1,31 @@ +getPortfolioController()->getPortfolio($secAccId); + } + + /** + * @return PortfolioController + */ + public function getPortfolioController() + { + return new PortfolioController($this->config, $this->jwt); + } +} diff --git a/src/Api/Traits/SecurityOrderLogTrait.php b/src/Api/Traits/SecurityOrderLogTrait.php new file mode 100644 index 0000000..49d47fb --- /dev/null +++ b/src/Api/Traits/SecurityOrderLogTrait.php @@ -0,0 +1,48 @@ +getSecurityOrderLogController(); + + return $controller->getSecurityOrderLogs( + $securityIdentifier, + $this->formatTimeStamp($startDate), + $this->formatTimeStamp($endDate), + $buyerSecAccId, + $sellerSecAccId + ); + } + + /** + * @return SecurityOrderLogController + */ + public function getSecurityOrderLogController() + { + return new SecurityOrderLogController($this->config, $this->jwt); + } +} diff --git a/src/Api/Traits/SecurityOrderTrait.php b/src/Api/Traits/SecurityOrderTrait.php new file mode 100644 index 0000000..76a7d32 --- /dev/null +++ b/src/Api/Traits/SecurityOrderTrait.php @@ -0,0 +1,55 @@ +getSecurityOrderController()->getSecurityOrder($secIdent); + } + + /** + * @param $owner + * @param $secIdent + * @param $action + * @param $type + * @param $price + * @param $numberOfShares + * @param $counterparty + * + * @return \Alphatrader\ApiBundle\Model\SecurityOrder + */ + public function createOrder($owner, $secIdent, $action, $type, $price, $numberOfShares, $counterparty) + { + return $this->getSecurityOrderController()->createSecurityOrder( + $owner, + $secIdent, + $action, + $type, + $price, + $numberOfShares, + $counterparty + ); + } + + /** + * @return SecurityOrderController + */ + public function getSecurityOrderController() + { + return new SecurityOrderController($this->config, $this->jwt); + } +} diff --git a/src/Api/Traits/SystemBondTrait.php b/src/Api/Traits/SystemBondTrait.php new file mode 100644 index 0000000..f3fe1c8 --- /dev/null +++ b/src/Api/Traits/SystemBondTrait.php @@ -0,0 +1,56 @@ +getSystemBondController(); + + return $controller->createBond( + $company, + $numberOfBonds + ); + } + + /** + * @return array + */ + public function repaySystemBond() + { + return $this->getSystemBondController()->repayBond(); + } + + /** + * @param $bondid + * + * @return \Alphatrader\ApiBundle\Model\Bond + */ + public function getSystemBond($bondid) + { + return $this->getSystemBondController()->getBond($bondid); + } + + /** + * @return SystemBondController + */ + public function getSystemBondController() + { + return new SystemBondController($this->config, $this->jwt); + } +} diff --git a/src/Api/Traits/TimeStampTrait.php b/src/Api/Traits/TimeStampTrait.php new file mode 100644 index 0000000..038983e --- /dev/null +++ b/src/Api/Traits/TimeStampTrait.php @@ -0,0 +1,21 @@ +getTimestamp() * 1000) : ((int)$time * 1000)) ?: null; + } +} diff --git a/src/Api/Traits/UserTrait.php b/src/Api/Traits/UserTrait.php new file mode 100644 index 0000000..5abcfa5 --- /dev/null +++ b/src/Api/Traits/UserTrait.php @@ -0,0 +1,90 @@ +getUserAccountController()->getCurrentUser(); + } + + /** + * @return \Alphatrader\ApiBundle\Model\UserAccount + */ + public function getUsers() + { + return $this->getUserAccountController()->getUsers(); + } + + /** + * @param $part + * + * @return \Alphatrader\ApiBundle\Model\UserAccount + */ + public function getUsersByNamePart($part) + { + return $this->getUserAccountController()->searchUsersByNamePart($part); + } + + /** + * @param string $username + * + * @return \Alphatrader\ApiBundle\Model\UserAccount + */ + public function getUserByUsername($username) + { + return $this->getUserAccountController()->getUserByUsername($username); + } + + /** + * @param $username + * @param $email + * @param $password + * + * @return \Alphatrader\ApiBundle\Model\UserAccount + */ + public function registerUser($username, $email, $password) + { + return $this->getUserAccountController()->registerUser($username, $email, $password); + } + + /** + * @param $username + * @param $password + * + * @return mixed + */ + public function getUserJwt($username, $password) + { + return $this->getUserAccountController()->getUserToken($username, $password); + } + + /** + * @param $username + * + * @return \Alphatrader\ApiBundle\Model\UserProfile + */ + public function getUserProfile($username) + { + return $this->getUserAccountController()->getUserProfile($username); + } + + /** + * @return UserAccountController + */ + public function getUserAccountController() + { + return new UserAccountController($this->config, $this->jwt); + } +} diff --git a/src/Api/Traits/VotingTrait.php b/src/Api/Traits/VotingTrait.php new file mode 100644 index 0000000..724a67e --- /dev/null +++ b/src/Api/Traits/VotingTrait.php @@ -0,0 +1,108 @@ +getVotingController()->getMyPolls(); + } + + /** + * @return \Doctrine\Common\Collections\ArrayCollection + */ + public function getAllKnownPolls() + { + return $this->getVotingController()->getAllKnownPolls(); + } + + /** + * @param Company $company + * + * @return \Alphatrader\ApiBundle\Model\AbstractPoll + */ + public function setCompanyCashoutPoll(Company $company) + { + return $this->getVotingController()->setCompanyCashoutPoll($company); + } + + /** + * @param Company $company + * @param $dailyWage + * + * @return \Alphatrader\ApiBundle\Model\AbstractPoll + */ + public function setCompanyEmployCeo(Company $company, $dailyWage) + { + return $this->getVotingController()->setCompanyEmployCeo($company, $dailyWage); + } + + /** + * @param Company $company + * + * @return \Alphatrader\ApiBundle\Model\AbstractPoll + */ + public function setCompanyLiquidation(Company $company) + { + return $this->getVotingController()->setCompanyLiquidation($company); + } + + /** + * @param $pollid + * + * @return \Alphatrader\ApiBundle\Model\AbstractPoll + */ + public function getPoll($pollid) + { + return $this->getVotingController()->getPoll($pollid); + } + + /** + * @param $pollid + */ + public function setExecutePoll($pollid) + { + $this->getVotingController()->executePoll($pollid); + } + + /** + * @param $pollid + */ + public function setdeletePoll($pollid) + { + $this->getVotingController()->deletePoll($pollid); + } + + /** + * @param $pollid + * @param $voices + * @param $votingType + * + * @return AbstractPoll + */ + public function setvotePoll($pollid, $voices, $votingType) + { + return $this->getVotingController()->votePoll($pollid, $voices, $votingType); + } + + /** + * @return VotingController + */ + public function getVotingController() + { + return new VotingController($this->config, $this->jwt); + } +} diff --git a/src/Model/UserAccount.php b/src/Model/UserAccount.php index 84fc878..7b35804 100644 --- a/src/Model/UserAccount.php +++ b/src/Model/UserAccount.php @@ -5,11 +5,11 @@ use JMS\Serializer\Annotation; /** - * Class Bankaccounts + * Class UserAccount * @package Alphatrader\ApiBundle\Model * @Annotation\ExclusionPolicy("none") */ -class Useraccount +class UserAccount { /** @@ -38,6 +38,12 @@ class Useraccount */ private $username; + /** + * @Annotation\Type("string") + * @Annotation\SerializedName("gravatarHash") + */ + private $gravatarHash; + /** * @return mixed */ @@ -101,4 +107,20 @@ public function setUsername($username) { $this->username = $username; } + + /** + * @return mixed + */ + public function getGravatarHash() + { + return $this->gravatarHash; + } + + /** + * @param mixed $gravatarHash + */ + public function setGravatarHash($gravatarHash) + { + $this->gravatarHash = $gravatarHash; + } } diff --git a/src/Model/UserAccounts.php b/src/Model/UserAccounts.php index 1c138d1..38da67a 100644 --- a/src/Model/UserAccounts.php +++ b/src/Model/UserAccounts.php @@ -5,11 +5,11 @@ use JMS\Serializer\Annotation; /** - * Class Bankaccounts + * Class UserAccounts * @package Alphatrader\ApiBundle\Model * @Annotation\ExclusionPolicy("none") */ -class Useraccounts +class UserAccounts { /**