Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add new methods to deal with Immoscout Projects #55

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 127 additions & 0 deletions Immocaster/Immobilienscout/Rest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1774,4 +1774,131 @@ private function _getPublish($aArgs)
$req->unset_parameter('username');
return parent::getContent($req,$sSecret);
}

/*
* Erfrage die Projekt-ID eines Objektes
*
* Hinweis: hierfür müssen gesonderte Rechte bei Immoscout erteilt werden!
*
* Beware: Doesn't work with external ID! Triggers an error at Immoscout24!
*
* @author chris <[email protected]> / https://github.com/chris-blues
*
* @param array $aArgs
* @return mixed
*/
public function getProjectId($aArgs)
{
$aRequired = array('username', 'estateid');
$oToken = null;
$sSecret = null;
if(!isset($aArgs['username']))
{
$aArgs['username'] = $this->_sDefaultUsername;
}
list($oToken, $sSecret) = $this->getApplicationTokenAndSecret($aArgs['username']);
if($oToken === NULL || $sSecret === NULL)
{
return IMMOCASTER_SDK_LANG_APPLICATION_NOT_CERTIFIED;
}
$req = $this->doRequest(
'offer/v1.0/user/'.$aArgs['username'].'/realestateproject?realestateid='.$aArgs["estateid"],
$aArgs,
$aRequired,
__FUNCTION__,
$oToken
);

return parent::getContent($req,$sSecret);
}

/**
* Füge Objekt einem Projekt hinzu
*
* Hinweis: hierfür müssen gesonderte Rechte bei Immoscout erteilt werden!
*
* @author chris <[email protected]> / https://github.com/chris-blues
*
* @param array $aArgs
* @param bool $externalID
* @return mixed
*/
public function addToProject($aArgs, $externalID = false)
{
$aRequired = array('username', 'estateid', 'project_id');
$oToken = null;
$sSecret = null;
if(!isset($aArgs['username']))
{
$aArgs['username'] = $this->_sDefaultUsername;
}
list($oToken, $sSecret) = $this->getApplicationTokenAndSecret($aArgs['username']);
if($oToken === NULL || $sSecret === NULL)
{
return IMMOCASTER_SDK_LANG_APPLICATION_NOT_CERTIFIED;
}
$aArgs['request_body'] = '<realestateproject:realEstateProjectEntries xmlns:realestateproject="http://rest.immobilienscout24.de/schema/offer/realestateproject/1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ns4="http://rest.immobilienscout24.de/schema/platform/gis/1.0">';

$aArgs['request_body'] .= ' <realEstateProjectEntry>';

if ($externalID)
{
$aArgs['request_body'] .= ' <realEstateExternalId>' . $aArgs["estateid"] . '</realEstateExternalId>';
}
else
{
$aArgs['request_body'] .= ' <realEstateId>' . $aArgs["estateid"] . '</realEstateId>';
}

$aArgs['request_body'] .= ' </realEstateProjectEntry>';

$aArgs['request_body'] .= '</realestateproject:realEstateProjectEntries>';

$req = $this->doRequest(
'offer/v1.0/user/'.$aArgs['username'].'/realestateproject/'.$aArgs["project_id"].'/realestateprojectentry',
$aArgs,
$aRequired,
__FUNCTION__,
$oToken,
'POST'
);

return parent::getContent($req,$sSecret);
}

/**
* Entferne Objekt aus einem Projekt
*
* Hinweis: hierfür müssen gesonderte Rechte bei Immoscout erteilt werden!
*
* @author chris <[email protected]> / https://github.com/chris-blues
*
* @param array $aArgs
* @return mixed
*/
public function deleteFromProject($aArgs)
{
$aRequired = array('username', 'estateid', 'project_id');
$oToken = null;
$sSecret = null;
if(!isset($aArgs['username']))
{
$aArgs['username'] = $this->_sDefaultUsername;
}
list($oToken, $sSecret) = $this->getApplicationTokenAndSecret($aArgs['username']);
if($oToken === NULL || $sSecret === NULL)
{
return IMMOCASTER_SDK_LANG_APPLICATION_NOT_CERTIFIED;
}
$req = $this->doRequest(
'offer/v1.0/user/'.$aArgs['username'].'/realestateproject/'.$aArgs["project_id"].'/realestateprojectentry/'.$aArgs["estateid"],
$aArgs,
$aRequired,
__FUNCTION__,
$oToken,
'DELETE'
);

return parent::getContent($req,$sSecret);
}
}