diff --git a/app/code/community/PedroTeixeira/Correios/Model/Observer.php b/app/code/community/PedroTeixeira/Correios/Model/Observer.php index e531984..5fe635b 100644 --- a/app/code/community/PedroTeixeira/Correios/Model/Observer.php +++ b/app/code/community/PedroTeixeira/Correios/Model/Observer.php @@ -20,32 +20,67 @@ class PedroTeixeira_Correios_Model_Observer */ public function sroTrackingJob() { - $count = 0; - /* @var $sro PedroTeixeira_Correios_Model_Sro */ - $sro = Mage::getModel('pedroteixeira_correios/sro'); - if ($sro->getConfigData('sro_tracking_job') == 0) { - return "SRO Tracking Job disabled."; + $message = "SRO Tracking Job disabled."; + if (Mage::helper('pedroteixeira_correios')->getConfigData('sro_tracking_job') == 0) { + return $message; } - $collection = $sro->getShippedTracks(); - foreach ($collection as $track) { - /* @var $track Mage_Sales_Model_Order_Shipment_Track */ - if ($sro->request($track->getNumber())) { - $savedId = $track->getDescription(); - $eventId = $sro->getEventId(); - if ($eventId != $savedId) { - $track->setDescription($eventId)->save(); - $track->getShipment()->getOrder() - ->setStatus($sro->getStatus()) - ->save(); - $track->getShipment() - ->addComment($sro->getComment(), $sro->isNotify(), true) - ->sendUpdateEmail($sro->isNotify(), $sro->getEmailComment()) - ->save(); - $count++; + $message = "No tracking updates"; + $count = 0; + $countTrack = 0; + $trackList = array(); + $sro = Mage::getModel('pedroteixeira_correios/sro')->init(); + $response = $sro->request(); + + if ($response && $response->return->qtd > 0) { + $tracksTxn = Mage::getModel('core/resource_transaction'); + $ordersTxn = Mage::getModel('core/resource_transaction'); + $shipmentsTxn = Mage::getModel('core/resource_transaction'); + foreach ($response->return->objeto as $obj) { + if (isset($obj->erro)) { + Mage::log("{$obj->numero}: {$obj->erro}"); + continue; + } + + if ($track = $sro->getTrack($obj)) { + $savedId = $track->getDescription(); + $eventId = $sro->getEventId($obj); + if ($eventId != $savedId) { + $status = $sro->getStatus($obj); + $notify = $sro->isNotify($obj); + $comment = $sro->getComment($obj); + $mailComment = $sro->getEmailComment($obj, $track); + $tracksTxn->addObject( + $track->setDescription($eventId) + ); + $ordersTxn->addObject( + $track->getShipment()->getOrder()->setStatus($status) + ); + $shipmentsTxn->addObject( + $track->getShipment() + ->addComment($comment, $notify, true) + ->sendUpdateEmail($notify, $mailComment) + ); + Mage::log("{$obj->numero}: saving scheduled"); + $count++; + } + } + $countTrack++; + } + + if ($count) { + try { + $tracksTxn->save(); + $ordersTxn->save(); + $shipmentsTxn->save(); + $message = "Updated {$count} objects of {$countTrack} tracked."; + } catch (Exception $e) { + $message = $e->getMessage(); } } } - return "Tracked {$count} objects of {$collection->getSize()}."; + + Mage::log($message); + return $message; } } diff --git a/app/code/community/PedroTeixeira/Correios/Model/Sro.php b/app/code/community/PedroTeixeira/Correios/Model/Sro.php index c84a714..09f1108 100644 --- a/app/code/community/PedroTeixeira/Correios/Model/Sro.php +++ b/app/code/community/PedroTeixeira/Correios/Model/Sro.php @@ -16,14 +16,27 @@ class PedroTeixeira_Correios_Model_Sro extends Varien_Object const CARRIER_CODE = 'pedroteixeira_correios'; const ORDER_SHIPPED_STATUS = 'complete_shipped'; const ORDER_WARNED_STATUS = 'complete_warned'; - + + protected $_trackList = array(); + /** - * Request response + * Retrieves all valid tracking codes * - * @var SimpleXMLElement + * @return PedroTeixeira_Correios_Model_Sro */ - protected $_xml = null; - + public function init() + { + $collection = $this->getShippedTracks(); + foreach ($collection as $track) { + if ($this->validateTrackNumber($track->getNumber())) { + $this->_trackList[$track->getNumber()] = $track; + continue; + } + Mage::log("{$track->getNumber()}: invalid tracking code"); + } + return $this; + } + /** * Load all opened tracks from database. * Filter tracks only with complete order state, and shipped status. @@ -48,8 +61,6 @@ public function getShippedTracks() /** * Load XML response from Correios * - * @param string $trackingCode Tracking Code - * * @throws Exception * * @link http://www.correios.com.br/para-voce/correios-de-a-a-z/pdf/rastreamento-de-objetos/ @@ -57,31 +68,37 @@ public function getShippedTracks() * @link http://www.corporativo.correios.com.br/encomendas/sigepweb/doc/ * Manual_de_Implementacao_do_Web_Service_SIGEPWEB_Logistica_Reversa.pdf * - * @return boolean|PedroTeixeira_Correios_Model_Sro + * @return boolean|Correios_Rastro_BuscaEventosResponse */ - public function request($trackingCode) + public function request() { - $params = array( - 'usuario' => $this->getConfigData('sro_username'), - 'senha' => $this->getConfigData('sro_password'), - 'tipo' => $this->getConfigData('sro_type'), - 'resultado' => $this->getConfigData('sro_result'), - 'lingua' => $this->getConfigData('sro_language'), - 'objetos' => $trackingCode, - ); - - try { - $client = new SoapClient($this->getConfigData('url_sro_correios')); - $response = $client->buscaEventos($params); - if (empty($response)) { - throw new Exception("Empty response"); + $response = false; + if (count($this->_trackList)) { + $trackingCodes = implode('', array_keys($this->_trackList)); + $params = new Correios_Rastro_BuscaEventos( + $this->getConfigData('sro_username'), + $this->getConfigData('sro_password'), + $this->getConfigData('sro_type'), + $this->getConfigData('sro_result'), + $this->getConfigData('sro_language'), + $trackingCodes + ); + Mage::log(print_r($params, true)); + + try { + $client = new Correios_Rastro( + Mage::helper('pedroteixeira_correios')->getStreamContext(), + $this->getConfigData('url_sro_correios') + ); + $response = $client->buscaEventos($params); + if (empty($response)) { + throw new Exception("Empty response"); + } + } catch (Exception $e) { + Mage::log("Soap Error: {$e->getMessage()}"); } - $this->_xml = $response->return; - } catch (Exception $e) { - Mage::log("Soap Error: {$e->getMessage()}"); - return false; } - return $this; + return $response; } /** @@ -99,12 +116,14 @@ public function getConfigData($path) /** * Returns a Shipping comment message * + * @param Correios_Rastro_Objeto $obj Response Object + * * @return string */ - public function getComment() + public function getComment($obj) { - $code = $this->_xml->objeto->numero; - $evento = $this->_xml->objeto->evento; + $code = $obj->numero; + $evento = $obj->evento; $msg = array(); $msg[] = $code; $msg[] = "{$evento->cidade}/{$evento->uf}"; @@ -126,14 +145,17 @@ public function getComment() /** * Returns an Update Shipping e-mail comment * + * @param Correios_Rastro_Objeto $obj Response Object + * @param Mage_Sales_Model_Order_Shipment_Track $track Tracking instance + * * @return string */ - public function getEmailComment() + public function getEmailComment($obj, $track) { - $trackUrl = $this->getConfigData('url_tracking'); - $code = $this->_xml->objeto->numero; - $evento = $this->_xml->objeto->evento; - $htmlAnchor = "{$code}"; + $trackUrl = Mage::helper('shipping')->getTrackingPopupUrlBySalesModel($track); + $code = $obj->numero; + $evento = $obj->evento; + $htmlAnchor = "{$code}"; $msg = array(); $msg[] = Mage::helper('pedroteixeira_correios')->__('Rastreador: %s', $htmlAnchor); $msg[] = Mage::helper('pedroteixeira_correios')->__('Local: %s', "{$evento->cidade}/{$evento->uf}"); @@ -154,14 +176,15 @@ public function getEmailComment() /** * Check the event type * - * @param string $mode Event Type Mode + * @param Correios_Rastro_Objeto $obj Response Object + * @param string $mode Event Type Mode * * @return boolean */ - public function validate($mode) + public function validate($obj, $mode) { $isValid = false; - $evento = $this->_xml->objeto->evento; + $evento = $obj->evento; $hashTypes = explode(',', $this->getConfigData("sro_event_type_{$mode}")); if (in_array($evento->tipo, $hashTypes)) { $type = strtolower($evento->tipo); @@ -175,41 +198,85 @@ public function validate($mode) * Track Description field are now being used to save the event id. * Event Id is a simple key to identify the last carrier event. * + * @param Correios_Rastro_Objeto $obj Response Object + * * @return string */ - public function getEventId() + public function getEventId($obj) { - $code = $this->_xml->objeto->numero; - $date = $this->_xml->objeto->evento->data; - $hour = $this->_xml->objeto->evento->hora; - $type = $this->_xml->objeto->evento->tipo; - return "{$code}::{$date}{$hour}::{$type}"; + if ($obj->numero && $obj->evento) { + $code = $obj->numero; + $date = $obj->evento->data; + $hour = $obj->evento->hora; + $type = $obj->evento->tipo; + return "{$code}::{$date}{$hour}::{$type}"; + } + return false; } /** * Check whether event notify is enabled or not * + * @param Correios_Rastro_Objeto $obj Response Object + * * @return boolean */ - public function isNotify() + public function isNotify($obj) { - return $this->validate('notify'); + return $this->validate($obj, 'notify'); } /** * Load order status based on event checking * + * @param Correios_Rastro_Objeto $obj Response Object + * * @return string */ - public function getStatus() + public function getStatus($obj) { $status = self::ORDER_SHIPPED_STATUS; - if ($this->validate('warn')) { + if ($this->validate($obj, 'warn')) { $status = self::ORDER_WARNED_STATUS; } - if ($this->validate('last')) { + if ($this->validate($obj, 'last')) { $status = Mage_Sales_Model_Order::STATE_COMPLETE; } return $status; } + + /** + * Validates the tracking code + * + * @param string $trackNumber Tracking Code + * + * @return boolean + */ + public function validateTrackNumber($trackNumber) + { + return preg_match('/^[a-zA-Z]{2}[0-9]{9}[a-zA-Z]{2}$/', $trackNumber); + } + + /** + * Retrieves the tracking instance + * + * @param Correios_Rastro_Objeto $obj Return Object + * + * @throws Exception + * + * @return Mage_Sales_Model_Order_Shipment_Track + */ + public function getTrack($obj) + { + $track = $this->_trackList[$obj->numero]; + if (!($desc = $track->getDescription())) { + Mage::log("{$obj->numero}: tracking instance missed. Trying to reload"); + try { + $track = Mage::getModel('sales/order_shipment_track')->load($obj->numero, 'track_number'); + } catch (Exception $e) { + Mage::log("{$obj->numero}: {$e->getMessage()}"); + } + } + return $track; + } } diff --git a/app/lib/Correios/Rastro.php b/app/lib/Correios/Rastro.php new file mode 100644 index 0000000..c010236 --- /dev/null +++ b/app/lib/Correios/Rastro.php @@ -0,0 +1,80 @@ + + * @copyright 2015 Pedro Teixeira (http://pedroteixeira.io) + * @license http://opensource.org/licenses/MIT MIT + * @link https://github.com/pedro-teixeira/correios + */ +class Correios_Rastro extends SoapClient +{ + + /** + * @var array $classmap The defined classes + * @access private + */ + private static $classmap = array( + 'BuscaEventosLista' => 'Correios_Rastro_BuscaEventosLista', + 'BuscaEventosListaResponse' => 'Correios_Rastro_BuscaEventosListaResponse', + 'Sroxml' => 'Correios_Rastro_Sroxml', + 'Objeto' => 'Correios_Rastro_Objeto', + 'Eventos' => 'Correios_Rastro_Eventos', + 'Destinos' => 'Correios_Rastro_Destinos', + 'EnderecoMobile' => 'Correios_Rastro_EnderecoMobile', + 'BuscaEventos' => 'Correios_Rastro_BuscaEventos', + 'BuscaEventosResponse' => 'Correios_Rastro_BuscaEventosResponse' + ); + + /** + * Class constructor method + * + * @param array $options An array of config values + * @param string $wsdl The wsdl file to use + * + * @access public + */ + public function __construct(array $options = array(), $wsdl = 'Rastro.wsdl') + { + foreach (self::$classmap as $key => $value) { + if (!isset($options['classmap'][$key])) { + $options['classmap'][$key] = $value; + } + } + + parent::__construct($wsdl, $options); + } + + /** + * Request method for buscaEventos + * + * @param Correios_Rastro_BuscaEventos $parameters Parameters + * + * @access public + * + * @return Correios_Rastro_BuscaEventosResponse + */ + public function buscaEventos(Correios_Rastro_BuscaEventos $parameters) + { + return $this->__soapCall('buscaEventos', array($parameters)); + } + + /** + * Request method for buscaEventosLista + * + * @param Correios_Rastro_BuscaEventosLista $parameters Parameters + * + * @access public + * + * @return Correios_Rastro_BuscaEventosListaResponse + */ + public function buscaEventosLista(Correios_Rastro_BuscaEventosLista $parameters) + { + return $this->__soapCall('buscaEventosLista', array($parameters)); + } + +} diff --git a/app/lib/Correios/Rastro/BuscaEventos.php b/app/lib/Correios/Rastro/BuscaEventos.php new file mode 100644 index 0000000..b7714c4 --- /dev/null +++ b/app/lib/Correios/Rastro/BuscaEventos.php @@ -0,0 +1,75 @@ + + * @copyright 2015 Pedro Teixeira (http://pedroteixeira.io) + * @license http://opensource.org/licenses/MIT MIT + * @link https://github.com/pedro-teixeira/correios + */ +class Correios_Rastro_BuscaEventos +{ + + /** + * @var string $usuario + * @access public + */ + public $usuario = null; + + /** + * @var string $senha + * @access public + */ + public $senha = null; + + /** + * @var string $tipo + * @access public + */ + public $tipo = null; + + /** + * @var string $resultado + * @access public + */ + public $resultado = null; + + /** + * @var string $lingua + * @access public + */ + public $lingua = null; + + /** + * @var string $objetos + * @access public + */ + public $objetos = null; + + /** + * Class constructor method + * + * @param string $usuario Username + * @param string $senha Password + * @param string $tipo Type + * @param string $resultado Result + * @param string $lingua Language + * @param string $objetos Objects + * + * @access public + */ + public function __construct($usuario, $senha, $tipo, $resultado, $lingua, $objetos) + { + $this->usuario = $usuario; + $this->senha = $senha; + $this->tipo = $tipo; + $this->resultado = $resultado; + $this->lingua = $lingua; + $this->objetos = $objetos; + } + +} diff --git a/app/lib/Correios/Rastro/BuscaEventosLista.php b/app/lib/Correios/Rastro/BuscaEventosLista.php new file mode 100644 index 0000000..c8dd767 --- /dev/null +++ b/app/lib/Correios/Rastro/BuscaEventosLista.php @@ -0,0 +1,75 @@ + + * @copyright 2015 Pedro Teixeira (http://pedroteixeira.io) + * @license http://opensource.org/licenses/MIT MIT + * @link https://github.com/pedro-teixeira/correios + */ +class Correios_Rastro_BuscaEventosLista +{ + + /** + * @var string $usuario + * @access public + */ + public $usuario = null; + + /** + * @var string $senha + * @access public + */ + public $senha = null; + + /** + * @var string $tipo + * @access public + */ + public $tipo = null; + + /** + * @var string $resultado + * @access public + */ + public $resultado = null; + + /** + * @var string $lingua + * @access public + */ + public $lingua = null; + + /** + * @var string[] $objetos + * @access public + */ + public $objetos = null; + + /** + * Class constructor method + * + * @param string $usuario Username + * @param string $senha Password + * @param string $tipo Type + * @param string $resultado Result + * @param string $lingua Language + * @param string[] $objetos Object List + * + * @access public + */ + public function __construct($usuario, $senha, $tipo, $resultado, $lingua, $objetos) + { + $this->usuario = $usuario; + $this->senha = $senha; + $this->tipo = $tipo; + $this->resultado = $resultado; + $this->lingua = $lingua; + $this->objetos = $objetos; + } + +} diff --git a/app/lib/Correios/Rastro/BuscaEventosListaResponse.php b/app/lib/Correios/Rastro/BuscaEventosListaResponse.php new file mode 100644 index 0000000..eeb4253 --- /dev/null +++ b/app/lib/Correios/Rastro/BuscaEventosListaResponse.php @@ -0,0 +1,35 @@ + + * @copyright 2015 Pedro Teixeira (http://pedroteixeira.io) + * @license http://opensource.org/licenses/MIT MIT + * @link https://github.com/pedro-teixeira/correios + */ +class Correios_Rastro_BuscaEventosListaResponse +{ + + /** + * @var Correios_Rastro_Sroxml $return + * @access public + */ + public $return = null; + + /** + * Class constructor method + * + * @param Correios_Rastro_Sroxml $return Sroxml Object + * + * @access public + */ + public function __construct($return) + { + $this->return = $return; + } + +} diff --git a/app/lib/Correios/Rastro/BuscaEventosResponse.php b/app/lib/Correios/Rastro/BuscaEventosResponse.php new file mode 100644 index 0000000..57042c5 --- /dev/null +++ b/app/lib/Correios/Rastro/BuscaEventosResponse.php @@ -0,0 +1,35 @@ + + * @copyright 2015 Pedro Teixeira (http://pedroteixeira.io) + * @license http://opensource.org/licenses/MIT MIT + * @link https://github.com/pedro-teixeira/correios + */ +class Correios_Rastro_BuscaEventosResponse +{ + + /** + * @var Correios_Rastro_Sroxml $return + * @access public + */ + public $return = null; + + /** + * Class constructor method + * + * @param Correios_Rastro_Sroxml $return Sroxml Object + * + * @access public + */ + public function __construct($return) + { + $this->return = $return; + } + +} diff --git a/app/lib/Correios/Rastro/Destinos.php b/app/lib/Correios/Rastro/Destinos.php new file mode 100644 index 0000000..70cbe29 --- /dev/null +++ b/app/lib/Correios/Rastro/Destinos.php @@ -0,0 +1,67 @@ + + * @copyright 2015 Pedro Teixeira (http://pedroteixeira.io) + * @license http://opensource.org/licenses/MIT MIT + * @link https://github.com/pedro-teixeira/correios + */ +class Correios_Rastro_Destinos +{ + + /** + * @var string $local + * @access public + */ + public $local = null; + + /** + * @var string $codigo + * @access public + */ + public $codigo = null; + + /** + * @var string $cidade + * @access public + */ + public $cidade = null; + + /** + * @var string $bairro + * @access public + */ + public $bairro = null; + + /** + * @var string $uf + * @access public + */ + public $uf = null; + + /** + * Class constructor method + * + * @param string $local Local + * @param string $codigo Code + * @param string $cidade City + * @param string $bairro Address + * @param string $uf Region Code + * + * @access public + */ + public function __construct($local, $codigo, $cidade, $bairro, $uf) + { + $this->local = $local; + $this->codigo = $codigo; + $this->cidade = $cidade; + $this->bairro = $bairro; + $this->uf = $uf; + } + +} diff --git a/app/lib/Correios/Rastro/EnderecoMobile.php b/app/lib/Correios/Rastro/EnderecoMobile.php new file mode 100644 index 0000000..724e4c1 --- /dev/null +++ b/app/lib/Correios/Rastro/EnderecoMobile.php @@ -0,0 +1,116 @@ + + * @copyright 2015 Pedro Teixeira (http://pedroteixeira.io) + * @license http://opensource.org/licenses/MIT MIT + * @link https://github.com/pedro-teixeira/correios + */ +class Correios_Rastro_EnderecoMobile +{ + + /** + * @var string $codigo + * @access public + */ + public $codigo = null; + + /** + * @var string $cep + * @access public + */ + public $cep = null; + + /** + * @var string $logradouro + * @access public + */ + public $logradouro = null; + + /** + * @var string $complemento + * @access public + */ + public $complemento = null; + + /** + * @var string $numero + * @access public + */ + public $numero = null; + + /** + * @var string $localidade + * @access public + */ + public $localidade = null; + + /** + * @var string $uf + * @access public + */ + public $uf = null; + + /** + * @var string $bairro + * @access public + */ + public $bairro = null; + + /** + * @var string $latitude + * @access public + */ + public $latitude = null; + + /** + * @var string $longitude + * @access public + */ + public $longitude = null; + + /** + * @var string $celular + * @access public + */ + public $celular = null; + + /** + * Class constructor method + * + * @param string $codigo Code + * @param string $cep Zip + * @param string $logradouro Street + * @param string $complemento Street 2 + * @param string $numero Number + * @param string $localidade Region + * @param string $uf Region Code + * @param string $bairro Address + * @param string $latitude Latitude + * @param string $longitude Longitude + * @param string $celular Cellphone + * + * @access public + */ + public function __construct( + $codigo, $cep, $logradouro, $complemento, $numero, $localidade, $uf, $bairro, $latitude, $longitude, $celular) + { + $this->codigo = $codigo; + $this->cep = $cep; + $this->logradouro = $logradouro; + $this->complemento = $complemento; + $this->numero = $numero; + $this->localidade = $localidade; + $this->uf = $uf; + $this->bairro = $bairro; + $this->latitude = $latitude; + $this->longitude = $longitude; + $this->celular = $celular; + } + +} diff --git a/app/lib/Correios/Rastro/Eventos.php b/app/lib/Correios/Rastro/Eventos.php new file mode 100644 index 0000000..dd90f49 --- /dev/null +++ b/app/lib/Correios/Rastro/Eventos.php @@ -0,0 +1,173 @@ + + * @copyright 2015 Pedro Teixeira (http://pedroteixeira.io) + * @license http://opensource.org/licenses/MIT MIT + * @link https://github.com/pedro-teixeira/correios + */ +class Correios_Rastro_Eventos +{ + + /** + * @var string $tipo + * @access public + */ + public $tipo = null; + + /** + * @var string $status + * @access public + */ + public $status = null; + + /** + * @var string $data + * @access public + */ + public $data = null; + + /** + * @var string $hora + * @access public + */ + public $hora = null; + + /** + * @var string $descricao + * @access public + */ + public $descricao = null; + + /** + * @var string $detalhe + * @access public + */ + public $detalhe = null; + + /** + * @var string $recebedor + * @access public + */ + public $recebedor = null; + + /** + * @var string $documento + * @access public + */ + public $documento = null; + + /** + * @var string $comentario + * @access public + */ + public $comentario = null; + + /** + * @var string $local + * @access public + */ + public $local = null; + + /** + * @var string $codigo + * @access public + */ + public $codigo = null; + + /** + * @var string $cidade + * @access public + */ + public $cidade = null; + + /** + * @var string $uf + * @access public + */ + public $uf = null; + + /** + * @var string $sto + * @access public + */ + public $sto = null; + + /** + * @var string $amazoncode + * @access public + */ + public $amazoncode = null; + + /** + * @var string $amazontimezone + * @access public + */ + public $amazontimezone = null; + + /** + * @var Correios_Rastro_Destinos $destino + * @access public + */ + public $destino = null; + + /** + * @var Correios_Rastro_EnderecoMobile $endereco + * @access public + */ + public $endereco = null; + + /** + * Class constructor method + * + * @param string $tipo Type + * @param string $status State + * @param string $data Date + * @param string $hora Hour + * @param string $descricao Description + * @param string $detalhe Detail + * @param string $recebedor Receiver + * @param string $documento Document + * @param string $comentario Comment + * @param string $local Local + * @param string $codigo Code + * @param string $cidade City + * @param string $uf State + * @param string $sto Sto + * @param string $amazoncode Amazon Code + * @param string $amazontimezone Amazon Timezone + * @param Correios_Rastro_Destinos $destino Destination + * @param Correios_Rastro_EnderecoMobile $endereco Address + * + * @access public + */ + public function __construct( + $tipo, $status, $data, $hora, $descricao, $detalhe, $recebedor, $documento, $comentario, $local, $codigo, + $cidade, $uf, $sto, $amazoncode, $amazontimezone, $destino, $endereco) + { + $this->tipo = $tipo; + $this->status = $status; + $this->data = $data; + $this->hora = $hora; + $this->descricao = $descricao; + $this->detalhe = $detalhe; + $this->recebedor = $recebedor; + $this->documento = $documento; + $this->comentario = $comentario; + $this->local = $local; + $this->codigo = $codigo; + $this->cidade = $cidade; + $this->uf = $uf; + $this->sto = $sto; + $this->amazoncode = $amazoncode; + $this->amazontimezone = $amazontimezone; + $this->destino = $destino; + $this->endereco = $endereco; + } + +} diff --git a/app/lib/Correios/Rastro/Objeto.php b/app/lib/Correios/Rastro/Objeto.php new file mode 100644 index 0000000..ec0f602 --- /dev/null +++ b/app/lib/Correios/Rastro/Objeto.php @@ -0,0 +1,75 @@ + + * @copyright 2015 Pedro Teixeira (http://pedroteixeira.io) + * @license http://opensource.org/licenses/MIT MIT + * @link https://github.com/pedro-teixeira/correios + */ +class Correios_Rastro_Objeto +{ + + /** + * @var string $numero + * @access public + */ + public $numero = null; + + /** + * @var string $sigla + * @access public + */ + public $sigla = null; + + /** + * @var string $nome + * @access public + */ + public $nome = null; + + /** + * @var string $categoria + * @access public + */ + public $categoria = null; + + /** + * @var string $erro + * @access public + */ + public $erro = null; + + /** + * @var Correios_Rastro_Eventos $evento + * @access public + */ + public $evento = null; + + /** + * Class constructor method + * + * @param string $numero Number + * @param string $sigla Initials + * @param string $nome Name + * @param string $categoria Category + * @param string $erro Error + * @param Correios_Rastro_Eventos $evento Event + * + * @access public + */ + public function __construct($numero, $sigla, $nome, $categoria, $erro, $evento) + { + $this->numero = $numero; + $this->sigla = $sigla; + $this->nome = $nome; + $this->categoria = $categoria; + $this->erro = $erro; + $this->evento = $evento; + } + +} diff --git a/app/lib/Correios/Rastro/Sroxml.php b/app/lib/Correios/Rastro/Sroxml.php new file mode 100644 index 0000000..41eee51 --- /dev/null +++ b/app/lib/Correios/Rastro/Sroxml.php @@ -0,0 +1,67 @@ + + * @copyright 2015 Pedro Teixeira (http://pedroteixeira.io) + * @license http://opensource.org/licenses/MIT MIT + * @link https://github.com/pedro-teixeira/correios + */ +class Correios_Rastro_Sroxml +{ + + /** + * @var string $versao + * @access public + */ + public $versao = null; + + /** + * @var string $qtd + * @access public + */ + public $qtd = null; + + /** + * @var string $TipoPesquisa + * @access public + */ + public $TipoPesquisa = null; + + /** + * @var string $TipoResultado + * @access public + */ + public $TipoResultado = null; + + /** + * @var Correios_Rastro_Objeto $objeto + * @access public + */ + public $objeto = null; + + /** + * Class constructor method + * + * @param string $versao Release + * @param string $qtd Quantity + * @param string $TipoPesquisa Search Type + * @param string $TipoResultado Result Type + * @param Correios_Rastro_Objeto $objeto Object + * + * @access public + */ + public function __construct($versao, $qtd, $TipoPesquisa, $TipoResultado, $objeto) + { + $this->versao = $versao; + $this->qtd = $qtd; + $this->TipoPesquisa = $TipoPesquisa; + $this->TipoResultado = $TipoResultado; + $this->objeto = $objeto; + } + +}