Example #1
0
 public function createXml()
 {
     $xml = parent::createXml();
     $msgType = $this->getHeaderField('MSG_TYPE');
     $xml->{$msgType}->donor = $this->getBodyField('DONOR');
     return $xml;
 }
Example #2
0
 /**
  * method to create xml from the request
  * 
  * @return SimpleXml xml object
  */
 public function createXml()
 {
     $xml = parent::createXml();
     $msgType = $this->getHeaderField('MSG_TYPE');
     $xml->{$msgType}->portingDateTime = Application_Model_General::getDateTimeIso($this->getBodyField('PORT_TIME'));
     return $xml;
 }
Example #3
0
 public function createXml()
 {
     $xml = parent::createXml();
     $msgType = $this->getHeaderField('MSG_TYPE');
     $xml->{$msgType} = "";
     return $xml;
 }
Example #4
0
 public function createXml()
 {
     $xml = parent::createXml();
     $msgType = $this->getHeaderField('MSG_TYPE');
     $this->addApprovalXml($xml, $msgType);
     $this->addTrxNoXml($xml, $msgType);
     return $xml;
 }
Example #5
0
 public function createXml()
 {
     $xml = parent::createXml();
     $msgType = $this->getHeaderField('MSG_TYPE');
     $networkType = Application_Model_General::getSettings("NetworkType");
     $numberType = $this->getBodyField('NUMBER_TYPE');
     $requestId = $this->getHeaderField('REQUEST_ID');
     $requestRecord = Application_Model_General::getFieldFromRequests(array('flags', 'transfer_time'), $requestId, 'request_id');
     $flags = json_decode($requestRecord['flags'], true);
     if (empty($numberType)) {
         $numberType = isset($flags['number_type']) ? $flags['number_type'] : Application_Model_General::getSettings("NumberType");
     }
     $number = $this->getBodyField('NUMBER');
     $portTime = Application_Model_General::getDateTimeIso($requestRecord['transfer_time']);
     $process_type = $this->getHeaderField('PROCESS_TYPE');
     if ($process_type == "PORT") {
         $path =& $xml->{$msgType}->updateRequestType;
         $path->updateType = "REQUEST";
         $path->portingDateTime = $portTime;
     } else {
         if ($process_type == "CANCEL") {
             $path =& $xml->{$msgType}->updateCancelTypeType;
             $path->updateType = "CANCEL";
             $path->portingDateTime = $portTime;
         } else {
             if ($process_type == "UPDATE") {
                 $path =& $xml->{$msgType}->updateUpdateTypeType;
                 $path->updateType = "UPDATE";
                 $path->portingDateTime = $portTime;
             }
         }
     }
     if ($networkType === "M") {
         $networkType = "mobile";
     } else {
         $networkType = "fixed";
     }
     $path->{$networkType};
     $path->{$networkType}->networkType = "M";
     if ($numberType === "I") {
         $path->{$networkType}->mobileNumberIdentified;
         $path->{$networkType}->mobileNumberIdentified->numberType = $numberType;
         $path->{$networkType}->mobileNumberIdentified->identificationValue = isset($flags['identification_value']) ? $flags['identification_value'] : 'default';
         $path->{$networkType}->mobileNumberIdentified->identificationValue2nd = 'default';
         $path->{$networkType}->mobileNumberIdentified->identificationValue3rd = 'default';
         $path->{$networkType}->mobileNumberIdentified->number = $number;
     } else {
         $path->{$networkType}->mobileNumberUnidentified;
         $path->{$networkType}->mobileNumberUnidentified->numberType = $numberType;
         $path->{$networkType}->mobileNumberUnidentified->number = $number;
     }
     return $xml;
 }
Example #6
0
 /**
  * Constructor
  * 
  * Checks if message is soap or not 
  * 
  * @param array $params
  * @return void 
  */
 public function __construct($params)
 {
     //check if this is a soap request
     if (is_object($params) && isset($params->NP_MESSAGE)) {
         $this->request = Np_Method::getInstance($params);
         $this->data = $params;
         if (!isset($this->data['PHONE_NUMBER'])) {
             $this->data['PHONE_NUMBER'] = Application_Model_General::getFieldFromRequests("phone_number", $params['REQUEST_ID']);
         }
     } else {
         if (is_array($params)) {
             // this is internal and not external (soap)
             if (isset($params['MANUAL']) && $params['MANUAL']) {
                 $fields = array('last_transaction', 'from_provider', 'to_provider');
                 $values = Application_Model_General::getFieldFromRequests($fields, $params['REQUEST_ID'], 'request_id');
                 if ($values['last_transaction'] != $params['MSG_TYPE'] && $values['last_transaction'] != $params['MSG_TYPE'] . '_response') {
                     $response = array('success' => 0, 'error' => 1, 'manual' => 1, 'desc' => 'The request is not at the right stage');
                     die(json_encode($response));
                 }
                 if (!isset($params['FROM']) || !isset($params['TO'])) {
                     $params['FROM'] = $values['to_provider'];
                     $params['TO'] = $values['from_provider'];
                 }
                 if (!isset($params['TRX_NO'])) {
                     $transaction = Application_Model_General::getTransactions($params['REQUEST_ID'], $params['MSG_TYPE']);
                     $params['TRX_NO'] = $transaction[0]['trx_no'];
                     $params['RETRY_DATE'] = Application_Model_General::getDateTimeIso($transaction[0]['last_transaction_time']);
                 }
                 $this->data = $params;
             } else {
                 if (is_array($params)) {
                     // we are receiving data => need to send to provider
                     if (!isset($params['REQUEST_ID']) && $params['MSG_TYPE'] != "Check" && isset($params['PHONE_NUMBER'])) {
                         //CALL FROM INTERNAL WITH NO REQUEST ID
                         //if the type is check the request id will be added later- on insert to DB
                         $params['REQUEST_ID'] = Application_Model_General::getFieldFromRequests("request_id", $params['PHONE_NUMBER']);
                     }
                     $this->data = $params;
                 } else {
                     //no parameters
                     $this->data = NULL;
                     $this->request = NULL;
                     return;
                 }
             }
             $this->request = Np_Method::getInstance($this->data);
         }
     }
 }
Example #7
0
 /**
  * method to create xml from the request
  * 
  * @return SimpleXml xml object
  */
 public function createXml()
 {
     $xml = parent::createXml();
     $msgType = $this->getHeaderField('MSG_TYPE');
     $numberType = $this->getBodyField('NUMBER_TYPE');
     $xml->{$msgType}->number = $this->getBodyField('NUMBER');
     if (Application_Model_General::getSettings("NetworkType") === "M") {
         $xml->{$msgType}->mobile;
         $xml->{$msgType}->mobile->networkType = "M";
         $xml->{$msgType}->mobile->numberType = $numberType;
     } else {
         $xml->{$msgType}->fixed->networkType = "M";
         $xml->{$msgType}->fixed->numberType = $numberType;
     }
     return $xml;
 }
Example #8
0
 public function createXml()
 {
     $xml = parent::createXml();
     $msgType = $this->getHeaderField('MSG_TYPE');
     $networkType = Application_Model_General::getSettings("NetworkType");
     $xml->{$msgType}->donor = $this->getBodyField('DONOR');
     $xml->{$msgType}->connectDateTime = Application_Model_General::getDateTimeIso($this->getBodyField('CONNECT_TIME'));
     $xml->{$msgType}->publishType = $this->getBodyField('PUBLISH_TYPE');
     $xml->{$msgType}->disconnectDateTime = Application_Model_General::getDateTimeIso($this->getBodyField('DISCONNECT_TIME'));
     if ($networkType === "M") {
         $xml->{$msgType}->mobile;
         $xml->{$msgType}->mobile->numberType = "I";
         $xml->{$msgType}->mobile->number = $this->getBodyField("NUMBER");
     } else {
         $xml->{$msgType}->fixed->fixedNumberSingle;
     }
     return $xml;
 }
Example #9
0
 /**
  * create data to post to the internal
  * 
  * @param Np_Method $request the request to create post data from
  * 
  * @return void
  * 
  * @todo refatoring to bridge classes
  */
 protected function createPostData(Np_Method $request)
 {
     $ack = $request->getAck();
     $rejectReasonCode = $request->getRejectReasonCode();
     $idValue = $request->getIDValue();
     if ($this->params['FROM'] != Application_Model_General::getSettings('InternalProvider')) {
         $provider = $this->params['FROM'];
     } else {
         $provider = $this->params['TO'];
     }
     if (!$rejectReasonCode || $rejectReasonCode === "" || $rejectReasonCode == " ") {
         $rejectReasonCode = "OK";
     }
     if (empty($idValue)) {
         $idValue = "no details";
     }
     $ret = array('number' => $this->params['PHONE_NUMBER'], 'provider' => $provider, 'msg_type' => $this->params['MSG_TYPE'], 'msgType' => $this->params['MSG_TYPE'], 'reqId' => $this->params['REQUEST_ID'], 'more' => array('identification_value' => $idValue, 'resultCode' => $rejectReasonCode, 'ack' => $ack));
     if (isset($this->params['PHONE_NUMBER'])) {
         $ret['number'] = $ret['phone_number'] = $this->params['PHONE_NUMBER'];
     }
     if (isset($this->params['NUMBER_TYPE'])) {
         $ret['more']['number_type'] = $this->params['NUMBER_TYPE'];
         if ($ret['more']['number_type'] == "R") {
             unset($ret['number'], $ret['phone_number']);
             $ret['more']['to_number'] = $this->params['TO_NUMBER'];
             $ret['more']['from_number'] = $this->params['FROM_NUMBER'];
         }
     }
     if (Application_Model_General::isMsgResponse($this->params['MSG_TYPE'])) {
         $ret['more']['approval_ind'] = $this->params['APPROVAL_IND'];
     }
     $msg_type = strtoupper($this->params['MSG_TYPE']);
     if ($msg_type == "KD_UPDATE_RESPONSE") {
         $ret['more']['KD_update_type'] = $this->params['KD_UPDATE_TYPE'];
     }
     if ($msg_type == "EXECUTE_RESPONSE" && isset($this->params['DISCONNECT_TIME'])) {
         $ret['more']['disconnect_time'] = $this->params['DISCONNECT_TIME'];
     }
     if ($msg_type == "REQUEST" || $msg_type == "UPDATE") {
         if (!is_numeric($this->params['PORT_TIME'])) {
             // convert to unix timestamp in case is format as full datetime
             $transfer_time = strtotime($this->params['PORT_TIME']);
         } else {
             $transfer_time = $this->params['PORT_TIME'];
         }
         // all the cases for backward compatibility
         $ret['port_time'] = $ret['more']['port_time'] = $ret['transfer_time'] = $ret['more']['transfer_time'] = $transfer_time;
     }
     if (isset($ret['more']['approval_ind']) && $ret['more']['approval_ind'] == 'Y' && ($msg_type == "REQUEST_RESPONSE" || $msg_type == "UPDATE_RESPONSE") && Application_Model_General::getSettings('InternalProvider') == $this->params['TO']) {
         $transfer_time = Application_Model_General::getFieldFromRequests('transfer_time', $this->params['REQUEST_ID'], 'request_id');
         $ret['more']['transfer_time'] = Application_Model_General::getDateTimeInTimeStamp($transfer_time);
     }
     if ($msg_type == "PUBLISH") {
         $ret['more']['donor'] = $this->params['DONOR'];
         $ret['more']['publish_type'] = $this->params['PUBLISH_TYPE'];
         if (isset($this->params['DISCONNECT_TIME'])) {
             $ret['more']['disconnect_time'] = $this->params['DISCONNECT_TIME'];
         }
         if (isset($this->params['CONNECT_TIME'])) {
             $ret['more']['connect_time'] = $this->params['CONNECT_TIME'];
         }
     }
     if ($msg_type == "CANCEL_PUBLISH") {
         $ret['more']['donor'] = $this->params['DONOR'];
     }
     if ($msg_type == "PUBLISH_RESPONSE") {
         $ret['more']['approval_ind'] = $this->params['APPROVAL_IND'];
         if (isset($this->params['ROUTE_TIME'])) {
             $ret['more']['route_time'] = Application_Model_General::getDateTimeInSqlFormat($this->params['ROUTE_TIME']);
         }
     }
     if ($msg_type == "CANCEL_PUBLISH_RESPONSE") {
         $ret['more']['msg_type'] = "Cancel_Publish_response";
         $ret['more']['approval_ind'] = $this->params['APPROVAL_IND'];
         $ret['more']['route_time'] = Application_Model_General::getDateTimeInSqlFormat($this->params['ROUTE_TIME']);
     }
     if ($msg_type == "INQUIRE_NUMBER_RESPONSE") {
         $ret['more']['approval_ind'] = $this->params['APPROVAL_IND'];
         $ret['more']['current_operator'] = isset($this->params['CURRENT_OPERATOR']) ? $this->params['CURRENT_OPERATOR'] : '  ';
     }
     if ($msg_type == "DB_SYNCH_REQUEST") {
         $ret['more']['from_date'] = $this->params['FROM_DATE'];
         $ret['more']['to_date'] = $this->params['TO_DATE'];
     }
     if ($msg_type == "DB_SYNCH_RESPONSE") {
         $ret['more']['file_name'] = $this->params['FILE_NAME'];
     }
     // let's keep on backward backward compatibility (b/c) - all more fields should be also in the root
     foreach ($ret['more'] as $k => $v) {
         if (!isset($ret[$k])) {
             $ret[$k] = $v;
         }
     }
     // b/c
     if (!isset($ret['msgDesc'])) {
         $ret['desc'] = '';
     }
     // b/c
     if (!isset($ret['more']['msgDesc'])) {
         $ret['more']['msgDesc'] = '';
     }
     return $ret;
 }
Example #10
0
 /**
  * method to create xml from the request
  * 
  * @return SimpleXml xml object
  */
 public function createXml()
 {
     $xml = parent::createXml();
     $networkType = Application_Model_General::getSettings("NetworkType");
     $numberType = $this->getBodyField('NUMBER_TYPE');
     $msgType = $this->getHeaderField('MSG_TYPE');
     $number = $this->getBodyField('NUMBER');
     if ($networkType === "M") {
         $networkType = "mobile";
     } else {
         $networkType = "fixed";
     }
     $xml->{$msgType}->{$networkType};
     $xml->{$msgType}->{$networkType}->networkType = "M";
     if ($numberType === "I") {
         $xml->{$msgType}->{$networkType}->mobileNumberIdentified->numberType = $numberType;
         $xml->{$msgType}->{$networkType}->mobileNumberIdentified->identificationValue = $this->getBodyField('IDENTIFICATION_VALUE');
         $xml->{$msgType}->{$networkType}->mobileNumberIdentified->identificationValue2nd = '';
         $xml->{$msgType}->{$networkType}->mobileNumberIdentified->identificationValue3rd = '';
         $xml->{$msgType}->{$networkType}->mobileNumberIdentified->number = $number;
     } else {
         $xml->{$msgType}->{$networkType}->mobileNumberUnidentified->numberType = $numberType;
         $xml->{$msgType}->{$networkType}->mobileNumberUnidentified->number = $number;
     }
     return $xml;
 }