bf7ec52f by fehrlich

Merge branch 'master' of gitlab.com:fehrlich/immoscout24-api-php

2 parents 68508bef fa4d2ad6
...@@ -182,7 +182,7 @@ abstract class ImmoScoutAPI extends GuzzleClient ...@@ -182,7 +182,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
182 { 182 {
183 $domain = $this->getDomain(); 183 $domain = $this->getDomain();
184 184
185 return 'https://rest.' . $domain . '/restapi/'; 185 return 'https://rest.'.$domain.'/restapi/';
186 } 186 }
187 187
188 /** 188 /**
...@@ -237,7 +237,7 @@ abstract class ImmoScoutAPI extends GuzzleClient ...@@ -237,7 +237,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
237 $stack->push($oAuth); 237 $stack->push($oAuth);
238 238
239 $client = new Client([ 239 $client = new Client([
240 'base_uri' => 'https://rest.sandbox-immobilienscout24.de/restapi/', 240 'base_uri' => $this->getBaseUrl(),
241 'handler' => $stack, 241 'handler' => $stack,
242 'auth' => 'oauth', 242 'auth' => 'oauth',
243 ]); 243 ]);
...@@ -266,7 +266,7 @@ abstract class ImmoScoutAPI extends GuzzleClient ...@@ -266,7 +266,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
266 throw new InvalidResponse('Could not parse the requested request token'); 266 throw new InvalidResponse('Could not parse the requested request token');
267 } 267 }
268 $this->saveRequestToken($body['oauth_token'], $body['oauth_token_secret']); 268 $this->saveRequestToken($body['oauth_token'], $body['oauth_token_secret']);
269 header('Location: ' . $this->getBaseUrl() . 'security/oauth/confirm_access?oauth_token=' . $body['oauth_token']); 269 header('Location: '.$this->getBaseUrl().'security/oauth/confirm_access?oauth_token='.$body['oauth_token']);
270 exit(); 270 exit();
271 } 271 }
272 272
...@@ -369,7 +369,7 @@ abstract class ImmoScoutAPI extends GuzzleClient ...@@ -369,7 +369,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
369 } 369 }
370 $path = str_replace('{user}', $this->user, $path); 370 $path = str_replace('{user}', $this->user, $path);
371 371
372 return $url . $path; 372 return $url.$path;
373 } 373 }
374 374
375 /** 375 /**
...@@ -521,7 +521,7 @@ abstract class ImmoScoutAPI extends GuzzleClient ...@@ -521,7 +521,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
521 $msgs = $this->parseMessages($res); 521 $msgs = $this->parseMessages($res);
522 if (!isset($msgs['parsed'][$expectedResponse])) { 522 if (!isset($msgs['parsed'][$expectedResponse])) {
523 $code = isset($msgs['parsed']['ERROR_RESOURCE_NOT_FOUND']) ? 404 : null; 523 $code = isset($msgs['parsed']['ERROR_RESOURCE_NOT_FOUND']) ? 404 : null;
524 throw new InvalidResponse('Did not get expected response: ' . $res->getBody(), $code, null, $res, $msgs); 524 throw new InvalidResponse('Did not get expected response: '.$res->getBody(), $code, null, $res, $msgs);
525 } 525 }
526 if ($expectedResponse == 'MESSAGE_RESOURCE_CREATED') { 526 if ($expectedResponse == 'MESSAGE_RESOURCE_CREATED') {
527 return $msgs['parsed'][$expectedResponse][0]; 527 return $msgs['parsed'][$expectedResponse][0];
...@@ -588,7 +588,7 @@ abstract class ImmoScoutAPI extends GuzzleClient ...@@ -588,7 +588,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
588 */ 588 */
589 public function updateRealEstate($id, $obj) 589 public function updateRealEstate($id, $obj)
590 { 590 {
591 $res = $this->callUserMethod('realestate/' . $id . '?usenewenergysourceenev2014values=true', 'PUT', $obj); 591 $res = $this->callUserMethod('realestate/'.$id.'?usenewenergysourceenev2014values=true', 'PUT', $obj);
592 592
593 return $this->checkForResponseUpdated($res); 593 return $this->checkForResponseUpdated($res);
594 } 594 }
...@@ -603,7 +603,7 @@ abstract class ImmoScoutAPI extends GuzzleClient ...@@ -603,7 +603,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
603 */ 603 */
604 public function deleteAttachment($reId, $attachmentId) 604 public function deleteAttachment($reId, $attachmentId)
605 { 605 {
606 $res = $this->callUserMethod('realestate/' . $reId . '/attachment/' . $attachmentId, 'DELETE'); 606 $res = $this->callUserMethod('realestate/'.$reId.'/attachment/'.$attachmentId, 'DELETE');
607 607
608 return $this->checkForResponseDeleted($res); 608 return $this->checkForResponseDeleted($res);
609 } 609 }
...@@ -628,7 +628,7 @@ abstract class ImmoScoutAPI extends GuzzleClient ...@@ -628,7 +628,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
628 */ 628 */
629 public function createAttachment($objId, $attachmentData, $content, $mimeType = 'image/jpeg', $fileName = 'image.jpg') 629 public function createAttachment($objId, $attachmentData, $content, $mimeType = 'image/jpeg', $fileName = 'image.jpg')
630 { 630 {
631 $res = $this->callUserMethod('realestate/' . $objId . '/attachment/', 'POST', [ 631 $res = $this->callUserMethod('realestate/'.$objId.'/attachment/', 'POST', [
632 'multipart' => [ 632 'multipart' => [
633 [ 633 [
634 'Content-type' => 'application/json', 634 'Content-type' => 'application/json',
...@@ -648,6 +648,21 @@ abstract class ImmoScoutAPI extends GuzzleClient ...@@ -648,6 +648,21 @@ abstract class ImmoScoutAPI extends GuzzleClient
648 } 648 }
649 649
650 /** 650 /**
651 * create simple attachment for an realestate, without a file attached.
652 *
653 * @param string $objId realestate id used by is24
654 * @param array $attachmentData compatible with https://api.immobilienscout24.de/our-apis/import-export/attachments/post.html
655 *
656 * @return string returns the id that is used by is24, this should be saved
657 */
658 public function createSimpleAttachment($objId, $attachmentData)
659 {
660 $res = $this->callUserMethod('realestate/'.$objId.'/attachment/', 'POST', $attachmentData);
661
662 return $this->checkForResponseCreated($res);
663 }
664
665 /**
651 * update realestate attachment. 666 * update realestate attachment.
652 * 667 *
653 * @param string $objId realestate id used by is24 668 * @param string $objId realestate id used by is24
...@@ -658,7 +673,7 @@ abstract class ImmoScoutAPI extends GuzzleClient ...@@ -658,7 +673,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
658 */ 673 */
659 public function updateAttachment($objId, $id, $attachmentData) 674 public function updateAttachment($objId, $id, $attachmentData)
660 { 675 {
661 $res = $this->callUserMethod('realestate/' . $objId . '/attachment/' . $id, 'PUT', $attachmentData); 676 $res = $this->callUserMethod('realestate/'.$objId.'/attachment/'.$id, 'PUT', $attachmentData);
662 677
663 return $this->checkForResponseUpdated($res); 678 return $this->checkForResponseUpdated($res);
664 } 679 }
...@@ -673,7 +688,7 @@ abstract class ImmoScoutAPI extends GuzzleClient ...@@ -673,7 +688,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
673 */ 688 */
674 public function updateAttachmentOrder($objId, $orderArray) 689 public function updateAttachmentOrder($objId, $orderArray)
675 { 690 {
676 $res = $this->callUserMethod('realestate/' . $objId . '/attachment/attachmentsorder', 'PUT', [ 691 $res = $this->callUserMethod('realestate/'.$objId.'/attachment/attachmentsorder', 'PUT', [
677 'attachmentsorder.attachmentsorder' => [ 692 'attachmentsorder.attachmentsorder' => [
678 '@xmlns' => [ 693 '@xmlns' => [
679 'attachmentsorder' => 'http://rest.immobilienscout24.de/schema/attachmentsorder/1.0', 694 'attachmentsorder' => 'http://rest.immobilienscout24.de/schema/attachmentsorder/1.0',
...@@ -704,17 +719,19 @@ abstract class ImmoScoutAPI extends GuzzleClient ...@@ -704,17 +719,19 @@ abstract class ImmoScoutAPI extends GuzzleClient
704 719
705 /** 720 /**
706 * Get an array of all contacts that can be specified for a real estate. 721 * Get an array of all contacts that can be specified for a real estate.
722 *
707 * @param string $reId realestate id used by is24 * 723 * @param string $reId realestate id used by is24 *
708 */ 724 */
709 public function delete($reId) 725 public function delete($reId)
710 { 726 {
711 $res = $this->callUserMethod('realestate/' . $reId, 'DELETE'); 727 $res = $this->callUserMethod('realestate/'.$reId, 'DELETE');
712 728
713 return $this->checkForResponseDeleted($res); 729 return $this->checkForResponseDeleted($res);
714 } 730 }
715 731
716 /** 732 /**
717 * Get an array of all contacts that can be specified for a real estate. 733 * Get an array of all contacts that can be specified for a real estate.
734 *
718 * @param string $reId realestate id used by is24 735 * @param string $reId realestate id used by is24
719 * @param string $publishchannel publish channel id like 10000 736 * @param string $publishchannel publish channel id like 10000
720 */ 737 */
...@@ -735,13 +752,14 @@ abstract class ImmoScoutAPI extends GuzzleClient ...@@ -735,13 +752,14 @@ abstract class ImmoScoutAPI extends GuzzleClient
735 } 752 }
736 753
737 /** 754 /**
738 * unpublish a real estate 755 * unpublish a real estate.
756 *
739 * @param string $reId realestate id used by is24 757 * @param string $reId realestate id used by is24
740 * @param string $publishchannel publish channel id like 10000 758 * @param string $publishchannel publish channel id like 10000
741 */ 759 */
742 public function unpublish($reId, $publishchannel = '10000') 760 public function unpublish($reId, $publishchannel = '10000')
743 { 761 {
744 $res = $this->callMethod('publish/' . $reId . '_' . $publishchannel, 'DELETE'); 762 $res = $this->callMethod('publish/'.$reId.'_'.$publishchannel, 'DELETE');
745 763
746 return $this->checkForResponseDeleted($res); 764 return $this->checkForResponseDeleted($res);
747 } 765 }
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!