247a7948 by Aleksandr Korzhenko

Merge branch 'protected' into 'master'

protected

See merge request !1
2 parents 9b36df06 4216c75a
......@@ -22,12 +22,12 @@ use Psr\Http\Message\ResponseInterface;
*/
abstract class ImmoScoutAPI extends GuzzleClient
{
private $consumerKey;
private $consumerKeySecret;
private $client = null;
protected $consumerKey;
protected $consumerKeySecret;
protected $client = null;
public $history = null;
private $user = 'me';
private $isSandbox = true;
protected $user = 'me';
protected $isSandbox = true;
/**
* should save the request token with tokenname + secret, the token can be temporarily saved within a session
......@@ -72,7 +72,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
*
* @return void
*/
private function validateToken($tokenArray)
protected function validateToken($tokenArray)
{
if (!is_array($tokenArray)) {
throw new InvalidTokenException('restored Token is not an Array need to be of the form [token, token_secret]');
......@@ -82,7 +82,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
}
}
private function getValidatedRequestToken()
protected function getValidatedRequestToken()
{
$token = $this->restoreRequestToken();
$this->validateToken($token);
......@@ -90,7 +90,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
return $token;
}
private function getValidatedAccessToken()
protected function getValidatedAccessToken()
{
$token = static::restoreAccessToken();
$this->validateToken($token);
......@@ -193,7 +193,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
*
* @return string base url
*/
private function getBaseUrl()
protected function getBaseUrl()
{
$domain = $this->getDomain();
......@@ -205,7 +205,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
*
* @return string current url
*/
private static function getSelfURI()
protected static function getSelfURI()
{
if (!isset($_SERVER) || !isset($_SERVER['HTTP_HOST']) || !isset($_SERVER['REQUEST_URI'])) {
throw new \Exception("coudn't detect request uri for callback (please specify one)");
......@@ -240,7 +240,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
*
* @return ResponseInterface
*/
private function callOAuth($uri, $oAuthData)
protected function callOAuth($uri, $oAuthData)
{
$oAuthData['consumer_key'] = $this->consumerKey;
$oAuthData['consumer_secret'] = $this->consumerKeySecret;
......@@ -267,7 +267,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
*
* @return void
*/
private function requestRequestToken($callback)
protected function requestRequestToken($callback)
{
try {
$res = static::callOAuth('/restapi/security/oauth/request_token', [
......@@ -292,7 +292,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
*
* @return void
*/
private function requestAccessToken($verifier)
protected function requestAccessToken($verifier)
{
$requestToken = $this->getValidatedRequestToken();
try {
......@@ -368,7 +368,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
*
* @return string url
*/
private function getUrl($methodUri, $withUser = true)
protected function getUrl($methodUri, $withUser = true)
{
$url = $this->getBaseUrl();
$path = 'api/offer/v1.0/';
......@@ -394,7 +394,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
*
* @return array message array
*/
private function parseMessages($res)
protected function parseMessages($res)
{
$return = [
'parsed' => [],
......@@ -488,7 +488,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
*
* @return void
*/
private function call($method, $methodUri, $data = [], $withUser = false)
protected function call($method, $methodUri, $data = [], $withUser = false)
{
$methodUri = $this->getUrl($methodUri, $withUser);
try {
......@@ -501,7 +501,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
}
}
private function callMethod($methodUri, $method = 'GET', $jsonData = null, $useJson = true, $withUser = false)
protected function callMethod($methodUri, $method = 'GET', $jsonData = null, $useJson = true, $withUser = false)
{
$data = [];
if ($jsonData && $useJson) {
......@@ -515,7 +515,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
return $this->call($method, $methodUri, $data, $withUser);
}
private function callUserMethod($methodUri, $method = 'GET', $jsonData = null, $useJson = true)
protected function callUserMethod($methodUri, $method = 'GET', $jsonData = null, $useJson = true)
{
return $this->callMethod($methodUri, $method, $jsonData, $useJson, true);
}
......@@ -528,7 +528,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
*
* @return bool
*/
private function checkForResponse($res, $expectedResponse = 'MESSAGE_RESOURCE_CREATED')
protected function checkForResponse($res, $expectedResponse = 'MESSAGE_RESOURCE_CREATED')
{
if (is_null($res)) {
throw new InvalidResponse('Got empty response ');
......@@ -545,22 +545,22 @@ abstract class ImmoScoutAPI extends GuzzleClient
return true;
}
private function checkForResponseCreated($res)
protected function checkForResponseCreated($res)
{
return $this->checkForResponse($res, 'MESSAGE_RESOURCE_CREATED');
}
private function checkForResponseUpdated($res)
protected function checkForResponseUpdated($res)
{
return $this->checkForResponse($res, 'MESSAGE_RESOURCE_UPDATED');
}
private function checkForResponseDeleted($res)
protected function checkForResponseDeleted($res)
{
return $this->checkForResponse($res, 'MESSAGE_RESOURCE_DELETED');
}
private function parseGetResponse($res)
protected function parseGetResponse($res)
{
try {
return json_decode((string) $res->getBody(), true);
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!