/** * Get Service Request by ID. * If SR is cached, get from cache directly, * otherwise, fetch SR from EBS by sending a cURL request. * Save the SR in the in-process cache to avoid sending multiple requests to EBS. * Save the SR in the session for incident creation usage. * @param int $srID Service Request ID * @return RNCPHP\RNObject Get SR result */ function getSRDetailByID($srID) { if ($srID === null) { return $this->getResponseObject(null, null, 'Error occurs when getSRbyID :: invalid sr_id'); } // check if the SR has been cached in the in-process cache // If cached, save it in the session and return the SR $cacheKey = 'sr_' . $srID; $srDetail = \RightNow\Utils\Framework::checkCache($cacheKey); if ($srDetail) { return $this->getResponseObject($srDetail, 'is_array'); } // if not cachaed, send request to EBS server to get the SR, // and save in session and cache $extObj = 'service_request_detail'; $extAction = 'read'; $requestParams = array('srID' => $srID); $requestEntries = null; $responseFields = array('INCIDENT_NUMBER', 'INCIDENT_ID', 'SUMMARY', 'INCIDENT_TYPE', 'INCIDENT_TYPE_ID', 'INCIDENT_STATUS', 'INCIDENT_STATUS_ID', 'INCIDENT_SEVERITY', 'INCIDENT_SEVERITY_ID', 'CREATION_DATE', 'OBJECT_VERSION_NUMBER', 'SR_OWNER_ID', 'CUSTOMER_TYPE', 'SERIAL_NUMBER', 'PRODUCT', 'CUSTOMER_ID', 'CUSTOMER_PRODUCT_ID', 'INVENTORY_ORG_ID', 'EXTATTRIBUTE13', 'EXTATTRIBUTE14', 'EXTATTRIBUTE15', 'CONTACT_PARTY_ID'); $errorFields = array('FAULTSTRING', 'X_MSG_DATA'); // send curl request $getSRResult = $this->CI->model('custom/EbsApi')->sendSoapRequest($this->extConfigVerb, $extObj, $extAction, null, $this->contact, $requestParams, $requestEntries, $responseFields, $errorFields); // check the result. if success, save SR in the in-process cache and the session if ($getSRResult->error === null) { \RightNow\Utils\Framework::setCache($cacheKey, $getSRResult->result, true); $sessionKey = $cacheKey; $this->CI->session->setSessionData(array($sessionKey => $getSRResult->result)); } return $getSRResult; }
/** * Get Service Request by ID * If SR is cached, get from cache directly, * otherwise, fetch SR from Siebel by sending a curl request. * Save the SR in the in-process cache to avoid send multiple requests to Siebel. * Save the SR in the session for incident creation usage. * @param int $srID Service Request ID * @return RNCPHP\RNObject Get SR result */ function getSRDetailByID($srID) { if ($srID === null) { return $this->getResponseObject(null, null, 'Error occurs when getSRbyID :: invalid sr_id'); } // check if the SR has been cached in the in-process cache // If cached, save it in the session and return the SR. $cacheKey = 'sr_' . $srID; $srDetail = \RightNow\Utils\Framework::checkCache($cacheKey); if ($srDetail) { return $this->getResponseObject($srDetail, 'is_array'); } // if not cachaed, send request to Siebel server to get the SR, // and save in the session and cache $extObj = 'service_request_detail'; $extAction = 'read'; $requestParams = array('srID' => $srID); $requestFieldData = array('Id', 'Created', 'Abstract', 'ContactId', 'CustomerProductId', 'DefaultStatus', 'Description', 'OwnedById', 'Owner', 'Product', 'ProductId', 'SRNumber', 'SRType', 'SerialNumber', 'Severity', 'Status', 'Type', 'IntegrationId'); $responseFields = $requestFieldData; $errorFields = array('FAULTSTRING', 'X_MSG_DATA'); // send curl request $getSRResult = $this->CI->model('custom/SiebelApi')->sendSoapRequest($this->extConfigVerb, $extObj, $extAction, null, $this->contact, $requestParams, $requestFieldData, $responseFields, $errorFields); // check the result. if success, save SR in the in-process cache and the session if ($getSRResult->error === null) { \RightNow\Utils\Framework::setCache($cacheKey, $getSRResult->result, true); $sessionKey = $cacheKey; $this->CI->session->setSessionData(array($sessionKey => $getSRResult->result)); } return $getSRResult; }