| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- <?php
- namespace ModulesGarden\Servers\ZimbraEmail\App\Libs\Zimbra\Components\Api\Soap;
- use ModulesGarden\Servers\ZimbraEmail\App\Libs\Zimbra\Components\Api\Soap\Helpers\XmlParser;
- /**
- *
- * Created by PhpStorm.
- * User: Tomasz Bielecki ( tomasz.bi@modulesgarden.com )
- * Date: 05.09.19
- * Time: 10:51
- * Class Response
- */
- class Response
- {
- protected $request;
- protected $options;
- protected $params;
- protected $headers;
- protected $xmlResponse;
- protected $responseHead;
- protected $responseBody;
- protected $responseModel;
- protected $lastError;
- protected $errors = [];
- /**
- * @return mixed
- */
- public function getRequest()
- {
- return $this->request;
- }
- /**
- * @param $request
- * @return $this
- */
- public function setRequest($request)
- {
- $this->request = $request;
- return $this;
- }
- /**
- * @return mixed
- */
- public function getOptions()
- {
- return $this->options;
- }
- /**
- * @param $options
- * @return $this
- */
- public function setOptions($options)
- {
- $this->options = $options;
- return $this;
- }
- /**
- * @return mixed
- */
- public function getParams()
- {
- return $this->params;
- }
- /**
- * @param $params
- * @return $this
- */
- public function setParams($params)
- {
- $this->params = $params;
- return $this;
- }
- /**
- * @return mixed
- */
- public function getHeaders()
- {
- return $this->headers;
- }
- /**
- * @param $headers
- * @return $this
- */
- public function setHeaders($headers)
- {
- $this->headers = $headers;
- return $this;
- }
- /**
- * @return mixed
- */
- public function getXmlResponse()
- {
- return $this->xmlResponse;
- }
- /**
- * @param $xmlResponse
- * @return $this
- */
- public function setXmlResponse($xmlResponse)
- {
- $this->xmlResponse = $xmlResponse;
- return $this;
- }
- /**
- * @return mixed
- */
- public function getResponseBody()
- {
- return $this->responseBody;
- }
- /**
- * @return mixed
- */
- public function getResponseModel()
- {
- return $this->responseModel;
- }
- /**
- * @param $responseModel
- * @return $this
- */
- public function setResponseModel($responseModel)
- {
- $this->responseModel = $responseModel;
- return $this;
- }
- /**
- *
- */
- public function getLastError()
- {
- return $this->lastError;
- }
- /**
- * @param $lastError
- */
- public function setLastError($lastError)
- {
- //todo save to file
- $this->errors[] = $lastError;
- $this->lastError = $lastError;
- }
- /**
- * @return bool
- */
- public function getLastErrorCode()
- {
- if($code = $this->responseBody['SOAP:FAULT']['SOAP:DETAIL']['ERROR']['CODE']['DATA'])
- {
- return $code;
- }
- return false;
- }
- /**
- * Parse response
- *
- * @return $this
- */
- public function response()
- {
- /**
- * xml parse response
- */
- $xml = new XmlParser();
- $array = $xml->parse($this->xmlResponse);
- /**
- * set response header
- */
- $this->responseHead = $array['SOAP:ENVELOPE']['SOAP:HEADER'];
- /**
- * set response body
- */
- $this->responseBody = $array['SOAP:ENVELOPE']['SOAP:BODY'];
- return $this;
- }
- }
|