opensrs\Base::send PHP Method

send() public method

Send the oSRS API request, set action, object and protocol based on the call being made (so we don't have to set it in each call class), and run any custom response handling if the function 'customResponseHandling' exists on $obj, the class for that specific API call.
public send ( $dataObject, $returnFullResponse = true )
    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);
    }