public function send($dataObject, $returnFullResponse = true)
{
if (!is_object($dataObject)) {
$dataObject = new \stdClass();
}
$dataObject->protocol = $this->protocol;
$dataObject->action = $this->action;
$dataObject->object = $this->object;
if (isset($dataObject->attributes->domain) && substr_count($dataObject->attributes->domain, '.') > 1) {
$dataObject->attributes->domain = str_replace('www.', '', $dataObject->attributes->domain);
}
// Flip Array to XML
$xmlCMD = $this->_opsHandler->encode(json_decode(json_encode($dataObject), true));
// Send XML
$XMLresult = $this->send_cmd($xmlCMD);
// Flip XML to Array
$arrayResult = $this->_opsHandler->decode($XMLresult);
if (!$arrayResult['is_success'] && $arrayResult['response_code'] != 200 && $arrayResult['response_code'] != 415) {
$errorInfo = null;
if (array_key_exists('attributes', $arrayResult)) {
$errorInfo = $arrayResult['attributes'];
}
throw new APIException("oSRS Error Code #{$arrayResult['response_code']}: {$arrayResult['response_text']}.", $errorInfo);
}
if (method_exists($this, 'customResponseHandling')) {
$arrayResult = $this->customResponseHandling($arrayResult, $returnFullResponse);
}
// Results
$this->resultFullRaw = $arrayResult;
if (!$returnFullResponse && isset($arrayResult['attributes'])) {
// Return 'attributes' hash from response
// if it exists, otherwise return the full
// response--original class did this, so have
// to keep for backward compatibility
// THIS IS NOT DEFAULT BEHAVIOR, BY DEFAULT
// WE WILL RETURN THE WHOLE RESPONSE
$this->resultRaw = $arrayResult['attributes'];
} else {
$this->resultRaw = $arrayResult;
}
$this->resultFullFormatted = $this->convertArray2Formatted($this->_formatHolder, $this->resultFullRaw);
$this->resultFormatted = $this->convertArray2Formatted($this->_formatHolder, $this->resultRaw);
}