for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace linkprofit\AmoCRM\services;
use linkprofit\AmoCRM\entities\Authorization;
use linkprofit\AmoCRM\entities\EntityInterface;
use linkprofit\AmoCRM\RequestHandler;
class AuthorizationService implements ServiceInterface
{
/**
* @var RequestHandler
*/
protected $request;
* @var array
protected $fields;
* @var
protected $response;
* @var Authorization
protected $authorization;
* AuthorizationService constructor.
* @param RequestHandler $request
public function __construct(RequestHandler $request)
$this->request = $request;
}
* @param Authorization $authorization
public function add(EntityInterface $authorization)
if ($authorization instanceof Authorization) {
$this->authorization = $authorization;
* @return bool
public function authorize()
$this->composeFields();
$this->request->performRequest($this->getAuthLink(), $this->fields);
$this->response = $this->request->getResponse();
$this->response = $this->response['response'];
return $this->checkResponse();
protected function checkResponse()
if (isset($this->response['auth'])) {
return true;
return false;
* @return string
protected function getAuthLink()
return 'https://' . $this->request->getSubdomain() . '.amocrm.ru/private/api/auth.php?type=json';
* Fill fields for response
protected function composeFields()
$this->fields = $this->authorization->get();