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
{
$domain = $this->getDomain();
return 'https://rest.' . $domain . '/restapi/';
return 'https://rest.'.$domain.'/restapi/';
}
/**
......@@ -237,7 +237,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
$stack->push($oAuth);
$client = new Client([
'base_uri' => 'https://rest.sandbox-immobilienscout24.de/restapi/',
'base_uri' => $this->getBaseUrl(),
'handler' => $stack,
'auth' => 'oauth',
]);
......@@ -266,7 +266,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
throw new InvalidResponse('Could not parse the requested request token');
}
$this->saveRequestToken($body['oauth_token'], $body['oauth_token_secret']);
header('Location: ' . $this->getBaseUrl() . 'security/oauth/confirm_access?oauth_token=' . $body['oauth_token']);
header('Location: '.$this->getBaseUrl().'security/oauth/confirm_access?oauth_token='.$body['oauth_token']);
exit();
}
......@@ -369,7 +369,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
}
$path = str_replace('{user}', $this->user, $path);
return $url . $path;
return $url.$path;
}
/**
......@@ -521,7 +521,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
$msgs = $this->parseMessages($res);
if (!isset($msgs['parsed'][$expectedResponse])) {
$code = isset($msgs['parsed']['ERROR_RESOURCE_NOT_FOUND']) ? 404 : null;
throw new InvalidResponse('Did not get expected response: ' . $res->getBody(), $code, null, $res, $msgs);
throw new InvalidResponse('Did not get expected response: '.$res->getBody(), $code, null, $res, $msgs);
}
if ($expectedResponse == 'MESSAGE_RESOURCE_CREATED') {
return $msgs['parsed'][$expectedResponse][0];
......@@ -588,7 +588,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
*/
public function updateRealEstate($id, $obj)
{
$res = $this->callUserMethod('realestate/' . $id . '?usenewenergysourceenev2014values=true', 'PUT', $obj);
$res = $this->callUserMethod('realestate/'.$id.'?usenewenergysourceenev2014values=true', 'PUT', $obj);
return $this->checkForResponseUpdated($res);
}
......@@ -603,7 +603,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
*/
public function deleteAttachment($reId, $attachmentId)
{
$res = $this->callUserMethod('realestate/' . $reId . '/attachment/' . $attachmentId, 'DELETE');
$res = $this->callUserMethod('realestate/'.$reId.'/attachment/'.$attachmentId, 'DELETE');
return $this->checkForResponseDeleted($res);
}
......@@ -628,7 +628,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
*/
public function createAttachment($objId, $attachmentData, $content, $mimeType = 'image/jpeg', $fileName = 'image.jpg')
{
$res = $this->callUserMethod('realestate/' . $objId . '/attachment/', 'POST', [
$res = $this->callUserMethod('realestate/'.$objId.'/attachment/', 'POST', [
'multipart' => [
[
'Content-type' => 'application/json',
......@@ -648,6 +648,21 @@ abstract class ImmoScoutAPI extends GuzzleClient
}
/**
* create simple attachment for an realestate, without a file attached.
*
* @param string $objId realestate id used by is24
* @param array $attachmentData compatible with https://api.immobilienscout24.de/our-apis/import-export/attachments/post.html
*
* @return string returns the id that is used by is24, this should be saved
*/
public function createSimpleAttachment($objId, $attachmentData)
{
$res = $this->callUserMethod('realestate/'.$objId.'/attachment/', 'POST', $attachmentData);
return $this->checkForResponseCreated($res);
}
/**
* update realestate attachment.
*
* @param string $objId realestate id used by is24
......@@ -658,7 +673,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
*/
public function updateAttachment($objId, $id, $attachmentData)
{
$res = $this->callUserMethod('realestate/' . $objId . '/attachment/' . $id, 'PUT', $attachmentData);
$res = $this->callUserMethod('realestate/'.$objId.'/attachment/'.$id, 'PUT', $attachmentData);
return $this->checkForResponseUpdated($res);
}
......@@ -673,7 +688,7 @@ abstract class ImmoScoutAPI extends GuzzleClient
*/
public function updateAttachmentOrder($objId, $orderArray)
{
$res = $this->callUserMethod('realestate/' . $objId . '/attachment/attachmentsorder', 'PUT', [
$res = $this->callUserMethod('realestate/'.$objId.'/attachment/attachmentsorder', 'PUT', [
'attachmentsorder.attachmentsorder' => [
'@xmlns' => [
'attachmentsorder' => 'http://rest.immobilienscout24.de/schema/attachmentsorder/1.0',
......@@ -704,19 +719,21 @@ abstract class ImmoScoutAPI extends GuzzleClient
/**
* Get an array of all contacts that can be specified for a real estate.
* @param string $reId realestate id used by is24 *
*
* @param string $reId realestate id used by is24 *
*/
public function delete($reId)
{
$res = $this->callUserMethod('realestate/' . $reId, 'DELETE');
$res = $this->callUserMethod('realestate/'.$reId, 'DELETE');
return $this->checkForResponseDeleted($res);
}
/**
* Get an array of all contacts that can be specified for a real estate.
* @param string $reId realestate id used by is24
* @param string $publishchannel publish channel id like 10000
*
* @param string $reId realestate id used by is24
* @param string $publishchannel publish channel id like 10000
*/
public function publish($reId, $publishchannel = '10000')
{
......@@ -735,13 +752,14 @@ abstract class ImmoScoutAPI extends GuzzleClient
}
/**
* unpublish a real estate
* @param string $reId realestate id used by is24
* @param string $publishchannel publish channel id like 10000
* unpublish a real estate.
*
* @param string $reId realestate id used by is24
* @param string $publishchannel publish channel id like 10000
*/
public function unpublish($reId, $publishchannel = '10000')
{
$res = $this->callMethod('publish/' . $reId . '_' . $publishchannel, 'DELETE');
$res = $this->callMethod('publish/'.$reId.'_'.$publishchannel, 'DELETE');
return $this->checkForResponseDeleted($res);
}
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!