Merge branch 'protected' into 'master'
protected See merge request !1
Showing
2 changed files
with
23 additions
and
23 deletions
File moved
| ... | @@ -22,12 +22,12 @@ use Psr\Http\Message\ResponseInterface; | ... | @@ -22,12 +22,12 @@ use Psr\Http\Message\ResponseInterface; |
| 22 | */ | 22 | */ |
| 23 | abstract class ImmoScoutAPI extends GuzzleClient | 23 | abstract class ImmoScoutAPI extends GuzzleClient |
| 24 | { | 24 | { |
| 25 | private $consumerKey; | 25 | protected $consumerKey; |
| 26 | private $consumerKeySecret; | 26 | protected $consumerKeySecret; |
| 27 | private $client = null; | 27 | protected $client = null; |
| 28 | public $history = null; | 28 | public $history = null; |
| 29 | private $user = 'me'; | 29 | protected $user = 'me'; |
| 30 | private $isSandbox = true; | 30 | protected $isSandbox = true; |
| 31 | 31 | ||
| 32 | /** | 32 | /** |
| 33 | * should save the request token with tokenname + secret, the token can be temporarily saved within a session | 33 | * 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 | ... | @@ -72,7 +72,7 @@ abstract class ImmoScoutAPI extends GuzzleClient |
| 72 | * | 72 | * |
| 73 | * @return void | 73 | * @return void |
| 74 | */ | 74 | */ |
| 75 | private function validateToken($tokenArray) | 75 | protected function validateToken($tokenArray) |
| 76 | { | 76 | { |
| 77 | if (!is_array($tokenArray)) { | 77 | if (!is_array($tokenArray)) { |
| 78 | throw new InvalidTokenException('restored Token is not an Array need to be of the form [token, token_secret]'); | 78 | 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 | ... | @@ -82,7 +82,7 @@ abstract class ImmoScoutAPI extends GuzzleClient |
| 82 | } | 82 | } |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | private function getValidatedRequestToken() | 85 | protected function getValidatedRequestToken() |
| 86 | { | 86 | { |
| 87 | $token = $this->restoreRequestToken(); | 87 | $token = $this->restoreRequestToken(); |
| 88 | $this->validateToken($token); | 88 | $this->validateToken($token); |
| ... | @@ -90,7 +90,7 @@ abstract class ImmoScoutAPI extends GuzzleClient | ... | @@ -90,7 +90,7 @@ abstract class ImmoScoutAPI extends GuzzleClient |
| 90 | return $token; | 90 | return $token; |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | private function getValidatedAccessToken() | 93 | protected function getValidatedAccessToken() |
| 94 | { | 94 | { |
| 95 | $token = static::restoreAccessToken(); | 95 | $token = static::restoreAccessToken(); |
| 96 | $this->validateToken($token); | 96 | $this->validateToken($token); |
| ... | @@ -193,7 +193,7 @@ abstract class ImmoScoutAPI extends GuzzleClient | ... | @@ -193,7 +193,7 @@ abstract class ImmoScoutAPI extends GuzzleClient |
| 193 | * | 193 | * |
| 194 | * @return string base url | 194 | * @return string base url |
| 195 | */ | 195 | */ |
| 196 | private function getBaseUrl() | 196 | protected function getBaseUrl() |
| 197 | { | 197 | { |
| 198 | $domain = $this->getDomain(); | 198 | $domain = $this->getDomain(); |
| 199 | 199 | ||
| ... | @@ -205,7 +205,7 @@ abstract class ImmoScoutAPI extends GuzzleClient | ... | @@ -205,7 +205,7 @@ abstract class ImmoScoutAPI extends GuzzleClient |
| 205 | * | 205 | * |
| 206 | * @return string current url | 206 | * @return string current url |
| 207 | */ | 207 | */ |
| 208 | private static function getSelfURI() | 208 | protected static function getSelfURI() |
| 209 | { | 209 | { |
| 210 | if (!isset($_SERVER) || !isset($_SERVER['HTTP_HOST']) || !isset($_SERVER['REQUEST_URI'])) { | 210 | if (!isset($_SERVER) || !isset($_SERVER['HTTP_HOST']) || !isset($_SERVER['REQUEST_URI'])) { |
| 211 | throw new \Exception("coudn't detect request uri for callback (please specify one)"); | 211 | throw new \Exception("coudn't detect request uri for callback (please specify one)"); |
| ... | @@ -240,7 +240,7 @@ abstract class ImmoScoutAPI extends GuzzleClient | ... | @@ -240,7 +240,7 @@ abstract class ImmoScoutAPI extends GuzzleClient |
| 240 | * | 240 | * |
| 241 | * @return ResponseInterface | 241 | * @return ResponseInterface |
| 242 | */ | 242 | */ |
| 243 | private function callOAuth($uri, $oAuthData) | 243 | protected function callOAuth($uri, $oAuthData) |
| 244 | { | 244 | { |
| 245 | $oAuthData['consumer_key'] = $this->consumerKey; | 245 | $oAuthData['consumer_key'] = $this->consumerKey; |
| 246 | $oAuthData['consumer_secret'] = $this->consumerKeySecret; | 246 | $oAuthData['consumer_secret'] = $this->consumerKeySecret; |
| ... | @@ -267,7 +267,7 @@ abstract class ImmoScoutAPI extends GuzzleClient | ... | @@ -267,7 +267,7 @@ abstract class ImmoScoutAPI extends GuzzleClient |
| 267 | * | 267 | * |
| 268 | * @return void | 268 | * @return void |
| 269 | */ | 269 | */ |
| 270 | private function requestRequestToken($callback) | 270 | protected function requestRequestToken($callback) |
| 271 | { | 271 | { |
| 272 | try { | 272 | try { |
| 273 | $res = static::callOAuth('/restapi/security/oauth/request_token', [ | 273 | $res = static::callOAuth('/restapi/security/oauth/request_token', [ |
| ... | @@ -292,7 +292,7 @@ abstract class ImmoScoutAPI extends GuzzleClient | ... | @@ -292,7 +292,7 @@ abstract class ImmoScoutAPI extends GuzzleClient |
| 292 | * | 292 | * |
| 293 | * @return void | 293 | * @return void |
| 294 | */ | 294 | */ |
| 295 | private function requestAccessToken($verifier) | 295 | protected function requestAccessToken($verifier) |
| 296 | { | 296 | { |
| 297 | $requestToken = $this->getValidatedRequestToken(); | 297 | $requestToken = $this->getValidatedRequestToken(); |
| 298 | try { | 298 | try { |
| ... | @@ -368,7 +368,7 @@ abstract class ImmoScoutAPI extends GuzzleClient | ... | @@ -368,7 +368,7 @@ abstract class ImmoScoutAPI extends GuzzleClient |
| 368 | * | 368 | * |
| 369 | * @return string url | 369 | * @return string url |
| 370 | */ | 370 | */ |
| 371 | private function getUrl($methodUri, $withUser = true) | 371 | protected function getUrl($methodUri, $withUser = true) |
| 372 | { | 372 | { |
| 373 | $url = $this->getBaseUrl(); | 373 | $url = $this->getBaseUrl(); |
| 374 | $path = 'api/offer/v1.0/'; | 374 | $path = 'api/offer/v1.0/'; |
| ... | @@ -394,7 +394,7 @@ abstract class ImmoScoutAPI extends GuzzleClient | ... | @@ -394,7 +394,7 @@ abstract class ImmoScoutAPI extends GuzzleClient |
| 394 | * | 394 | * |
| 395 | * @return array message array | 395 | * @return array message array |
| 396 | */ | 396 | */ |
| 397 | private function parseMessages($res) | 397 | protected function parseMessages($res) |
| 398 | { | 398 | { |
| 399 | $return = [ | 399 | $return = [ |
| 400 | 'parsed' => [], | 400 | 'parsed' => [], |
| ... | @@ -488,7 +488,7 @@ abstract class ImmoScoutAPI extends GuzzleClient | ... | @@ -488,7 +488,7 @@ abstract class ImmoScoutAPI extends GuzzleClient |
| 488 | * | 488 | * |
| 489 | * @return void | 489 | * @return void |
| 490 | */ | 490 | */ |
| 491 | private function call($method, $methodUri, $data = [], $withUser = false) | 491 | protected function call($method, $methodUri, $data = [], $withUser = false) |
| 492 | { | 492 | { |
| 493 | $methodUri = $this->getUrl($methodUri, $withUser); | 493 | $methodUri = $this->getUrl($methodUri, $withUser); |
| 494 | try { | 494 | try { |
| ... | @@ -501,7 +501,7 @@ abstract class ImmoScoutAPI extends GuzzleClient | ... | @@ -501,7 +501,7 @@ abstract class ImmoScoutAPI extends GuzzleClient |
| 501 | } | 501 | } |
| 502 | } | 502 | } |
| 503 | 503 | ||
| 504 | private function callMethod($methodUri, $method = 'GET', $jsonData = null, $useJson = true, $withUser = false) | 504 | protected function callMethod($methodUri, $method = 'GET', $jsonData = null, $useJson = true, $withUser = false) |
| 505 | { | 505 | { |
| 506 | $data = []; | 506 | $data = []; |
| 507 | if ($jsonData && $useJson) { | 507 | if ($jsonData && $useJson) { |
| ... | @@ -515,7 +515,7 @@ abstract class ImmoScoutAPI extends GuzzleClient | ... | @@ -515,7 +515,7 @@ abstract class ImmoScoutAPI extends GuzzleClient |
| 515 | return $this->call($method, $methodUri, $data, $withUser); | 515 | return $this->call($method, $methodUri, $data, $withUser); |
| 516 | } | 516 | } |
| 517 | 517 | ||
| 518 | private function callUserMethod($methodUri, $method = 'GET', $jsonData = null, $useJson = true) | 518 | protected function callUserMethod($methodUri, $method = 'GET', $jsonData = null, $useJson = true) |
| 519 | { | 519 | { |
| 520 | return $this->callMethod($methodUri, $method, $jsonData, $useJson, true); | 520 | return $this->callMethod($methodUri, $method, $jsonData, $useJson, true); |
| 521 | } | 521 | } |
| ... | @@ -528,7 +528,7 @@ abstract class ImmoScoutAPI extends GuzzleClient | ... | @@ -528,7 +528,7 @@ abstract class ImmoScoutAPI extends GuzzleClient |
| 528 | * | 528 | * |
| 529 | * @return bool | 529 | * @return bool |
| 530 | */ | 530 | */ |
| 531 | private function checkForResponse($res, $expectedResponse = 'MESSAGE_RESOURCE_CREATED') | 531 | protected function checkForResponse($res, $expectedResponse = 'MESSAGE_RESOURCE_CREATED') |
| 532 | { | 532 | { |
| 533 | if (is_null($res)) { | 533 | if (is_null($res)) { |
| 534 | throw new InvalidResponse('Got empty response '); | 534 | throw new InvalidResponse('Got empty response '); |
| ... | @@ -545,22 +545,22 @@ abstract class ImmoScoutAPI extends GuzzleClient | ... | @@ -545,22 +545,22 @@ abstract class ImmoScoutAPI extends GuzzleClient |
| 545 | return true; | 545 | return true; |
| 546 | } | 546 | } |
| 547 | 547 | ||
| 548 | private function checkForResponseCreated($res) | 548 | protected function checkForResponseCreated($res) |
| 549 | { | 549 | { |
| 550 | return $this->checkForResponse($res, 'MESSAGE_RESOURCE_CREATED'); | 550 | return $this->checkForResponse($res, 'MESSAGE_RESOURCE_CREATED'); |
| 551 | } | 551 | } |
| 552 | 552 | ||
| 553 | private function checkForResponseUpdated($res) | 553 | protected function checkForResponseUpdated($res) |
| 554 | { | 554 | { |
| 555 | return $this->checkForResponse($res, 'MESSAGE_RESOURCE_UPDATED'); | 555 | return $this->checkForResponse($res, 'MESSAGE_RESOURCE_UPDATED'); |
| 556 | } | 556 | } |
| 557 | 557 | ||
| 558 | private function checkForResponseDeleted($res) | 558 | protected function checkForResponseDeleted($res) |
| 559 | { | 559 | { |
| 560 | return $this->checkForResponse($res, 'MESSAGE_RESOURCE_DELETED'); | 560 | return $this->checkForResponse($res, 'MESSAGE_RESOURCE_DELETED'); |
| 561 | } | 561 | } |
| 562 | 562 | ||
| 563 | private function parseGetResponse($res) | 563 | protected function parseGetResponse($res) |
| 564 | { | 564 | { |
| 565 | try { | 565 | try { |
| 566 | return json_decode((string) $res->getBody(), true); | 566 | return json_decode((string) $res->getBody(), true); | ... | ... |
-
Please register or sign in to post a comment