fa4d2ad6 by fehrlich

added method to create simple attachments

1 parent af5d08c6
...@@ -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 /**
...@@ -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 /**
...@@ -518,7 +518,7 @@ abstract class ImmoScoutAPI extends GuzzleClient ...@@ -518,7 +518,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
518 $msgs = $this->parseMessages($res); 518 $msgs = $this->parseMessages($res);
519 if (!isset($msgs['parsed'][$expectedResponse])) { 519 if (!isset($msgs['parsed'][$expectedResponse])) {
520 $code = isset($msgs['parsed']['ERROR_RESOURCE_NOT_FOUND']) ? 404 : null; 520 $code = isset($msgs['parsed']['ERROR_RESOURCE_NOT_FOUND']) ? 404 : null;
521 throw new InvalidResponse('Did not get expected response: ' . $res->getBody(), $code, null, $res, $msgs); 521 throw new InvalidResponse('Did not get expected response: '.$res->getBody(), $code, null, $res, $msgs);
522 } 522 }
523 if ($expectedResponse == 'MESSAGE_RESOURCE_CREATED') { 523 if ($expectedResponse == 'MESSAGE_RESOURCE_CREATED') {
524 return $msgs['parsed'][$expectedResponse][0]; 524 return $msgs['parsed'][$expectedResponse][0];
...@@ -585,7 +585,7 @@ abstract class ImmoScoutAPI extends GuzzleClient ...@@ -585,7 +585,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
585 */ 585 */
586 public function updateRealEstate($id, $obj) 586 public function updateRealEstate($id, $obj)
587 { 587 {
588 $res = $this->callUserMethod('realestate/' . $id . '?usenewenergysourceenev2014values=true', 'PUT', $obj); 588 $res = $this->callUserMethod('realestate/'.$id.'?usenewenergysourceenev2014values=true', 'PUT', $obj);
589 589
590 return $this->checkForResponseUpdated($res); 590 return $this->checkForResponseUpdated($res);
591 } 591 }
...@@ -600,7 +600,7 @@ abstract class ImmoScoutAPI extends GuzzleClient ...@@ -600,7 +600,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
600 */ 600 */
601 public function deleteAttachment($reId, $attachmentId) 601 public function deleteAttachment($reId, $attachmentId)
602 { 602 {
603 $res = $this->callUserMethod('realestate/' . $reId . '/attachment/' . $attachmentId, 'DELETE'); 603 $res = $this->callUserMethod('realestate/'.$reId.'/attachment/'.$attachmentId, 'DELETE');
604 604
605 return $this->checkForResponseDeleted($res); 605 return $this->checkForResponseDeleted($res);
606 } 606 }
...@@ -625,7 +625,7 @@ abstract class ImmoScoutAPI extends GuzzleClient ...@@ -625,7 +625,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
625 */ 625 */
626 public function createAttachment($objId, $attachmentData, $content, $mimeType = 'image/jpeg', $fileName = 'image.jpg') 626 public function createAttachment($objId, $attachmentData, $content, $mimeType = 'image/jpeg', $fileName = 'image.jpg')
627 { 627 {
628 $res = $this->callUserMethod('realestate/' . $objId . '/attachment/', 'POST', [ 628 $res = $this->callUserMethod('realestate/'.$objId.'/attachment/', 'POST', [
629 'multipart' => [ 629 'multipart' => [
630 [ 630 [
631 'Content-type' => 'application/json', 631 'Content-type' => 'application/json',
...@@ -645,6 +645,21 @@ abstract class ImmoScoutAPI extends GuzzleClient ...@@ -645,6 +645,21 @@ abstract class ImmoScoutAPI extends GuzzleClient
645 } 645 }
646 646
647 /** 647 /**
648 * create simple attachment for an realestate, without a file attached.
649 *
650 * @param string $objId realestate id used by is24
651 * @param array $attachmentData compatible with https://api.immobilienscout24.de/our-apis/import-export/attachments/post.html
652 *
653 * @return string returns the id that is used by is24, this should be saved
654 */
655 public function createSimpleAttachment($objId, $attachmentData)
656 {
657 $res = $this->callUserMethod('realestate/'.$objId.'/attachment/', 'POST', $attachmentData);
658
659 return $this->checkForResponseCreated($res);
660 }
661
662 /**
648 * update realestate attachment. 663 * update realestate attachment.
649 * 664 *
650 * @param string $objId realestate id used by is24 665 * @param string $objId realestate id used by is24
...@@ -655,7 +670,7 @@ abstract class ImmoScoutAPI extends GuzzleClient ...@@ -655,7 +670,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
655 */ 670 */
656 public function updateAttachment($objId, $id, $attachmentData) 671 public function updateAttachment($objId, $id, $attachmentData)
657 { 672 {
658 $res = $this->callUserMethod('realestate/' . $objId . '/attachment/' . $id, 'PUT', $attachmentData); 673 $res = $this->callUserMethod('realestate/'.$objId.'/attachment/'.$id, 'PUT', $attachmentData);
659 674
660 return $this->checkForResponseUpdated($res); 675 return $this->checkForResponseUpdated($res);
661 } 676 }
...@@ -670,7 +685,7 @@ abstract class ImmoScoutAPI extends GuzzleClient ...@@ -670,7 +685,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
670 */ 685 */
671 public function updateAttachmentOrder($objId, $orderArray) 686 public function updateAttachmentOrder($objId, $orderArray)
672 { 687 {
673 $res = $this->callUserMethod('realestate/' . $objId . '/attachment/attachmentsorder', 'PUT', [ 688 $res = $this->callUserMethod('realestate/'.$objId.'/attachment/attachmentsorder', 'PUT', [
674 'attachmentsorder.attachmentsorder' => [ 689 'attachmentsorder.attachmentsorder' => [
675 '@xmlns' => [ 690 '@xmlns' => [
676 'attachmentsorder' => 'http://rest.immobilienscout24.de/schema/attachmentsorder/1.0', 691 'attachmentsorder' => 'http://rest.immobilienscout24.de/schema/attachmentsorder/1.0',
...@@ -701,19 +716,21 @@ abstract class ImmoScoutAPI extends GuzzleClient ...@@ -701,19 +716,21 @@ abstract class ImmoScoutAPI extends GuzzleClient
701 716
702 /** 717 /**
703 * Get an array of all contacts that can be specified for a real estate. 718 * Get an array of all contacts that can be specified for a real estate.
704 * @param string $reId realestate id used by is24 * 719 *
720 * @param string $reId realestate id used by is24 *
705 */ 721 */
706 public function delete($reId) 722 public function delete($reId)
707 { 723 {
708 $res = $this->callUserMethod('realestate/' . $reId, 'DELETE'); 724 $res = $this->callUserMethod('realestate/'.$reId, 'DELETE');
709 725
710 return $this->checkForResponseDeleted($res); 726 return $this->checkForResponseDeleted($res);
711 } 727 }
712 728
713 /** 729 /**
714 * Get an array of all contacts that can be specified for a real estate. 730 * Get an array of all contacts that can be specified for a real estate.
715 * @param string $reId realestate id used by is24 731 *
716 * @param string $publishchannel publish channel id like 10000 732 * @param string $reId realestate id used by is24
733 * @param string $publishchannel publish channel id like 10000
717 */ 734 */
718 public function publish($reId, $publishchannel = '10000') 735 public function publish($reId, $publishchannel = '10000')
719 { 736 {
...@@ -732,13 +749,14 @@ abstract class ImmoScoutAPI extends GuzzleClient ...@@ -732,13 +749,14 @@ abstract class ImmoScoutAPI extends GuzzleClient
732 } 749 }
733 750
734 /** 751 /**
735 * unpublish a real estate 752 * unpublish a real estate.
736 * @param string $reId realestate id used by is24 753 *
737 * @param string $publishchannel publish channel id like 10000 754 * @param string $reId realestate id used by is24
755 * @param string $publishchannel publish channel id like 10000
738 */ 756 */
739 public function unpublish($reId, $publishchannel = '10000') 757 public function unpublish($reId, $publishchannel = '10000')
740 { 758 {
741 $res = $this->callMethod('publish/' . $reId . '_' . $publishchannel, 'DELETE'); 759 $res = $this->callMethod('publish/'.$reId.'_'.$publishchannel, 'DELETE');
742 760
743 return $this->checkForResponseDeleted($res); 761 return $this->checkForResponseDeleted($res);
744 } 762 }
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!