From 23340bfc84af7e7d5289e239bf81ed8efd7990b0 Mon Sep 17 00:00:00 2001 From: Pedro Teixeira Date: Tue, 16 May 2017 19:30:16 +0200 Subject: [PATCH 01/15] #252 Fix migrations --- CHANGELOG.md | 6 + .../install-4.8.0.php | 118 ++++++------------ .../install-4.8.1.php | 100 ++++++--------- .../upgrade-4.7.2-4.8.0.php | 96 -------------- .../upgrade-4.8.0-4.8.1.php | 91 ++++++++++++++ 5 files changed, 177 insertions(+), 234 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f760ff2..44cebf5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# v4.8.1 + +### Bugfix + +- [#252](https://github.com/pedro-teixeira/correios/issues/252) Corrige atualizações das versões 4.7.1 e 4.7.2 + # v4.8.0 ### Bugfix diff --git a/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/install-4.8.0.php b/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/install-4.8.0.php index 2d475e0..711cadf 100644 --- a/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/install-4.8.0.php +++ b/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/install-4.8.0.php @@ -138,112 +138,74 @@ } -$installer->run( - "CREATE TABLE IF NOT EXISTS {$this->getTable('pedroteixeira_correios/postmethod')} ( - method_id int(11) unsigned NOT NULL auto_increment, - method_code varchar(5) NOT NULL default '0', - method_title varchar(255) NOT NULL default '', - PRIMARY KEY (method_id) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" -); - -$installer->getConnection()->insertForce( - $this->getTable('pedroteixeira_correios/postmethod'), - array( - 'method_id' => '1', - 'method_code' => '41106', - 'method_title' => 'PAC SEM CONTRATO', - ) -); - -$installer->getConnection()->insertForce( - $this->getTable('pedroteixeira_correios/postmethod'), +$tableName = $this->getTable('pedroteixeira_correios/postmethod'); +$table = $installer->getConnection() + ->newTable($tableName) + ->addColumn('method_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( + 'identity' => true, + 'unsigned' => true, + 'nullable' => false, + 'primary' => true, + ), 'ID') + ->addColumn('method_code', Varien_Db_Ddl_Table::TYPE_TEXT, 5, array( + 'nullable' => false, + 'default' => '0' + ), 'Code') + ->addColumn('method_title', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array( + 'nullable' => false, + 'default' => '' + ), 'Title') + ->addIndex( + $installer->getIdxName( + $tableName, + array('method_code'), + Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE + ), + array('method_code'), + array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE)); +$installer->getConnection()->createTable($table); + +$services = array( array( - 'method_id' => '2', - 'method_code' => '40010', - 'method_title' => 'SEDEX SEM CONTRATO', - ) -); - -$installer->getConnection()->insertForce( - $this->getTable('pedroteixeira_correios/postmethod'), - array( - 'method_id' => '3', 'method_code' => '40045', 'method_title' => 'SEDEX A COBRAR SEM CONTRATO', - ) -); - -$installer->getConnection()->insertForce( - $this->getTable('pedroteixeira_correios/postmethod'), + ), array( - 'method_id' => '4', 'method_code' => '40215', 'method_title' => 'SEDEX 10 SEM CONTRATO', - ) -); - -$installer->getConnection()->insertForce( - $this->getTable('pedroteixeira_correios/postmethod'), + ), array( - 'method_id' => '5', 'method_code' => '40290', 'method_title' => 'SEDEX HOJE SEM CONTRATO', - ) -); - -$installer->getConnection()->insertForce( - $this->getTable('pedroteixeira_correios/postmethod'), + ), array( - 'method_id' => '6', 'method_code' => '04510', 'method_title' => 'PAC SEM CONTRATO', - ) -); - -$installer->getConnection()->insertForce( - $this->getTable('pedroteixeira_correios/postmethod'), + ), array( - 'method_id' => '7', 'method_code' => '04014', 'method_title' => 'SEDEX SEM CONTRATO', - ) -); - -$installer->getConnection()->insertForce( - $this->getTable('pedroteixeira_correios/postmethod'), + ), array( - 'method_id' => '8', 'method_code' => '04669', 'method_title' => 'PAC CONTRATO AGENCIA', - ) -); - -$installer->getConnection()->insertForce( - $this->getTable('pedroteixeira_correios/postmethod'), + ), array( - 'method_id' => '9', 'method_code' => '04162', 'method_title' => 'SEDEX CONTRATO AGENCIA', - ) -); - -$installer->getConnection()->insertForce( - $this->getTable('pedroteixeira_correios/postmethod'), + ), array( - 'method_id' => '10', 'method_code' => '04693', 'method_title' => 'PAC CONTRATO GRANDES FORMATOS', - ) -); - -$installer->getConnection()->insertForce( - $this->getTable('pedroteixeira_correios/postmethod'), + ), array( - 'method_id' => '11', 'method_code' => '10065', 'method_title' => 'CARTA COMERCIAL A FATURAR', ) ); +foreach ($services as $service) { + $installer->getConnection()->insertOnDuplicate($tableName, $service, array('method_code')); +} + $installer->endSetup(); diff --git a/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/install-4.8.1.php b/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/install-4.8.1.php index 9b1794f..711cadf 100644 --- a/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/install-4.8.1.php +++ b/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/install-4.8.1.php @@ -138,94 +138,74 @@ } -$installer->run( - "CREATE TABLE IF NOT EXISTS {$this->getTable('pedroteixeira_correios/postmethod')} ( - method_id int(11) unsigned NOT NULL auto_increment, - method_code varchar(5) NOT NULL default '0', - method_title varchar(255) NOT NULL default '', - PRIMARY KEY (method_id) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" -); - -$installer->getConnection()->insertForce( - $this->getTable('pedroteixeira_correios/postmethod'), +$tableName = $this->getTable('pedroteixeira_correios/postmethod'); +$table = $installer->getConnection() + ->newTable($tableName) + ->addColumn('method_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( + 'identity' => true, + 'unsigned' => true, + 'nullable' => false, + 'primary' => true, + ), 'ID') + ->addColumn('method_code', Varien_Db_Ddl_Table::TYPE_TEXT, 5, array( + 'nullable' => false, + 'default' => '0' + ), 'Code') + ->addColumn('method_title', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array( + 'nullable' => false, + 'default' => '' + ), 'Title') + ->addIndex( + $installer->getIdxName( + $tableName, + array('method_code'), + Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE + ), + array('method_code'), + array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE)); +$installer->getConnection()->createTable($table); + +$services = array( array( - 'method_id' => '3', 'method_code' => '40045', 'method_title' => 'SEDEX A COBRAR SEM CONTRATO', - ) -); - -$installer->getConnection()->insertForce( - $this->getTable('pedroteixeira_correios/postmethod'), + ), array( - 'method_id' => '4', 'method_code' => '40215', 'method_title' => 'SEDEX 10 SEM CONTRATO', - ) -); - -$installer->getConnection()->insertForce( - $this->getTable('pedroteixeira_correios/postmethod'), + ), array( - 'method_id' => '5', 'method_code' => '40290', 'method_title' => 'SEDEX HOJE SEM CONTRATO', - ) -); - -$installer->getConnection()->insertForce( - $this->getTable('pedroteixeira_correios/postmethod'), + ), array( - 'method_id' => '6', 'method_code' => '04510', 'method_title' => 'PAC SEM CONTRATO', - ) -); - -$installer->getConnection()->insertForce( - $this->getTable('pedroteixeira_correios/postmethod'), + ), array( - 'method_id' => '7', 'method_code' => '04014', 'method_title' => 'SEDEX SEM CONTRATO', - ) -); - -$installer->getConnection()->insertForce( - $this->getTable('pedroteixeira_correios/postmethod'), + ), array( - 'method_id' => '8', 'method_code' => '04669', 'method_title' => 'PAC CONTRATO AGENCIA', - ) -); - -$installer->getConnection()->insertForce( - $this->getTable('pedroteixeira_correios/postmethod'), + ), array( - 'method_id' => '9', 'method_code' => '04162', 'method_title' => 'SEDEX CONTRATO AGENCIA', - ) -); - -$installer->getConnection()->insertForce( - $this->getTable('pedroteixeira_correios/postmethod'), + ), array( - 'method_id' => '10', 'method_code' => '04693', 'method_title' => 'PAC CONTRATO GRANDES FORMATOS', - ) -); - -$installer->getConnection()->insertForce( - $this->getTable('pedroteixeira_correios/postmethod'), + ), array( - 'method_id' => '11', 'method_code' => '10065', 'method_title' => 'CARTA COMERCIAL A FATURAR', ) ); +foreach ($services as $service) { + $installer->getConnection()->insertOnDuplicate($tableName, $service, array('method_code')); +} + $installer->endSetup(); diff --git a/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/upgrade-4.7.2-4.8.0.php b/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/upgrade-4.7.2-4.8.0.php index c447d70..0f189ac 100644 --- a/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/upgrade-4.7.2-4.8.0.php +++ b/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/upgrade-4.7.2-4.8.0.php @@ -11,99 +11,3 @@ * @license http://opensource.org/licenses/MIT MIT * @link https://github.com/pedro-teixeira/correios */ - -/* @var $installer Mage_Core_Model_Resource_Setup */ -$installer = $this; -$installer->startSetup(); - -$installer->run( - "CREATE TABLE IF NOT EXISTS {$this->getTable('pedroteixeira_correios/postmethod')} ( - method_id int(11) unsigned NOT NULL auto_increment, - method_code varchar(5) NOT NULL default '0', - method_title varchar(255) NOT NULL default '', - PRIMARY KEY (method_id) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" -); - -$installer->getConnection()->insertForce( - $this->getTable('pedroteixeira_correios/postmethod'), - array( - 'method_id' => '3', - 'method_code' => '40045', - 'method_title' => 'SEDEX A COBRAR SEM CONTRATO', - ) -); - -$installer->getConnection()->insertForce( - $this->getTable('pedroteixeira_correios/postmethod'), - array( - 'method_id' => '4', - 'method_code' => '40215', - 'method_title' => 'SEDEX 10 SEM CONTRATO', - ) -); - -$installer->getConnection()->insertForce( - $this->getTable('pedroteixeira_correios/postmethod'), - array( - 'method_id' => '5', - 'method_code' => '40290', - 'method_title' => 'SEDEX HOJE SEM CONTRATO', - ) -); - -$installer->getConnection()->insertForce( - $this->getTable('pedroteixeira_correios/postmethod'), - array( - 'method_id' => '6', - 'method_code' => '04510', - 'method_title' => 'PAC SEM CONTRATO', - ) -); - -$installer->getConnection()->insertForce( - $this->getTable('pedroteixeira_correios/postmethod'), - array( - 'method_id' => '7', - 'method_code' => '04014', - 'method_title' => 'SEDEX SEM CONTRATO', - ) -); - -$installer->getConnection()->insertForce( - $this->getTable('pedroteixeira_correios/postmethod'), - array( - 'method_id' => '8', - 'method_code' => '04669', - 'method_title' => 'PAC CONTRATO AGENCIA', - ) -); - -$installer->getConnection()->insertForce( - $this->getTable('pedroteixeira_correios/postmethod'), - array( - 'method_id' => '9', - 'method_code' => '04162', - 'method_title' => 'SEDEX CONTRATO AGENCIA', - ) -); - -$installer->getConnection()->insertForce( - $this->getTable('pedroteixeira_correios/postmethod'), - array( - 'method_id' => '10', - 'method_code' => '04693', - 'method_title' => 'PAC CONTRATO GRANDES FORMATOS', - ) -); - -$installer->getConnection()->insertForce( - $this->getTable('pedroteixeira_correios/postmethod'), - array( - 'method_id' => '11', - 'method_code' => '10065', - 'method_title' => 'CARTA COMERCIAL A FATURAR', - ) -); - -$installer->endSetup(); diff --git a/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/upgrade-4.8.0-4.8.1.php b/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/upgrade-4.8.0-4.8.1.php index 0f189ac..3021fc2 100644 --- a/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/upgrade-4.8.0-4.8.1.php +++ b/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/upgrade-4.8.0-4.8.1.php @@ -11,3 +11,94 @@ * @license http://opensource.org/licenses/MIT MIT * @link https://github.com/pedro-teixeira/correios */ + +/* @var $installer Mage_Core_Model_Resource_Setup */ +$installer = $this; +$installer->startSetup(); + +$tableName = $this->getTable('pedroteixeira_correios/postmethod'); + +if ($installer->getConnection()->isTableExists($tableName)) { + // Fix old migration to 4.8.0 + // See https://github.com/pedro-teixeira/correios/pull/252 + $installer->getConnection()->addIndex( + $tableName, + $installer->getIdxName( + $tableName, + array('method_code'), + Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE + ), + array('method_code'), + array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE)); +} else { + $table = $installer->getConnection() + ->newTable($tableName) + ->addColumn('method_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( + 'identity' => true, + 'unsigned' => true, + 'nullable' => false, + 'primary' => true, + ), 'ID') + ->addColumn('method_code', Varien_Db_Ddl_Table::TYPE_TEXT, 5, array( + 'nullable' => false, + 'default' => '0' + ), 'Code') + ->addColumn('method_title', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array( + 'nullable' => false, + 'default' => '' + ), 'Title') + ->addIndex( + $installer->getIdxName( + $tableName, + array('method_code'), + Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE + ), + array('method_code'), + array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE)); + $installer->getConnection()->createTable($table); + + $services = array( + array( + 'method_code' => '40045', + 'method_title' => 'SEDEX A COBRAR SEM CONTRATO', + ), + array( + 'method_code' => '40215', + 'method_title' => 'SEDEX 10 SEM CONTRATO', + ), + array( + 'method_code' => '40290', + 'method_title' => 'SEDEX HOJE SEM CONTRATO', + ), + array( + 'method_code' => '04510', + 'method_title' => 'PAC SEM CONTRATO', + ), + array( + 'method_code' => '04014', + 'method_title' => 'SEDEX SEM CONTRATO', + ), + array( + 'method_code' => '04669', + 'method_title' => 'PAC CONTRATO AGENCIA', + ), + array( + 'method_code' => '04162', + 'method_title' => 'SEDEX CONTRATO AGENCIA', + ), + array( + 'method_code' => '04693', + 'method_title' => 'PAC CONTRATO GRANDES FORMATOS', + ), + array( + 'method_code' => '10065', + 'method_title' => 'CARTA COMERCIAL A FATURAR', + ) + ); + + foreach ($services as $service) { + $installer->getConnection()->insertOnDuplicate($tableName, $service, array('method_code')); + } +} + +$installer->endSetup(); From c258421cd7e4f8eaf71f3d2e2b87ddf9906df669 Mon Sep 17 00:00:00 2001 From: Pedro Teixeira Date: Tue, 16 May 2017 19:37:05 +0200 Subject: [PATCH 02/15] #252 Fix build --- .../install-4.8.0.php | 48 +++++++++++------ .../install-4.8.1.php | 48 +++++++++++------ .../upgrade-4.8.0-4.8.1.php | 51 ++++++++++++------- 3 files changed, 98 insertions(+), 49 deletions(-) diff --git a/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/install-4.8.0.php b/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/install-4.8.0.php index 711cadf..39d3831 100644 --- a/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/install-4.8.0.php +++ b/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/install-4.8.0.php @@ -141,28 +141,44 @@ $tableName = $this->getTable('pedroteixeira_correios/postmethod'); $table = $installer->getConnection() ->newTable($tableName) - ->addColumn('method_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( - 'identity' => true, - 'unsigned' => true, - 'nullable' => false, - 'primary' => true, - ), 'ID') - ->addColumn('method_code', Varien_Db_Ddl_Table::TYPE_TEXT, 5, array( - 'nullable' => false, - 'default' => '0' - ), 'Code') - ->addColumn('method_title', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array( - 'nullable' => false, - 'default' => '' - ), 'Title') - ->addIndex( + ->addColumn( + 'method_id', + Varien_Db_Ddl_Table::TYPE_INTEGER, + null, + array( + 'identity' => true, + 'unsigned' => true, + 'nullable' => false, + 'primary' => true, + ), + 'ID' + )->addColumn( + 'method_code', + Varien_Db_Ddl_Table::TYPE_TEXT, + 5, + array( + 'nullable' => false, + 'default' => '0' + ), + 'Code' + )->addColumn( + 'method_title', + Varien_Db_Ddl_Table::TYPE_TEXT, + 255, + array( + 'nullable' => false, + 'default' => '' + ), + 'Title' + )->addIndex( $installer->getIdxName( $tableName, array('method_code'), Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE ), array('method_code'), - array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE)); + array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE) + ); $installer->getConnection()->createTable($table); $services = array( diff --git a/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/install-4.8.1.php b/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/install-4.8.1.php index 711cadf..39d3831 100644 --- a/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/install-4.8.1.php +++ b/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/install-4.8.1.php @@ -141,28 +141,44 @@ $tableName = $this->getTable('pedroteixeira_correios/postmethod'); $table = $installer->getConnection() ->newTable($tableName) - ->addColumn('method_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( - 'identity' => true, - 'unsigned' => true, - 'nullable' => false, - 'primary' => true, - ), 'ID') - ->addColumn('method_code', Varien_Db_Ddl_Table::TYPE_TEXT, 5, array( - 'nullable' => false, - 'default' => '0' - ), 'Code') - ->addColumn('method_title', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array( - 'nullable' => false, - 'default' => '' - ), 'Title') - ->addIndex( + ->addColumn( + 'method_id', + Varien_Db_Ddl_Table::TYPE_INTEGER, + null, + array( + 'identity' => true, + 'unsigned' => true, + 'nullable' => false, + 'primary' => true, + ), + 'ID' + )->addColumn( + 'method_code', + Varien_Db_Ddl_Table::TYPE_TEXT, + 5, + array( + 'nullable' => false, + 'default' => '0' + ), + 'Code' + )->addColumn( + 'method_title', + Varien_Db_Ddl_Table::TYPE_TEXT, + 255, + array( + 'nullable' => false, + 'default' => '' + ), + 'Title' + )->addIndex( $installer->getIdxName( $tableName, array('method_code'), Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE ), array('method_code'), - array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE)); + array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE) + ); $installer->getConnection()->createTable($table); $services = array( diff --git a/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/upgrade-4.8.0-4.8.1.php b/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/upgrade-4.8.0-4.8.1.php index 3021fc2..2f4cd90 100644 --- a/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/upgrade-4.8.0-4.8.1.php +++ b/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/upgrade-4.8.0-4.8.1.php @@ -29,32 +29,49 @@ Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE ), array('method_code'), - array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE)); + array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE) + ); } else { $table = $installer->getConnection() ->newTable($tableName) - ->addColumn('method_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array( - 'identity' => true, - 'unsigned' => true, - 'nullable' => false, - 'primary' => true, - ), 'ID') - ->addColumn('method_code', Varien_Db_Ddl_Table::TYPE_TEXT, 5, array( - 'nullable' => false, - 'default' => '0' - ), 'Code') - ->addColumn('method_title', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array( - 'nullable' => false, - 'default' => '' - ), 'Title') - ->addIndex( + ->addColumn( + 'method_id', + Varien_Db_Ddl_Table::TYPE_INTEGER, + null, + array( + 'identity' => true, + 'unsigned' => true, + 'nullable' => false, + 'primary' => true, + ), + 'ID' + )->addColumn( + 'method_code', + Varien_Db_Ddl_Table::TYPE_TEXT, + 5, + array( + 'nullable' => false, + 'default' => '0' + ), + 'Code' + )->addColumn( + 'method_title', + Varien_Db_Ddl_Table::TYPE_TEXT, + 255, + array( + 'nullable' => false, + 'default' => '' + ), + 'Title' + )->addIndex( $installer->getIdxName( $tableName, array('method_code'), Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE ), array('method_code'), - array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE)); + array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE) + ); $installer->getConnection()->createTable($table); $services = array( From 310f7afeba8a145e7019fe2d1598ba5ca62b5b91 Mon Sep 17 00:00:00 2001 From: Rafael Patro Date: Sat, 27 May 2017 11:46:42 -0300 Subject: [PATCH 03/15] =?UTF-8?q?#244=20Corrige=20a=20cota=C3=A7=C3=A3o=20?= =?UTF-8?q?para=20Produtos=20Configur=C3=A1veis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Correios/Model/Carrier/CorreiosMethod.php | 35 ++- .../PedroTeixeira/Correios/etc/config.xml | 2 +- .../install-4.8.2.php | 227 ++++++++++++++++++ .../upgrade-4.8.1-4.8.2.php | 63 +++++ 4 files changed, 321 insertions(+), 6 deletions(-) create mode 100644 app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/install-4.8.2.php create mode 100644 app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/upgrade-4.8.1-4.8.2.php diff --git a/app/code/community/PedroTeixeira/Correios/Model/Carrier/CorreiosMethod.php b/app/code/community/PedroTeixeira/Correios/Model/Carrier/CorreiosMethod.php index 5ea5a06..c41bef0 100644 --- a/app/code/community/PedroTeixeira/Correios/Model/Carrier/CorreiosMethod.php +++ b/app/code/community/PedroTeixeira/Correios/Model/Carrier/CorreiosMethod.php @@ -427,6 +427,27 @@ protected function _throwError($message, $log = null, $line = 'NO LINE', $custom $this->_result->append($error); } + /** + * Retrieves a simple product + * + * @param Mage_Catalog_Model_Product $product Catalog Product + * + * @return Mage_Catalog_Model_Product + */ + protected function _getSimpleProduct($product) + { + $type = $product->getTypeInstance(true); + if ($type->getProduct($product)->hasCustomOptions() && + ($simpleProductOption = $type->getProduct($product)->getCustomOption('simple_product')) + ) { + $simpleProduct = $simpleProductOption->getProduct($product); + if ($simpleProduct) { + return $this->_getSimpleProduct($simpleProduct); + } + } + return $type->getProduct($product); + } + /** * Generate Volume weight * @@ -441,7 +462,7 @@ protected function _generateVolumeWeight($request) $items = $this->_getRequestItems($request); foreach ($items as $item) { - $_product = $item->getProduct(); + $_product = $this->_getSimpleProduct($item->getProduct()); if ($_product->getData('volume_altura') == '' || (int) $_product->getData('volume_altura') == 0) { $itemAltura = $this->getConfigData('altura_padrao'); @@ -850,8 +871,12 @@ protected function _filterMethodByItemRestriction($request) $items = $this->_getRequestItems($request); $intersection = $this->_postMethodsExplode; foreach ($items as $item) { - $product = Mage::getModel('catalog/product')->load($item->getProductId()); - $prodPostMethods = explode(',', $product->getData('postmethods')); + $product = $this->_getSimpleProduct($item->getProduct()); + $prodPostMethods = explode( + ',', $product->getResource()->getAttributeRawValue( + $product->getId(), 'postmethods', $request->getStoreId() + ) + ); $intersection = array_intersect($prodPostMethods, $intersection); } @@ -880,7 +905,7 @@ protected function _filterMethodByItemRestriction($request) */ protected function _getFitHeight($item) { - $product = $item->getProduct(); + $product = $this->_getSimpleProduct($item->getProduct()); $height = $product->getData('volume_altura'); $height = ($height > 0) ? $height : (int) $this->getConfigData('altura_padrao'); $fitSize = (float) $product->getData('fit_size'); @@ -1028,7 +1053,7 @@ protected function _getSoftErrorMsg($error) $softErrorList = explode(',', $this->getConfigData('soft_errors')); $isSoftError = in_array($error, $softErrorList); if ($isSoftError) { - $msg.= " / Área de Risco"; + $msg.= " / ?rea de Risco"; } } return $msg; diff --git a/app/code/community/PedroTeixeira/Correios/etc/config.xml b/app/code/community/PedroTeixeira/Correios/etc/config.xml index 21a2b71..8cd9f82 100644 --- a/app/code/community/PedroTeixeira/Correios/etc/config.xml +++ b/app/code/community/PedroTeixeira/Correios/etc/config.xml @@ -15,7 +15,7 @@ - 4.8.1 + 4.8.2 diff --git a/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/install-4.8.2.php b/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/install-4.8.2.php new file mode 100644 index 0000000..0ca6e69 --- /dev/null +++ b/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/install-4.8.2.php @@ -0,0 +1,227 @@ + + * @copyright 2015 Pedro Teixeira (http://pedroteixeira.io) + * @license http://opensource.org/licenses/MIT MIT + * @link https://github.com/pedro-teixeira/correios + */ + +/** @var $installer Mage_Core_Model_Resource_Setup */ +$installer = $this; +$installer->startSetup(); + +$status = Mage::getModel('sales/order_status'); +$status->setStatus(PedroTeixeira_Correios_Model_Sro::ORDER_SHIPPED_STATUS) + ->setLabel('Pedido em Transporte') + ->assignState(Mage_Sales_Model_Order::STATE_COMPLETE) + ->save(); + +$status = Mage::getModel('sales/order_status'); +$status->setStatus(PedroTeixeira_Correios_Model_Sro::ORDER_WARNED_STATUS) + ->setLabel('Dificuldade de Entrega') + ->assignState(Mage_Sales_Model_Order::STATE_COMPLETE) + ->save(); + +/* @var $installer Mage_Catalog_Model_Resource_Eav_Mysql4_Setup */ +$setup = new Mage_Eav_Model_Entity_Setup('core_setup'); + +// Add volume to prduct attribute set +$codigo = 'volume_comprimento'; +$config = array( + 'position' => 1, + 'required' => 0, + 'label' => 'Comprimento (cm)', + 'type' => 'int', + 'input' => 'text', + 'apply_to' => 'simple,grouped', + 'note' => 'Comprimento da embalagem do produto (Para cálculo dos Correios)' +); + +$setup->addAttribute('catalog_product', $codigo, $config); + +// Add volume to prduct attribute set +$codigo = 'volume_altura'; +$config = array( + 'position' => 1, + 'required' => 0, + 'label' => 'Altura (cm)', + 'type' => 'int', + 'input' => 'text', + 'apply_to' => 'simple,grouped', + 'note' => 'Altura da embalagem do produto (Para cálculo dos Correios)' +); + +$setup->addAttribute('catalog_product', $codigo, $config); + +// Add volume to prduct attribute set +$codigo = 'volume_largura'; +$config = array( + 'position' => 1, + 'required' => 0, + 'label' => 'Largura (cm)', + 'type' => 'int', + 'input' => 'text', + 'apply_to' => 'simple,grouped', + 'note' => 'Largura da embalagem do produto (Para cálculo dos Correios)' +); + +$setup->addAttribute('catalog_product', $codigo, $config); + +$codigo = 'postmethods'; +$config = array( + 'position' => 1, + 'required' => 0, + 'label' => 'Serviços de Entrega', + 'type' => 'text', + 'input' => 'multiselect', + 'source' => 'pedroteixeira_correios/source_postMethods', + 'backend' => 'eav/entity_attribute_backend_array', + 'apply_to' => 'simple,grouped', + 'note' => 'Selecione os serviços apropriados para o produto.' +); + +$setup->addAttribute('catalog_product', $codigo, $config); + +$codigo = 'fit_size'; +$config = array( + 'position' => 1, + 'required' => 0, + 'label' => 'Diferença do Encaixe (cm)', + 'type' => 'varchar', + 'input' => 'text', + 'apply_to' => 'simple,grouped', + 'note' => 'Exemplo: Se 1 item mede 10cm de altura, e 2 itens encaixados medem 11cm. A diferença é de 1cm.' +); + +$setup->addAttribute('catalog_product', $codigo, $config); + +$codigo = 'posting_days'; +$config = array( + 'position' => 1, + 'required' => 0, + 'label' => 'Prazo de Postagem', + 'type' => 'int', + 'input' => 'text', + 'apply_to' => 'simple,grouped', + 'note' => 'O prazo total é o Prazo dos Correios acrescido do maior Prazo de Postagem dos produtos no carrinho.' +); + +$setup->addAttribute('catalog_product', $codigo, $config); + +// Add Correios Tab +$setIds = $setup->getAllAttributeSetIds('catalog_product'); + +$attributes = array( + 'volume_comprimento', + 'volume_altura', + 'volume_largura', + 'postmethods', + 'fit_size', + 'posting_days' +); + +foreach ( $setIds as $setId ) { + + $setup->addAttributeGroup('catalog_product', $setId, 'Correios', 2); + $groupId = $setup->getAttributeGroupId('catalog_product', $setId, 'Correios'); + + foreach ( $attributes as $attribute ) { + $attributeId = $setup->getAttributeId('catalog_product', $attribute); + $setup->addAttributeToGroup('catalog_product', $setId, $groupId, $attributeId); + } + +} + +$tableName = $this->getTable('pedroteixeira_correios/postmethod'); +$table = $installer->getConnection() + ->newTable($tableName) + ->addColumn( + 'method_id', + Varien_Db_Ddl_Table::TYPE_INTEGER, + null, + array( + 'identity' => true, + 'unsigned' => true, + 'nullable' => false, + 'primary' => true, + ), + 'ID' + )->addColumn( + 'method_code', + Varien_Db_Ddl_Table::TYPE_TEXT, + 5, + array( + 'nullable' => false, + 'default' => '0' + ), + 'Code' + )->addColumn( + 'method_title', + Varien_Db_Ddl_Table::TYPE_TEXT, + 255, + array( + 'nullable' => false, + 'default' => '' + ), + 'Title' + )->addIndex( + $installer->getIdxName( + $tableName, + array('method_code'), + Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE + ), + array('method_code'), + array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE) + ); +$installer->getConnection()->createTable($table); + +$services = array( + array( + 'method_code' => '40045', + 'method_title' => 'SEDEX A COBRAR SEM CONTRATO', + ), + array( + 'method_code' => '40215', + 'method_title' => 'SEDEX 10 SEM CONTRATO', + ), + array( + 'method_code' => '40290', + 'method_title' => 'SEDEX HOJE SEM CONTRATO', + ), + array( + 'method_code' => '04510', + 'method_title' => 'PAC SEM CONTRATO', + ), + array( + 'method_code' => '04014', + 'method_title' => 'SEDEX SEM CONTRATO', + ), + array( + 'method_code' => '04669', + 'method_title' => 'PAC CONTRATO AGENCIA', + ), + array( + 'method_code' => '04162', + 'method_title' => 'SEDEX CONTRATO AGENCIA', + ), + array( + 'method_code' => '04693', + 'method_title' => 'PAC CONTRATO GRANDES FORMATOS', + ), + array( + 'method_code' => '10065', + 'method_title' => 'CARTA COMERCIAL A FATURAR', + ) +); + +foreach ($services as $service) { + $installer->getConnection()->insertOnDuplicate($tableName, $service, array('method_code')); +} + +$installer->endSetup(); diff --git a/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/upgrade-4.8.1-4.8.2.php b/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/upgrade-4.8.1-4.8.2.php new file mode 100644 index 0000000..e6a5b5e --- /dev/null +++ b/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/upgrade-4.8.1-4.8.2.php @@ -0,0 +1,63 @@ + + * @copyright 2015 Pedro Teixeira (http://pedroteixeira.io) + * @license http://opensource.org/licenses/MIT MIT + * @link https://github.com/pedro-teixeira/correios + */ + +/* @var $installer Mage_Core_Model_Resource_Setup */ +$installer = $this; +$installer->startSetup(); + +$setup = new Mage_Eav_Model_Entity_Setup('core_setup'); + +$setup->updateAttribute( + 'catalog_product', + 'volume_altura', + 'apply_to', + 'simple,grouped' +); + +$setup->updateAttribute( + 'catalog_product', + 'volume_largura', + 'apply_to', + 'simple,grouped' +); + +$setup->updateAttribute( + 'catalog_product', + 'volume_comprimento', + 'apply_to', + 'simple,grouped' +); + +$setup->updateAttribute( + 'catalog_product', + 'postmethods', + 'apply_to', + 'simple,grouped' +); + +$setup->updateAttribute( + 'catalog_product', + 'fit_size', + 'apply_to', + 'simple,grouped' +); + +$setup->updateAttribute( + 'catalog_product', + 'posting_days', + 'apply_to', + 'simple,grouped' +); + +$installer->endSetup(); From 62e3e7f5236dc04e18643997ee3b383f24eae50e Mon Sep 17 00:00:00 2001 From: Rafael Patro Date: Sat, 27 May 2017 11:50:19 -0300 Subject: [PATCH 04/15] =?UTF-8?q?#244=20Altera=C3=A7=C3=A3o=20cosm=C3=A9ti?= =?UTF-8?q?ca?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PedroTeixeira/Correios/Model/Carrier/CorreiosMethod.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/community/PedroTeixeira/Correios/Model/Carrier/CorreiosMethod.php b/app/code/community/PedroTeixeira/Correios/Model/Carrier/CorreiosMethod.php index c41bef0..01ccd91 100644 --- a/app/code/community/PedroTeixeira/Correios/Model/Carrier/CorreiosMethod.php +++ b/app/code/community/PedroTeixeira/Correios/Model/Carrier/CorreiosMethod.php @@ -1053,7 +1053,7 @@ protected function _getSoftErrorMsg($error) $softErrorList = explode(',', $this->getConfigData('soft_errors')); $isSoftError = in_array($error, $softErrorList); if ($isSoftError) { - $msg.= " / ?rea de Risco"; + $msg.= " / Área de Risco"; } } return $msg; From 863bad9dd83d8bd90822f322b73ed7dfc4c9ab83 Mon Sep 17 00:00:00 2001 From: Rafael Patro Date: Sat, 27 May 2017 12:38:38 -0300 Subject: [PATCH 05/15] =?UTF-8?q?#170=20Melhoria=20no=20Monitoramento=20Au?= =?UTF-8?q?tom=C3=A1tico=20das=20encomendas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PedroTeixeira/Correios/Model/Observer.php | 79 ++++++--- .../PedroTeixeira/Correios/Model/Sro.php | 164 ++++++++++++------ app/lib/Correios/Rastro.php | 67 +++++++ app/lib/Correios/Rastro/BuscaEventos.php | 61 +++++++ app/lib/Correios/Rastro/BuscaEventosLista.php | 61 +++++++ .../Rastro/BuscaEventosListaResponse.php | 21 +++ .../Correios/Rastro/BuscaEventosResponse.php | 21 +++ app/lib/Correios/Rastro/Destinos.php | 53 ++++++ app/lib/Correios/Rastro/EnderecoMobile.php | 101 +++++++++++ app/lib/Correios/Rastro/Eventos.php | 157 +++++++++++++++++ app/lib/Correios/Rastro/Objeto.php | 61 +++++++ app/lib/Correios/Rastro/Sroxml.php | 53 ++++++ 12 files changed, 826 insertions(+), 73 deletions(-) create mode 100644 app/lib/Correios/Rastro.php create mode 100644 app/lib/Correios/Rastro/BuscaEventos.php create mode 100644 app/lib/Correios/Rastro/BuscaEventosLista.php create mode 100644 app/lib/Correios/Rastro/BuscaEventosListaResponse.php create mode 100644 app/lib/Correios/Rastro/BuscaEventosResponse.php create mode 100644 app/lib/Correios/Rastro/Destinos.php create mode 100644 app/lib/Correios/Rastro/EnderecoMobile.php create mode 100644 app/lib/Correios/Rastro/Eventos.php create mode 100644 app/lib/Correios/Rastro/Objeto.php create mode 100644 app/lib/Correios/Rastro/Sroxml.php 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..92f0e4a 100644 --- a/app/code/community/PedroTeixeira/Correios/Model/Sro.php +++ b/app/code/community/PedroTeixeira/Correios/Model/Sro.php @@ -16,14 +16,22 @@ 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'; - - /** - * Request response - * - * @var SimpleXMLElement - */ - protected $_xml = null; + protected $_trackList = array(); + + 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 +56,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 +63,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 +111,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 +140,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 +171,15 @@ public function getEmailComment() /** * Check the event type * + * @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 +193,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 + * + * @throws Exception + * + * @param Correios_Rastro_Objeto $obj Return Object + * + * @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..2bb7bc9 --- /dev/null +++ b/app/lib/Correios/Rastro.php @@ -0,0 +1,67 @@ + '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'); + + /** + * @param array $options A 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); + } + + /** + * @param Correios_Rastro_BuscaEventos $parameters + * @access public + * @return Correios_Rastro_BuscaEventosResponse + */ + public function buscaEventos(Correios_Rastro_BuscaEventos $parameters) + { + return $this->__soapCall('buscaEventos', array($parameters)); + } + + /** + * @param Correios_Rastro_BuscaEventosLista $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..1c15a7c --- /dev/null +++ b/app/lib/Correios/Rastro/BuscaEventos.php @@ -0,0 +1,61 @@ +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..fd4d420 --- /dev/null +++ b/app/lib/Correios/Rastro/BuscaEventosLista.php @@ -0,0 +1,61 @@ +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..90fb66d --- /dev/null +++ b/app/lib/Correios/Rastro/BuscaEventosListaResponse.php @@ -0,0 +1,21 @@ +return = $return; + } + +} diff --git a/app/lib/Correios/Rastro/BuscaEventosResponse.php b/app/lib/Correios/Rastro/BuscaEventosResponse.php new file mode 100644 index 0000000..b8df656 --- /dev/null +++ b/app/lib/Correios/Rastro/BuscaEventosResponse.php @@ -0,0 +1,21 @@ +return = $return; + } + +} diff --git a/app/lib/Correios/Rastro/Destinos.php b/app/lib/Correios/Rastro/Destinos.php new file mode 100644 index 0000000..4caff5e --- /dev/null +++ b/app/lib/Correios/Rastro/Destinos.php @@ -0,0 +1,53 @@ +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..bc86b3f --- /dev/null +++ b/app/lib/Correios/Rastro/EnderecoMobile.php @@ -0,0 +1,101 @@ +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..5db943f --- /dev/null +++ b/app/lib/Correios/Rastro/Eventos.php @@ -0,0 +1,157 @@ +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..23ec027 --- /dev/null +++ b/app/lib/Correios/Rastro/Objeto.php @@ -0,0 +1,61 @@ +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..26cefa7 --- /dev/null +++ b/app/lib/Correios/Rastro/Sroxml.php @@ -0,0 +1,53 @@ +versao = $versao; + $this->qtd = $qtd; + $this->TipoPesquisa = $TipoPesquisa; + $this->TipoResultado = $TipoResultado; + $this->objeto = $objeto; + } + +} From 0ddec5aac36371f73fb2a05ecfcb5805ebd1707b Mon Sep 17 00:00:00 2001 From: Rafael Patro Date: Sat, 27 May 2017 13:15:53 -0300 Subject: [PATCH 06/15] =?UTF-8?q?#244=20Altera=C3=A7=C3=A3o=20cosm=C3=A9ti?= =?UTF-8?q?ca?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PedroTeixeira/Correios/Model/Carrier/CorreiosMethod.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/community/PedroTeixeira/Correios/Model/Carrier/CorreiosMethod.php b/app/code/community/PedroTeixeira/Correios/Model/Carrier/CorreiosMethod.php index 01ccd91..8d4bcf5 100644 --- a/app/code/community/PedroTeixeira/Correios/Model/Carrier/CorreiosMethod.php +++ b/app/code/community/PedroTeixeira/Correios/Model/Carrier/CorreiosMethod.php @@ -437,8 +437,8 @@ protected function _throwError($message, $log = null, $line = 'NO LINE', $custom protected function _getSimpleProduct($product) { $type = $product->getTypeInstance(true); - if ($type->getProduct($product)->hasCustomOptions() && - ($simpleProductOption = $type->getProduct($product)->getCustomOption('simple_product')) + if ($type->getProduct($product)->hasCustomOptions() + && ($simpleProductOption = $type->getProduct($product)->getCustomOption('simple_product')) ) { $simpleProduct = $simpleProductOption->getProduct($product); if ($simpleProduct) { From 631083c3ead355feba34d0aba2dbd818ae65fe8f Mon Sep 17 00:00:00 2001 From: Rafael Patro Date: Sat, 27 May 2017 19:45:52 -0300 Subject: [PATCH 07/15] #244 Corrigido o versionamento --- app/code/community/PedroTeixeira/Correios/etc/config.xml | 2 +- .../{install-4.8.2.php => install-4.9.0.php} | 0 .../{upgrade-4.8.1-4.8.2.php => upgrade-4.8.1-4.9.0.php} | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/{install-4.8.2.php => install-4.9.0.php} (100%) rename app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/{upgrade-4.8.1-4.8.2.php => upgrade-4.8.1-4.9.0.php} (100%) diff --git a/app/code/community/PedroTeixeira/Correios/etc/config.xml b/app/code/community/PedroTeixeira/Correios/etc/config.xml index 8cd9f82..a6f2656 100644 --- a/app/code/community/PedroTeixeira/Correios/etc/config.xml +++ b/app/code/community/PedroTeixeira/Correios/etc/config.xml @@ -15,7 +15,7 @@ - 4.8.2 + 4.9.0 diff --git a/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/install-4.8.2.php b/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/install-4.9.0.php similarity index 100% rename from app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/install-4.8.2.php rename to app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/install-4.9.0.php diff --git a/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/upgrade-4.8.1-4.8.2.php b/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/upgrade-4.8.1-4.9.0.php similarity index 100% rename from app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/upgrade-4.8.1-4.8.2.php rename to app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/upgrade-4.8.1-4.9.0.php From 1651f6fb996a8fb02363ac9ab33a96ad4ef2527b Mon Sep 17 00:00:00 2001 From: Rafael Patro Date: Sat, 27 May 2017 19:52:12 -0300 Subject: [PATCH 08/15] =?UTF-8?q?#265=20Removidas=20as=20declara=C3=A7?= =?UTF-8?q?=C3=B5es=20include=5Fonce?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/lib/Correios/Rastro.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/app/lib/Correios/Rastro.php b/app/lib/Correios/Rastro.php index 2bb7bc9..d89bed2 100644 --- a/app/lib/Correios/Rastro.php +++ b/app/lib/Correios/Rastro.php @@ -1,15 +1,5 @@ Date: Sat, 27 May 2017 20:49:54 -0300 Subject: [PATCH 09/15] =?UTF-8?q?#265=20Corre=C3=A7=C3=A3o=20do=20build?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PedroTeixeira/Correios/Model/Sro.php | 15 ++-- app/lib/Correios/Rastro.php | 24 +++++- app/lib/Correios/Rastro/BuscaEventos.php | 36 +++++--- app/lib/Correios/Rastro/BuscaEventosLista.php | 36 +++++--- .../Rastro/BuscaEventosListaResponse.php | 16 +++- .../Correios/Rastro/BuscaEventosResponse.php | 16 +++- app/lib/Correios/Rastro/Destinos.php | 32 ++++--- app/lib/Correios/Rastro/EnderecoMobile.php | 56 ++++++++----- app/lib/Correios/Rastro/Eventos.php | 84 +++++++++++-------- app/lib/Correios/Rastro/Objeto.php | 36 +++++--- app/lib/Correios/Rastro/Sroxml.php | 32 ++++--- 11 files changed, 256 insertions(+), 127 deletions(-) diff --git a/app/code/community/PedroTeixeira/Correios/Model/Sro.php b/app/code/community/PedroTeixeira/Correios/Model/Sro.php index 92f0e4a..09f1108 100644 --- a/app/code/community/PedroTeixeira/Correios/Model/Sro.php +++ b/app/code/community/PedroTeixeira/Correios/Model/Sro.php @@ -19,6 +19,11 @@ class PedroTeixeira_Correios_Model_Sro extends Varien_Object protected $_trackList = array(); + /** + * Retrieves all valid tracking codes + * + * @return PedroTeixeira_Correios_Model_Sro + */ public function init() { $collection = $this->getShippedTracks(); @@ -140,7 +145,7 @@ public function getComment($obj) /** * Returns an Update Shipping e-mail comment * - * @param Correios_Rastro_Objeto $obj Response Object + * @param Correios_Rastro_Objeto $obj Response Object * @param Mage_Sales_Model_Order_Shipment_Track $track Tracking instance * * @return string @@ -171,8 +176,8 @@ public function getEmailComment($obj, $track) /** * Check the event type * - * @param Correios_Rastro_Objeto $obj Response Object - * @param string $mode Event Type Mode + * @param Correios_Rastro_Objeto $obj Response Object + * @param string $mode Event Type Mode * * @return boolean */ @@ -255,10 +260,10 @@ public function validateTrackNumber($trackNumber) /** * Retrieves the tracking instance * - * @throws Exception - * * @param Correios_Rastro_Objeto $obj Return Object * + * @throws Exception + * * @return Mage_Sales_Model_Order_Shipment_Track */ public function getTrack($obj) diff --git a/app/lib/Correios/Rastro.php b/app/lib/Correios/Rastro.php index d89bed2..4036f80 100644 --- a/app/lib/Correios/Rastro.php +++ b/app/lib/Correios/Rastro.php @@ -1,5 +1,16 @@ + * @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 { @@ -19,8 +30,9 @@ class Correios_Rastro extends SoapClient 'BuscaEventosResponse' => 'Correios_Rastro_BuscaEventosResponse'); /** - * @param array $options A array of config values - * @param string $wsdl The wsdl file to use + * @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') @@ -35,8 +47,10 @@ public function __construct(array $options = array(), $wsdl = 'Rastro.wsdl') } /** - * @param Correios_Rastro_BuscaEventos $parameters + * @param Correios_Rastro_BuscaEventos $parameters Parameters + * * @access public + * * @return Correios_Rastro_BuscaEventosResponse */ public function buscaEventos(Correios_Rastro_BuscaEventos $parameters) @@ -45,8 +59,10 @@ public function buscaEventos(Correios_Rastro_BuscaEventos $parameters) } /** - * @param Correios_Rastro_BuscaEventosLista $parameters + * @param Correios_Rastro_BuscaEventosLista $parameters Parameters + * * @access public + * * @return Correios_Rastro_BuscaEventosListaResponse */ public function buscaEventosLista(Correios_Rastro_BuscaEventosLista $parameters) diff --git a/app/lib/Correios/Rastro/BuscaEventos.php b/app/lib/Correios/Rastro/BuscaEventos.php index 1c15a7c..8eced73 100644 --- a/app/lib/Correios/Rastro/BuscaEventos.php +++ b/app/lib/Correios/Rastro/BuscaEventos.php @@ -1,5 +1,16 @@ + * @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 { @@ -40,22 +51,23 @@ class Correios_Rastro_BuscaEventos public $objetos = null; /** - * @param string $usuario - * @param string $senha - * @param string $tipo - * @param string $resultado - * @param string $lingua - * @param string $objetos + * @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; + $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 index fd4d420..baf7db5 100644 --- a/app/lib/Correios/Rastro/BuscaEventosLista.php +++ b/app/lib/Correios/Rastro/BuscaEventosLista.php @@ -1,5 +1,16 @@ + * @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 { @@ -40,22 +51,23 @@ class Correios_Rastro_BuscaEventosLista public $objetos = null; /** - * @param string $usuario - * @param string $senha - * @param string $tipo - * @param string $resultado - * @param string $lingua - * @param string[] $objetos + * @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; + $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 index 90fb66d..4baf2cc 100644 --- a/app/lib/Correios/Rastro/BuscaEventosListaResponse.php +++ b/app/lib/Correios/Rastro/BuscaEventosListaResponse.php @@ -1,5 +1,16 @@ + * @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 { @@ -10,12 +21,13 @@ class Correios_Rastro_BuscaEventosListaResponse public $return = null; /** - * @param Correios_Rastro_Sroxml $return + * @param Correios_Rastro_Sroxml $return Sroxml Object + * * @access public */ public function __construct($return) { - $this->return = $return; + $this->return = $return; } } diff --git a/app/lib/Correios/Rastro/BuscaEventosResponse.php b/app/lib/Correios/Rastro/BuscaEventosResponse.php index b8df656..866d24f 100644 --- a/app/lib/Correios/Rastro/BuscaEventosResponse.php +++ b/app/lib/Correios/Rastro/BuscaEventosResponse.php @@ -1,5 +1,16 @@ + * @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 { @@ -10,12 +21,13 @@ class Correios_Rastro_BuscaEventosResponse public $return = null; /** - * @param Correios_Rastro_Sroxml $return + * @param Correios_Rastro_Sroxml $return Sroxml Object + * * @access public */ public function __construct($return) { - $this->return = $return; + $this->return = $return; } } diff --git a/app/lib/Correios/Rastro/Destinos.php b/app/lib/Correios/Rastro/Destinos.php index 4caff5e..d5fd446 100644 --- a/app/lib/Correios/Rastro/Destinos.php +++ b/app/lib/Correios/Rastro/Destinos.php @@ -1,5 +1,16 @@ + * @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 { @@ -34,20 +45,21 @@ class Correios_Rastro_Destinos public $uf = null; /** - * @param string $local - * @param string $codigo - * @param string $cidade - * @param string $bairro - * @param string $uf + * @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; + $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 index bc86b3f..7b2b32c 100644 --- a/app/lib/Correios/Rastro/EnderecoMobile.php +++ b/app/lib/Correios/Rastro/EnderecoMobile.php @@ -1,5 +1,16 @@ + * @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 { @@ -70,32 +81,33 @@ class Correios_Rastro_EnderecoMobile public $celular = null; /** - * @param string $codigo - * @param string $cep - * @param string $logradouro - * @param string $complemento - * @param string $numero - * @param string $localidade - * @param string $uf - * @param string $bairro - * @param string $latitude - * @param string $longitude - * @param string $celular + * @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; + $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 index 5db943f..7b189ae 100644 --- a/app/lib/Correios/Rastro/Eventos.php +++ b/app/lib/Correios/Rastro/Eventos.php @@ -1,5 +1,16 @@ + * @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 { @@ -112,46 +123,47 @@ class Correios_Rastro_Eventos public $endereco = null; /** - * @param string $tipo - * @param string $status - * @param string $data - * @param string $hora - * @param string $descricao - * @param string $detalhe - * @param string $recebedor - * @param string $documento - * @param string $comentario - * @param string $local - * @param string $codigo - * @param string $cidade - * @param string $uf - * @param string $sto - * @param string $amazoncode - * @param string $amazontimezone - * @param Correios_Rastro_Destinos $destino - * @param Correios_Rastro_EnderecoMobile $endereco + * @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; + $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 index 23ec027..ef02f42 100644 --- a/app/lib/Correios/Rastro/Objeto.php +++ b/app/lib/Correios/Rastro/Objeto.php @@ -1,5 +1,16 @@ + * @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 { @@ -40,22 +51,23 @@ class Correios_Rastro_Objeto public $evento = null; /** - * @param string $numero - * @param string $sigla - * @param string $nome - * @param string $categoria - * @param string $erro - * @param Correios_Rastro_Eventos $evento + * @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; + $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 index 26cefa7..ce50f08 100644 --- a/app/lib/Correios/Rastro/Sroxml.php +++ b/app/lib/Correios/Rastro/Sroxml.php @@ -1,5 +1,16 @@ + * @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 { @@ -34,20 +45,21 @@ class Correios_Rastro_Sroxml public $objeto = null; /** - * @param string $versao - * @param string $qtd - * @param string $TipoPesquisa - * @param string $TipoResultado - * @param Correios_Rastro_Objeto $objeto + * @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; + $this->versao = $versao; + $this->qtd = $qtd; + $this->TipoPesquisa = $TipoPesquisa; + $this->TipoResultado = $TipoResultado; + $this->objeto = $objeto; } } From a9db02fa39f663f181fe5207d9a4627f62d54517 Mon Sep 17 00:00:00 2001 From: Rafael Patro Date: Sat, 27 May 2017 20:57:13 -0300 Subject: [PATCH 10/15] =?UTF-8?q?#266=20Corre=C3=A7=C3=A3o=20do=20build?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/lib/Correios/Rastro.php | 3 +++ app/lib/Correios/Rastro/BuscaEventos.php | 1 + app/lib/Correios/Rastro/BuscaEventosLista.php | 1 + app/lib/Correios/Rastro/BuscaEventosListaResponse.php | 1 + app/lib/Correios/Rastro/BuscaEventosResponse.php | 1 + app/lib/Correios/Rastro/Destinos.php | 1 + app/lib/Correios/Rastro/EnderecoMobile.php | 5 ++++- app/lib/Correios/Rastro/Eventos.php | 6 +++++- app/lib/Correios/Rastro/Objeto.php | 1 + app/lib/Correios/Rastro/Sroxml.php | 1 + 10 files changed, 19 insertions(+), 2 deletions(-) diff --git a/app/lib/Correios/Rastro.php b/app/lib/Correios/Rastro.php index 4036f80..89d2816 100644 --- a/app/lib/Correios/Rastro.php +++ b/app/lib/Correios/Rastro.php @@ -30,6 +30,7 @@ class Correios_Rastro extends SoapClient 'BuscaEventosResponse' => 'Correios_Rastro_BuscaEventosResponse'); /** + * * @param array $options An array of config values * @param string $wsdl The wsdl file to use * @@ -47,6 +48,7 @@ public function __construct(array $options = array(), $wsdl = 'Rastro.wsdl') } /** + * * @param Correios_Rastro_BuscaEventos $parameters Parameters * * @access public @@ -59,6 +61,7 @@ public function buscaEventos(Correios_Rastro_BuscaEventos $parameters) } /** + * * @param Correios_Rastro_BuscaEventosLista $parameters Parameters * * @access public diff --git a/app/lib/Correios/Rastro/BuscaEventos.php b/app/lib/Correios/Rastro/BuscaEventos.php index 8eced73..5455206 100644 --- a/app/lib/Correios/Rastro/BuscaEventos.php +++ b/app/lib/Correios/Rastro/BuscaEventos.php @@ -51,6 +51,7 @@ class Correios_Rastro_BuscaEventos public $objetos = null; /** + * * @param string $usuario Username * @param string $senha Password * @param string $tipo Type diff --git a/app/lib/Correios/Rastro/BuscaEventosLista.php b/app/lib/Correios/Rastro/BuscaEventosLista.php index baf7db5..2f7c812 100644 --- a/app/lib/Correios/Rastro/BuscaEventosLista.php +++ b/app/lib/Correios/Rastro/BuscaEventosLista.php @@ -51,6 +51,7 @@ class Correios_Rastro_BuscaEventosLista public $objetos = null; /** + * * @param string $usuario Username * @param string $senha Password * @param string $tipo Type diff --git a/app/lib/Correios/Rastro/BuscaEventosListaResponse.php b/app/lib/Correios/Rastro/BuscaEventosListaResponse.php index 4baf2cc..2eb494f 100644 --- a/app/lib/Correios/Rastro/BuscaEventosListaResponse.php +++ b/app/lib/Correios/Rastro/BuscaEventosListaResponse.php @@ -21,6 +21,7 @@ class Correios_Rastro_BuscaEventosListaResponse public $return = null; /** + * * @param Correios_Rastro_Sroxml $return Sroxml Object * * @access public diff --git a/app/lib/Correios/Rastro/BuscaEventosResponse.php b/app/lib/Correios/Rastro/BuscaEventosResponse.php index 866d24f..4ee2cac 100644 --- a/app/lib/Correios/Rastro/BuscaEventosResponse.php +++ b/app/lib/Correios/Rastro/BuscaEventosResponse.php @@ -21,6 +21,7 @@ class Correios_Rastro_BuscaEventosResponse public $return = null; /** + * * @param Correios_Rastro_Sroxml $return Sroxml Object * * @access public diff --git a/app/lib/Correios/Rastro/Destinos.php b/app/lib/Correios/Rastro/Destinos.php index d5fd446..60e6c44 100644 --- a/app/lib/Correios/Rastro/Destinos.php +++ b/app/lib/Correios/Rastro/Destinos.php @@ -45,6 +45,7 @@ class Correios_Rastro_Destinos public $uf = null; /** + * * @param string $local Local * @param string $codigo Code * @param string $cidade City diff --git a/app/lib/Correios/Rastro/EnderecoMobile.php b/app/lib/Correios/Rastro/EnderecoMobile.php index 7b2b32c..d09f176 100644 --- a/app/lib/Correios/Rastro/EnderecoMobile.php +++ b/app/lib/Correios/Rastro/EnderecoMobile.php @@ -81,6 +81,7 @@ class Correios_Rastro_EnderecoMobile public $celular = null; /** + * * @param string $codigo Code * @param string $cep Zip * @param string $logradouro Street @@ -95,7 +96,9 @@ class Correios_Rastro_EnderecoMobile * * @access public */ - public function __construct($codigo, $cep, $logradouro, $complemento, $numero, $localidade, $uf, $bairro, $latitude, $longitude, $celular) + public function __construct( + $codigo, $cep, $logradouro, $complemento, $numero, $localidade, $uf, $bairro, $latitude, $longitude, $celular + ) { $this->codigo = $codigo; $this->cep = $cep; diff --git a/app/lib/Correios/Rastro/Eventos.php b/app/lib/Correios/Rastro/Eventos.php index 7b189ae..222b46e 100644 --- a/app/lib/Correios/Rastro/Eventos.php +++ b/app/lib/Correios/Rastro/Eventos.php @@ -123,6 +123,7 @@ class Correios_Rastro_Eventos public $endereco = null; /** + * * @param string $tipo Type * @param string $status State * @param string $data Date @@ -144,7 +145,10 @@ class Correios_Rastro_Eventos * * @access public */ - public function __construct($tipo, $status, $data, $hora, $descricao, $detalhe, $recebedor, $documento, $comentario, $local, $codigo, $cidade, $uf, $sto, $amazoncode, $amazontimezone, $destino, $endereco) + 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; diff --git a/app/lib/Correios/Rastro/Objeto.php b/app/lib/Correios/Rastro/Objeto.php index ef02f42..fea7cd7 100644 --- a/app/lib/Correios/Rastro/Objeto.php +++ b/app/lib/Correios/Rastro/Objeto.php @@ -51,6 +51,7 @@ class Correios_Rastro_Objeto public $evento = null; /** + * * @param string $numero Number * @param string $sigla Initials * @param string $nome Name diff --git a/app/lib/Correios/Rastro/Sroxml.php b/app/lib/Correios/Rastro/Sroxml.php index ce50f08..7a40d04 100644 --- a/app/lib/Correios/Rastro/Sroxml.php +++ b/app/lib/Correios/Rastro/Sroxml.php @@ -45,6 +45,7 @@ class Correios_Rastro_Sroxml public $objeto = null; /** + * * @param string $versao Release * @param string $qtd Quantity * @param string $TipoPesquisa Search Type From 56896e4a015ed94205a39a92333b3536ec35900b Mon Sep 17 00:00:00 2001 From: Rafael Patro Date: Sat, 27 May 2017 21:10:17 -0300 Subject: [PATCH 11/15] =?UTF-8?q?#266=20Corre=C3=A7=C3=A3o=20do=20build?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/lib/Correios/Rastro.php | 34 +++++++++++-------- app/lib/Correios/Rastro/BuscaEventos.php | 1 + app/lib/Correios/Rastro/BuscaEventosLista.php | 1 + .../Rastro/BuscaEventosListaResponse.php | 1 + .../Correios/Rastro/BuscaEventosResponse.php | 1 + app/lib/Correios/Rastro/Destinos.php | 1 + app/lib/Correios/Rastro/EnderecoMobile.php | 1 + app/lib/Correios/Rastro/Eventos.php | 1 + app/lib/Correios/Rastro/Objeto.php | 1 + app/lib/Correios/Rastro/Sroxml.php | 1 + 10 files changed, 28 insertions(+), 15 deletions(-) diff --git a/app/lib/Correios/Rastro.php b/app/lib/Correios/Rastro.php index 89d2816..819e82f 100644 --- a/app/lib/Correios/Rastro.php +++ b/app/lib/Correios/Rastro.php @@ -19,17 +19,19 @@ class Correios_Rastro extends SoapClient * @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'); + '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 @@ -38,16 +40,17 @@ class Correios_Rastro extends SoapClient */ public function __construct(array $options = array(), $wsdl = 'Rastro.wsdl') { - foreach (self::$classmap as $key => $value) { - if (!isset($options['classmap'][$key])) { - $options['classmap'][$key] = $value; + 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 * @@ -57,10 +60,11 @@ public function __construct(array $options = array(), $wsdl = 'Rastro.wsdl') */ public function buscaEventos(Correios_Rastro_BuscaEventos $parameters) { - return $this->__soapCall('buscaEventos', array($parameters)); + return $this->__soapCall('buscaEventos', array($parameters)); } /** + * Request method for buscaEventosLista * * @param Correios_Rastro_BuscaEventosLista $parameters Parameters * @@ -70,7 +74,7 @@ public function buscaEventos(Correios_Rastro_BuscaEventos $parameters) */ public function buscaEventosLista(Correios_Rastro_BuscaEventosLista $parameters) { - return $this->__soapCall('buscaEventosLista', array($parameters)); + return $this->__soapCall('buscaEventosLista', array($parameters)); } } diff --git a/app/lib/Correios/Rastro/BuscaEventos.php b/app/lib/Correios/Rastro/BuscaEventos.php index 5455206..b7714c4 100644 --- a/app/lib/Correios/Rastro/BuscaEventos.php +++ b/app/lib/Correios/Rastro/BuscaEventos.php @@ -51,6 +51,7 @@ class Correios_Rastro_BuscaEventos public $objetos = null; /** + * Class constructor method * * @param string $usuario Username * @param string $senha Password diff --git a/app/lib/Correios/Rastro/BuscaEventosLista.php b/app/lib/Correios/Rastro/BuscaEventosLista.php index 2f7c812..c8dd767 100644 --- a/app/lib/Correios/Rastro/BuscaEventosLista.php +++ b/app/lib/Correios/Rastro/BuscaEventosLista.php @@ -51,6 +51,7 @@ class Correios_Rastro_BuscaEventosLista public $objetos = null; /** + * Class constructor method * * @param string $usuario Username * @param string $senha Password diff --git a/app/lib/Correios/Rastro/BuscaEventosListaResponse.php b/app/lib/Correios/Rastro/BuscaEventosListaResponse.php index 2eb494f..eeb4253 100644 --- a/app/lib/Correios/Rastro/BuscaEventosListaResponse.php +++ b/app/lib/Correios/Rastro/BuscaEventosListaResponse.php @@ -21,6 +21,7 @@ class Correios_Rastro_BuscaEventosListaResponse public $return = null; /** + * Class constructor method * * @param Correios_Rastro_Sroxml $return Sroxml Object * diff --git a/app/lib/Correios/Rastro/BuscaEventosResponse.php b/app/lib/Correios/Rastro/BuscaEventosResponse.php index 4ee2cac..57042c5 100644 --- a/app/lib/Correios/Rastro/BuscaEventosResponse.php +++ b/app/lib/Correios/Rastro/BuscaEventosResponse.php @@ -21,6 +21,7 @@ class Correios_Rastro_BuscaEventosResponse public $return = null; /** + * Class constructor method * * @param Correios_Rastro_Sroxml $return Sroxml Object * diff --git a/app/lib/Correios/Rastro/Destinos.php b/app/lib/Correios/Rastro/Destinos.php index 60e6c44..70cbe29 100644 --- a/app/lib/Correios/Rastro/Destinos.php +++ b/app/lib/Correios/Rastro/Destinos.php @@ -45,6 +45,7 @@ class Correios_Rastro_Destinos public $uf = null; /** + * Class constructor method * * @param string $local Local * @param string $codigo Code diff --git a/app/lib/Correios/Rastro/EnderecoMobile.php b/app/lib/Correios/Rastro/EnderecoMobile.php index d09f176..679f879 100644 --- a/app/lib/Correios/Rastro/EnderecoMobile.php +++ b/app/lib/Correios/Rastro/EnderecoMobile.php @@ -81,6 +81,7 @@ class Correios_Rastro_EnderecoMobile public $celular = null; /** + * Class constructor method * * @param string $codigo Code * @param string $cep Zip diff --git a/app/lib/Correios/Rastro/Eventos.php b/app/lib/Correios/Rastro/Eventos.php index 222b46e..a47c0b2 100644 --- a/app/lib/Correios/Rastro/Eventos.php +++ b/app/lib/Correios/Rastro/Eventos.php @@ -123,6 +123,7 @@ class Correios_Rastro_Eventos public $endereco = null; /** + * Class constructor method * * @param string $tipo Type * @param string $status State diff --git a/app/lib/Correios/Rastro/Objeto.php b/app/lib/Correios/Rastro/Objeto.php index fea7cd7..ec0f602 100644 --- a/app/lib/Correios/Rastro/Objeto.php +++ b/app/lib/Correios/Rastro/Objeto.php @@ -51,6 +51,7 @@ class Correios_Rastro_Objeto public $evento = null; /** + * Class constructor method * * @param string $numero Number * @param string $sigla Initials diff --git a/app/lib/Correios/Rastro/Sroxml.php b/app/lib/Correios/Rastro/Sroxml.php index 7a40d04..41eee51 100644 --- a/app/lib/Correios/Rastro/Sroxml.php +++ b/app/lib/Correios/Rastro/Sroxml.php @@ -45,6 +45,7 @@ class Correios_Rastro_Sroxml public $objeto = null; /** + * Class constructor method * * @param string $versao Release * @param string $qtd Quantity From 030a340e6c70de70bd2438f042555dca5162a741 Mon Sep 17 00:00:00 2001 From: Rafael Patro Date: Sat, 27 May 2017 21:11:47 -0300 Subject: [PATCH 12/15] =?UTF-8?q?#266=20Corre=C3=A7=C3=A3o=20do=20build?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/lib/Correios/Rastro/EnderecoMobile.php | 3 +-- app/lib/Correios/Rastro/Eventos.php | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/lib/Correios/Rastro/EnderecoMobile.php b/app/lib/Correios/Rastro/EnderecoMobile.php index 679f879..3f3bc70 100644 --- a/app/lib/Correios/Rastro/EnderecoMobile.php +++ b/app/lib/Correios/Rastro/EnderecoMobile.php @@ -99,8 +99,7 @@ class Correios_Rastro_EnderecoMobile */ public function __construct( $codigo, $cep, $logradouro, $complemento, $numero, $localidade, $uf, $bairro, $latitude, $longitude, $celular - ) - { + ) { $this->codigo = $codigo; $this->cep = $cep; $this->logradouro = $logradouro; diff --git a/app/lib/Correios/Rastro/Eventos.php b/app/lib/Correios/Rastro/Eventos.php index a47c0b2..8af0e34 100644 --- a/app/lib/Correios/Rastro/Eventos.php +++ b/app/lib/Correios/Rastro/Eventos.php @@ -149,8 +149,7 @@ class Correios_Rastro_Eventos 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; From 26257f0525a406bf475e27ec5f9ff47e3f03fe0c Mon Sep 17 00:00:00 2001 From: Rafael Patro Date: Sat, 27 May 2017 22:15:48 -0300 Subject: [PATCH 13/15] =?UTF-8?q?#266=20Corre=C3=A7=C3=A3o=20do=20build?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/lib/Correios/Rastro.php | 4 ++-- app/lib/Correios/Rastro/EnderecoMobile.php | 4 ++-- app/lib/Correios/Rastro/Eventos.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/lib/Correios/Rastro.php b/app/lib/Correios/Rastro.php index 819e82f..c010236 100644 --- a/app/lib/Correios/Rastro.php +++ b/app/lib/Correios/Rastro.php @@ -45,8 +45,8 @@ public function __construct(array $options = array(), $wsdl = 'Rastro.wsdl') $options['classmap'][$key] = $value; } } - - parent::__construct($wsdl, $options); + + parent::__construct($wsdl, $options); } /** diff --git a/app/lib/Correios/Rastro/EnderecoMobile.php b/app/lib/Correios/Rastro/EnderecoMobile.php index 3f3bc70..724e4c1 100644 --- a/app/lib/Correios/Rastro/EnderecoMobile.php +++ b/app/lib/Correios/Rastro/EnderecoMobile.php @@ -98,8 +98,8 @@ class Correios_Rastro_EnderecoMobile * @access public */ public function __construct( - $codigo, $cep, $logradouro, $complemento, $numero, $localidade, $uf, $bairro, $latitude, $longitude, $celular - ) { + $codigo, $cep, $logradouro, $complemento, $numero, $localidade, $uf, $bairro, $latitude, $longitude, $celular) + { $this->codigo = $codigo; $this->cep = $cep; $this->logradouro = $logradouro; diff --git a/app/lib/Correios/Rastro/Eventos.php b/app/lib/Correios/Rastro/Eventos.php index 8af0e34..dd90f49 100644 --- a/app/lib/Correios/Rastro/Eventos.php +++ b/app/lib/Correios/Rastro/Eventos.php @@ -148,8 +148,8 @@ class Correios_Rastro_Eventos */ public function __construct( $tipo, $status, $data, $hora, $descricao, $detalhe, $recebedor, $documento, $comentario, $local, $codigo, - $cidade, $uf, $sto, $amazoncode, $amazontimezone, $destino, $endereco - ) { + $cidade, $uf, $sto, $amazoncode, $amazontimezone, $destino, $endereco) + { $this->tipo = $tipo; $this->status = $status; $this->data = $data; From 0a887ed23ce65a9f2d5f297f346c14e84ac07013 Mon Sep 17 00:00:00 2001 From: Pedro Teixeira Date: Mon, 29 May 2017 14:14:45 +0200 Subject: [PATCH 14/15] =?UTF-8?q?Adiciona=20PSR2=20com=20algumas=20modific?= =?UTF-8?q?a=C3=A7=C3=B5es=20e=20atualiza=20PHPCS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Adminhtml/System/Config/Form/Button.php | 6 +- .../PedroTeixeira/Correios/Helper/Data.php | 10 ++-- .../PedroTeixeira/Correios/Model/Cache.php | 6 +- .../Correios/Model/Carrier/CorreiosMethod.php | 24 ++++---- .../Model/Http/Client/Adapter/Socket.php | 2 +- .../PedroTeixeira/Correios/Model/Observer.php | 2 +- .../Correios/Model/Postmethod.php | 6 +- .../Correios/Model/Resource/Postmethod.php | 4 +- .../Model/Resource/Postmethod/Collection.php | 4 +- .../PedroTeixeira/Correios/Model/Sigepweb.php | 4 +- .../PedroTeixeira/Correios/Model/Sro.php | 48 +++++++-------- .../Adminhtml/SigepwebController.php | 2 +- .../install-4.7.0.php | 6 +- .../install-4.8.0.php | 6 +- .../install-4.8.1.php | 6 +- .../install-4.9.0.php | 6 +- .../upgrade-4.6.0-4.7.0.php | 6 +- app/lib/Correios/Rastro.php | 19 +++--- app/lib/Correios/Rastro/BuscaEventos.php | 5 +- app/lib/Correios/Rastro/BuscaEventosLista.php | 5 +- .../Rastro/BuscaEventosListaResponse.php | 5 +- .../Correios/Rastro/BuscaEventosResponse.php | 5 +- app/lib/Correios/Rastro/Destinos.php | 5 +- app/lib/Correios/Rastro/EnderecoMobile.php | 20 +++++-- app/lib/Correios/Rastro/Eventos.php | 28 +++++++-- app/lib/Correios/Rastro/Objeto.php | 5 +- app/lib/Correios/Rastro/Sroxml.php | 5 +- composer.json | 2 +- composer.lock | 59 ++++++------------- ruleset.xml | 57 +++--------------- 30 files changed, 156 insertions(+), 212 deletions(-) diff --git a/app/code/community/PedroTeixeira/Correios/Block/Adminhtml/System/Config/Form/Button.php b/app/code/community/PedroTeixeira/Correios/Block/Adminhtml/System/Config/Form/Button.php index f2f3302..376e1e8 100644 --- a/app/code/community/PedroTeixeira/Correios/Block/Adminhtml/System/Config/Form/Button.php +++ b/app/code/community/PedroTeixeira/Correios/Block/Adminhtml/System/Config/Form/Button.php @@ -16,9 +16,9 @@ class PedroTeixeira_Correios_Block_Adminhtml_System_Config_Form_Button { /** * Retrieve the html code for Element - * + * * @param Varien_Data_Form_Element_Abstract $element Element - * + * * @return string */ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) @@ -28,7 +28,7 @@ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) /** * Retrieve an adminhtml button - * + * * @return string */ public function getButton() diff --git a/app/code/community/PedroTeixeira/Correios/Helper/Data.php b/app/code/community/PedroTeixeira/Correios/Helper/Data.php index 1fe098d..39aaa5e 100644 --- a/app/code/community/PedroTeixeira/Correios/Helper/Data.php +++ b/app/code/community/PedroTeixeira/Correios/Helper/Data.php @@ -15,9 +15,9 @@ class PedroTeixeira_Correios_Helper_Data extends Mage_Core_Helper_Abstract { /** * Gets the configuration value by path - * + * * @param string $path System Config Path - * + * * @return mixed */ public function getConfigData($path) @@ -28,9 +28,9 @@ public function getConfigData($path) /** * Get a text for option value - * + * * @param string|int $value Method Code - * + * * @return string|bool */ public function getShippingLabel($value) @@ -41,7 +41,7 @@ public function getShippingLabel($value) /** * Retrieve stream context as a Soap parameter - * + * * @return array */ public function getStreamContext() diff --git a/app/code/community/PedroTeixeira/Correios/Model/Cache.php b/app/code/community/PedroTeixeira/Correios/Model/Cache.php index 92354b3..6dfb369 100644 --- a/app/code/community/PedroTeixeira/Correios/Model/Cache.php +++ b/app/code/community/PedroTeixeira/Correios/Model/Cache.php @@ -203,17 +203,17 @@ public function loadByTags() /** * Validate the response data from Correios. * This method will choose between Request Cache or Save in Cache - * + * * Step 1: * Invalid responses must call the Cache load. * Cache loading is requested by throwing adapter exception. - * + * * Step 2: * To save valid responses, it must contain no errors. * Errors are detected by pattern_nocache and returns false. * * @param string $data XML Content - * + * * @throws Zend_Http_Client_Adapter_Exception * * @return boolean diff --git a/app/code/community/PedroTeixeira/Correios/Model/Carrier/CorreiosMethod.php b/app/code/community/PedroTeixeira/Correios/Model/Carrier/CorreiosMethod.php index 8d4bcf5..fdeaa3f 100644 --- a/app/code/community/PedroTeixeira/Correios/Model/Carrier/CorreiosMethod.php +++ b/app/code/community/PedroTeixeira/Correios/Model/Carrier/CorreiosMethod.php @@ -139,8 +139,8 @@ protected function _getRequestItems($request) $allItems = $request->getAllItems(); $items = array(); - foreach ( $allItems as $item ) { - if ( !$item->getParentItemId() ) { + foreach ($allItems as $item) { + if (!$item->getParentItemId()) { $items[] = $item; } } @@ -185,7 +185,6 @@ protected function _getQuotes() $correiosReturn = $this->_addPostMethods($correiosReturn); foreach ($correiosReturn as $servicos) { - $errorId = (string) $servicos->Erro; $errorList[$errorId] = $servicos->MsgErro; @@ -587,11 +586,11 @@ public function getTracking($trackings) /** * Loads the parameters and calls the webservice using SOAP - * + * * @param string $code Code - * + * * @return bool|array - * + * * @throws Exception */ protected function _getTrackingRequest($code) @@ -622,13 +621,13 @@ protected function _getTrackingRequest($code) /** * Loads tracking progress details - * + * * @param SimpleXMLElement $evento XML Element Node * @param bool $isDelivered Delivery Flag - * + * * @return array */ - protected function _getTrackingProgressDetails($evento, $isDelivered=false) + protected function _getTrackingProgressDetails($evento, $isDelivered = false) { $date = new Zend_Date($evento->data, 'dd/MM/YYYY', new Zend_Locale('pt_BR')); $track = array( @@ -648,10 +647,10 @@ protected function _getTrackingProgressDetails($evento, $isDelivered=false) } /** - * Loads progress data using the WSDL response - * + * Loads progress data using the WSDL response + * * @param string $request Request response - * + * * @return array */ protected function _getTrackingProgress($request) @@ -867,7 +866,6 @@ protected function _addPostMethods($cServico) protected function _filterMethodByItemRestriction($request) { if ($this->getConfigFlag('filter_by_item')) { - $items = $this->_getRequestItems($request); $intersection = $this->_postMethodsExplode; foreach ($items as $item) { diff --git a/app/code/community/PedroTeixeira/Correios/Model/Http/Client/Adapter/Socket.php b/app/code/community/PedroTeixeira/Correios/Model/Http/Client/Adapter/Socket.php index fa1c71c..e1a6b62 100644 --- a/app/code/community/PedroTeixeira/Correios/Model/Http/Client/Adapter/Socket.php +++ b/app/code/community/PedroTeixeira/Correios/Model/Http/Client/Adapter/Socket.php @@ -140,4 +140,4 @@ public function getConfigData($field) $path = 'carriers/' . $this->_code . '/' . $field; return Mage::getStoreConfig($path); } -} \ No newline at end of file +} diff --git a/app/code/community/PedroTeixeira/Correios/Model/Observer.php b/app/code/community/PedroTeixeira/Correios/Model/Observer.php index 5fe635b..82b19f0 100644 --- a/app/code/community/PedroTeixeira/Correios/Model/Observer.php +++ b/app/code/community/PedroTeixeira/Correios/Model/Observer.php @@ -15,7 +15,7 @@ class PedroTeixeira_Correios_Model_Observer { /** * Look for shipped trackings, and send notifications if available and enabled - * + * * @return string */ public function sroTrackingJob() diff --git a/app/code/community/PedroTeixeira/Correios/Model/Postmethod.php b/app/code/community/PedroTeixeira/Correios/Model/Postmethod.php index 984b02d..ff44b14 100644 --- a/app/code/community/PedroTeixeira/Correios/Model/Postmethod.php +++ b/app/code/community/PedroTeixeira/Correios/Model/Postmethod.php @@ -10,7 +10,7 @@ * @copyright 2015 Pedro Teixeira (http://pedroteixeira.io) * @license http://opensource.org/licenses/MIT MIT * @link https://github.com/pedro-teixeira/correios - * + * * @method string getMethodId() * @method string getMethodCode() * @method string getMethodTitle() @@ -23,9 +23,9 @@ class PedroTeixeira_Correios_Model_Postmethod extends Mage_Core_Model_Abstract { /** * Internal constructor - * + * * @see Varien_Object::_construct() - * + * * @return void */ protected function _construct() diff --git a/app/code/community/PedroTeixeira/Correios/Model/Resource/Postmethod.php b/app/code/community/PedroTeixeira/Correios/Model/Resource/Postmethod.php index 14f99ab..70b6418 100644 --- a/app/code/community/PedroTeixeira/Correios/Model/Resource/Postmethod.php +++ b/app/code/community/PedroTeixeira/Correios/Model/Resource/Postmethod.php @@ -16,9 +16,9 @@ class PedroTeixeira_Correios_Model_Resource_Postmethod { /** * Resource initialization - * + * * @see Mage_Core_Model_Resource_Abstract::_construct() - * + * * @return void */ protected function _construct() diff --git a/app/code/community/PedroTeixeira/Correios/Model/Resource/Postmethod/Collection.php b/app/code/community/PedroTeixeira/Correios/Model/Resource/Postmethod/Collection.php index 788615b..c0fd087 100644 --- a/app/code/community/PedroTeixeira/Correios/Model/Resource/Postmethod/Collection.php +++ b/app/code/community/PedroTeixeira/Correios/Model/Resource/Postmethod/Collection.php @@ -16,9 +16,9 @@ class PedroTeixeira_Correios_Model_Resource_Postmethod_Collection { /** * Resource initialization - * + * * @see Mage_Core_Model_Resource_Db_Collection_Abstract::_construct() - * + * * @return void */ protected function _construct() diff --git a/app/code/community/PedroTeixeira/Correios/Model/Sigepweb.php b/app/code/community/PedroTeixeira/Correios/Model/Sigepweb.php index 0d8cc2c..72c71b9 100644 --- a/app/code/community/PedroTeixeira/Correios/Model/Sigepweb.php +++ b/app/code/community/PedroTeixeira/Correios/Model/Sigepweb.php @@ -16,7 +16,7 @@ class PedroTeixeira_Correios_Model_Sigepweb extends Mage_Core_Model_Abstract /** * Retrieve the module helper - * + * * @return Pedroteixeira_Correios_Helper_Data */ public function helper() @@ -26,7 +26,7 @@ public function helper() /** * Request Correios service codes using configuration fields - * + * * @return SimpleXMLElement */ public function getBuscaCliente() diff --git a/app/code/community/PedroTeixeira/Correios/Model/Sro.php b/app/code/community/PedroTeixeira/Correios/Model/Sro.php index 09f1108..6bb173f 100644 --- a/app/code/community/PedroTeixeira/Correios/Model/Sro.php +++ b/app/code/community/PedroTeixeira/Correios/Model/Sro.php @@ -21,7 +21,7 @@ class PedroTeixeira_Correios_Model_Sro extends Varien_Object /** * Retrieves all valid tracking codes - * + * * @return PedroTeixeira_Correios_Model_Sro */ public function init() @@ -40,7 +40,7 @@ public function init() /** * Load all opened tracks from database. * Filter tracks only with complete order state, and shipped status. - * + * * @return Mage_Sales_Model_Resource_Order_Shipment_Track_Collection */ public function getShippedTracks() @@ -60,14 +60,14 @@ public function getShippedTracks() /** * Load XML response from Correios - * + * * @throws Exception - * + * * @link http://www.correios.com.br/para-voce/correios-de-a-a-z/pdf/rastreamento-de-objetos/ * Manual_SROXML_28fev14.pdf * @link http://www.corporativo.correios.com.br/encomendas/sigepweb/doc/ * Manual_de_Implementacao_do_Web_Service_SIGEPWEB_Logistica_Reversa.pdf - * + * * @return boolean|Correios_Rastro_BuscaEventosResponse */ public function request() @@ -103,9 +103,9 @@ public function request() /** * Retrieve config value by path - * + * * @param string $path Variable Path - * + * * @return string */ public function getConfigData($path) @@ -115,9 +115,9 @@ public function getConfigData($path) /** * Returns a Shipping comment message - * + * * @param Correios_Rastro_Objeto $obj Response Object - * + * * @return string */ public function getComment($obj) @@ -144,10 +144,10 @@ public function getComment($obj) /** * 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($obj, $track) @@ -175,10 +175,10 @@ public function getEmailComment($obj, $track) /** * Check the event type - * + * * @param Correios_Rastro_Objeto $obj Response Object * @param string $mode Event Type Mode - * + * * @return boolean */ public function validate($obj, $mode) @@ -197,9 +197,9 @@ public function validate($obj, $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($obj) @@ -216,9 +216,9 @@ public function getEventId($obj) /** * Check whether event notify is enabled or not - * + * * @param Correios_Rastro_Objeto $obj Response Object - * + * * @return boolean */ public function isNotify($obj) @@ -228,9 +228,9 @@ public function isNotify($obj) /** * Load order status based on event checking - * + * * @param Correios_Rastro_Objeto $obj Response Object - * + * * @return string */ public function getStatus($obj) @@ -247,9 +247,9 @@ public function getStatus($obj) /** * Validates the tracking code - * + * * @param string $trackNumber Tracking Code - * + * * @return boolean */ public function validateTrackNumber($trackNumber) @@ -259,11 +259,11 @@ public function validateTrackNumber($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) diff --git a/app/code/community/PedroTeixeira/Correios/controllers/Adminhtml/SigepwebController.php b/app/code/community/PedroTeixeira/Correios/controllers/Adminhtml/SigepwebController.php index 92aa4fb..e6c8dd2 100644 --- a/app/code/community/PedroTeixeira/Correios/controllers/Adminhtml/SigepwebController.php +++ b/app/code/community/PedroTeixeira/Correios/controllers/Adminhtml/SigepwebController.php @@ -16,7 +16,7 @@ class PedroTeixeira_Correios_Adminhtml_SigepwebController { /** * This updates the available service codes from Correios - * + * * @return void */ public function postmethodsUpdateAction() diff --git a/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/install-4.7.0.php b/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/install-4.7.0.php index 2704604..0b9305e 100644 --- a/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/install-4.7.0.php +++ b/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/install-4.7.0.php @@ -126,16 +126,14 @@ 'posting_days' ); -foreach ( $setIds as $setId ) { - +foreach ($setIds as $setId) { $setup->addAttributeGroup('catalog_product', $setId, 'Correios', 2); $groupId = $setup->getAttributeGroupId('catalog_product', $setId, 'Correios'); - foreach ( $attributes as $attribute ) { + foreach ($attributes as $attribute) { $attributeId = $setup->getAttributeId('catalog_product', $attribute); $setup->addAttributeToGroup('catalog_product', $setId, $groupId, $attributeId); } - } $installer->endSetup(); diff --git a/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/install-4.8.0.php b/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/install-4.8.0.php index 39d3831..160f7a4 100644 --- a/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/install-4.8.0.php +++ b/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/install-4.8.0.php @@ -126,16 +126,14 @@ 'posting_days' ); -foreach ( $setIds as $setId ) { - +foreach ($setIds as $setId) { $setup->addAttributeGroup('catalog_product', $setId, 'Correios', 2); $groupId = $setup->getAttributeGroupId('catalog_product', $setId, 'Correios'); - foreach ( $attributes as $attribute ) { + foreach ($attributes as $attribute) { $attributeId = $setup->getAttributeId('catalog_product', $attribute); $setup->addAttributeToGroup('catalog_product', $setId, $groupId, $attributeId); } - } $tableName = $this->getTable('pedroteixeira_correios/postmethod'); diff --git a/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/install-4.8.1.php b/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/install-4.8.1.php index 39d3831..160f7a4 100644 --- a/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/install-4.8.1.php +++ b/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/install-4.8.1.php @@ -126,16 +126,14 @@ 'posting_days' ); -foreach ( $setIds as $setId ) { - +foreach ($setIds as $setId) { $setup->addAttributeGroup('catalog_product', $setId, 'Correios', 2); $groupId = $setup->getAttributeGroupId('catalog_product', $setId, 'Correios'); - foreach ( $attributes as $attribute ) { + foreach ($attributes as $attribute) { $attributeId = $setup->getAttributeId('catalog_product', $attribute); $setup->addAttributeToGroup('catalog_product', $setId, $groupId, $attributeId); } - } $tableName = $this->getTable('pedroteixeira_correios/postmethod'); diff --git a/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/install-4.9.0.php b/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/install-4.9.0.php index 0ca6e69..73b9507 100644 --- a/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/install-4.9.0.php +++ b/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/install-4.9.0.php @@ -126,16 +126,14 @@ 'posting_days' ); -foreach ( $setIds as $setId ) { - +foreach ($setIds as $setId) { $setup->addAttributeGroup('catalog_product', $setId, 'Correios', 2); $groupId = $setup->getAttributeGroupId('catalog_product', $setId, 'Correios'); - foreach ( $attributes as $attribute ) { + foreach ($attributes as $attribute) { $attributeId = $setup->getAttributeId('catalog_product', $attribute); $setup->addAttributeToGroup('catalog_product', $setId, $groupId, $attributeId); } - } $tableName = $this->getTable('pedroteixeira_correios/postmethod'); diff --git a/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/upgrade-4.6.0-4.7.0.php b/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/upgrade-4.6.0-4.7.0.php index 2337b29..762615b 100644 --- a/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/upgrade-4.6.0-4.7.0.php +++ b/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/upgrade-4.6.0-4.7.0.php @@ -28,16 +28,14 @@ 'posting_days' ); -foreach ( $setIds as $setId ) { - +foreach ($setIds as $setId) { $setup->addAttributeGroup('catalog_product', $setId, 'Correios', 2); $groupId = $setup->getAttributeGroupId('catalog_product', $setId, 'Correios'); - foreach ( $attributes as $attribute ) { + foreach ($attributes as $attribute) { $attributeId = $setup->getAttributeId('catalog_product', $attribute); $setup->addAttributeToGroup('catalog_product', $setId, $groupId, $attributeId); } - } $installer->endSetup(); diff --git a/app/lib/Correios/Rastro.php b/app/lib/Correios/Rastro.php index c010236..5569931 100644 --- a/app/lib/Correios/Rastro.php +++ b/app/lib/Correios/Rastro.php @@ -27,15 +27,15 @@ class Correios_Rastro extends SoapClient 'Destinos' => 'Correios_Rastro_Destinos', 'EnderecoMobile' => 'Correios_Rastro_EnderecoMobile', 'BuscaEventos' => 'Correios_Rastro_BuscaEventos', - 'BuscaEventosResponse' => 'Correios_Rastro_BuscaEventosResponse' + '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') @@ -51,11 +51,11 @@ public function __construct(array $options = array(), $wsdl = 'Rastro.wsdl') /** * Request method for buscaEventos - * + * * @param Correios_Rastro_BuscaEventos $parameters Parameters - * + * * @access public - * + * * @return Correios_Rastro_BuscaEventosResponse */ public function buscaEventos(Correios_Rastro_BuscaEventos $parameters) @@ -65,16 +65,15 @@ public function buscaEventos(Correios_Rastro_BuscaEventos $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 index b7714c4..c09a9c3 100644 --- a/app/lib/Correios/Rastro/BuscaEventos.php +++ b/app/lib/Correios/Rastro/BuscaEventos.php @@ -52,14 +52,14 @@ class Correios_Rastro_BuscaEventos /** * 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) @@ -71,5 +71,4 @@ public function __construct($usuario, $senha, $tipo, $resultado, $lingua, $objet $this->lingua = $lingua; $this->objetos = $objetos; } - } diff --git a/app/lib/Correios/Rastro/BuscaEventosLista.php b/app/lib/Correios/Rastro/BuscaEventosLista.php index c8dd767..d5b8118 100644 --- a/app/lib/Correios/Rastro/BuscaEventosLista.php +++ b/app/lib/Correios/Rastro/BuscaEventosLista.php @@ -52,14 +52,14 @@ class Correios_Rastro_BuscaEventosLista /** * 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) @@ -71,5 +71,4 @@ public function __construct($usuario, $senha, $tipo, $resultado, $lingua, $objet $this->lingua = $lingua; $this->objetos = $objetos; } - } diff --git a/app/lib/Correios/Rastro/BuscaEventosListaResponse.php b/app/lib/Correios/Rastro/BuscaEventosListaResponse.php index eeb4253..3048ee3 100644 --- a/app/lib/Correios/Rastro/BuscaEventosListaResponse.php +++ b/app/lib/Correios/Rastro/BuscaEventosListaResponse.php @@ -22,14 +22,13 @@ class Correios_Rastro_BuscaEventosListaResponse /** * 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 index 57042c5..eef48ca 100644 --- a/app/lib/Correios/Rastro/BuscaEventosResponse.php +++ b/app/lib/Correios/Rastro/BuscaEventosResponse.php @@ -22,14 +22,13 @@ class Correios_Rastro_BuscaEventosResponse /** * 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 index 70cbe29..ebbfa99 100644 --- a/app/lib/Correios/Rastro/Destinos.php +++ b/app/lib/Correios/Rastro/Destinos.php @@ -46,13 +46,13 @@ class Correios_Rastro_Destinos /** * 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) @@ -63,5 +63,4 @@ public function __construct($local, $codigo, $cidade, $bairro, $uf) $this->bairro = $bairro; $this->uf = $uf; } - } diff --git a/app/lib/Correios/Rastro/EnderecoMobile.php b/app/lib/Correios/Rastro/EnderecoMobile.php index 724e4c1..3c8db98 100644 --- a/app/lib/Correios/Rastro/EnderecoMobile.php +++ b/app/lib/Correios/Rastro/EnderecoMobile.php @@ -82,7 +82,7 @@ class Correios_Rastro_EnderecoMobile /** * Class constructor method - * + * * @param string $codigo Code * @param string $cep Zip * @param string $logradouro Street @@ -94,12 +94,23 @@ class Correios_Rastro_EnderecoMobile * @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) - { + $codigo, + $cep, + $logradouro, + $complemento, + $numero, + $localidade, + $uf, + $bairro, + $latitude, + $longitude, + $celular + ) { + $this->codigo = $codigo; $this->cep = $cep; $this->logradouro = $logradouro; @@ -112,5 +123,4 @@ public function __construct( $this->longitude = $longitude; $this->celular = $celular; } - } diff --git a/app/lib/Correios/Rastro/Eventos.php b/app/lib/Correios/Rastro/Eventos.php index dd90f49..57dc004 100644 --- a/app/lib/Correios/Rastro/Eventos.php +++ b/app/lib/Correios/Rastro/Eventos.php @@ -124,7 +124,7 @@ class Correios_Rastro_Eventos /** * Class constructor method - * + * * @param string $tipo Type * @param string $status State * @param string $data Date @@ -143,13 +143,30 @@ class Correios_Rastro_Eventos * @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) - { + $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; @@ -169,5 +186,4 @@ public function __construct( $this->destino = $destino; $this->endereco = $endereco; } - } diff --git a/app/lib/Correios/Rastro/Objeto.php b/app/lib/Correios/Rastro/Objeto.php index ec0f602..d2d9d02 100644 --- a/app/lib/Correios/Rastro/Objeto.php +++ b/app/lib/Correios/Rastro/Objeto.php @@ -52,14 +52,14 @@ class Correios_Rastro_Objeto /** * 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) @@ -71,5 +71,4 @@ public function __construct($numero, $sigla, $nome, $categoria, $erro, $evento) $this->erro = $erro; $this->evento = $evento; } - } diff --git a/app/lib/Correios/Rastro/Sroxml.php b/app/lib/Correios/Rastro/Sroxml.php index 41eee51..1b7d95f 100644 --- a/app/lib/Correios/Rastro/Sroxml.php +++ b/app/lib/Correios/Rastro/Sroxml.php @@ -46,13 +46,13 @@ class Correios_Rastro_Sroxml /** * 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) @@ -63,5 +63,4 @@ public function __construct($versao, $qtd, $TipoPesquisa, $TipoResultado, $objet $this->TipoResultado = $TipoResultado; $this->objeto = $objeto; } - } diff --git a/composer.json b/composer.json index aecd8d5..426155f 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "description" : "Módulo de frete para Magento com tracking ", "require" : { "php" : ">=5.4", - "squizlabs/php_codesniffer" : "~1" + "squizlabs/php_codesniffer" : "~3" }, "config" : { "bin-dir" : "bin" diff --git a/composer.lock b/composer.lock index 8acaefd..92b5cb1 100644 --- a/composer.lock +++ b/composer.lock @@ -1,67 +1,44 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" ], - "hash": "ac1ab71a23addf4d4d1f0db627e9a526", + "content-hash": "ff3e1c6a7b395d8eec2a4b14003e7718", "packages": [ { "name": "squizlabs/php_codesniffer", - "version": "1.5.5", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "5d973e59cf58a0c847f298de84374c96b42b17b3" + "reference": "b95ff2c3b122a3ee4b57d149a57d2afce65522c3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/5d973e59cf58a0c847f298de84374c96b42b17b3", - "reference": "5d973e59cf58a0c847f298de84374c96b42b17b3", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/b95ff2c3b122a3ee4b57d149a57d2afce65522c3", + "reference": "b95ff2c3b122a3ee4b57d149a57d2afce65522c3", "shasum": "" }, "require": { + "ext-simplexml": "*", "ext-tokenizer": "*", - "php": ">=5.1.2" + "ext-xmlwriter": "*", + "php": ">=5.4.0" }, - "suggest": { - "phpunit/php-timer": "dev-master" + "require-dev": { + "phpunit/phpunit": "~4.0" }, "bin": [ - "scripts/phpcs" + "bin/phpcs", + "bin/phpcbf" ], "type": "library", "extra": { "branch-alias": { - "dev-phpcs-fixer": "2.0.x-dev" + "dev-master": "3.x-dev" } }, - "autoload": { - "classmap": [ - "CodeSniffer.php", - "CodeSniffer/CLI.php", - "CodeSniffer/Exception.php", - "CodeSniffer/File.php", - "CodeSniffer/Report.php", - "CodeSniffer/Reporting.php", - "CodeSniffer/Sniff.php", - "CodeSniffer/Tokens.php", - "CodeSniffer/Reports/", - "CodeSniffer/CommentParser/", - "CodeSniffer/Tokenizers/", - "CodeSniffer/DocGenerators/", - "CodeSniffer/Standards/AbstractPatternSniff.php", - "CodeSniffer/Standards/AbstractScopeSniff.php", - "CodeSniffer/Standards/AbstractVariableSniff.php", - "CodeSniffer/Standards/IncorrectPatternException.php", - "CodeSniffer/Standards/Generic/Sniffs/", - "CodeSniffer/Standards/MySource/Sniffs/", - "CodeSniffer/Standards/PEAR/Sniffs/", - "CodeSniffer/Standards/PSR1/Sniffs/", - "CodeSniffer/Standards/PSR2/Sniffs/", - "CodeSniffer/Standards/Squiz/Sniffs/", - "CodeSniffer/Standards/Zend/Sniffs/" - ] - }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" @@ -72,19 +49,21 @@ "role": "lead" } ], - "description": "PHP_CodeSniffer tokenises PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", "homepage": "http://www.squizlabs.com/php-codesniffer", "keywords": [ "phpcs", "standards" ], - "time": "2014-09-25 03:33:46" + "time": "2017-05-04T00:33:04+00:00" } ], "packages-dev": [], "aliases": [], "minimum-stability": "stable", "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, "platform": { "php": ">=5.4" }, diff --git a/ruleset.xml b/ruleset.xml index 96b0090..6d064f3 100644 --- a/ruleset.xml +++ b/ruleset.xml @@ -1,52 +1,11 @@ - - - - - - - - - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + From 2352e1de0ac77b0705025dff75f93d8aaf22388d Mon Sep 17 00:00:00 2001 From: Pedro Teixeira Date: Mon, 29 May 2017 14:22:10 +0200 Subject: [PATCH 15/15] Adiciona changelog --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44cebf5..606de98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +# v4.9.0 + +### Bugfix + +- [#265](https://github.com/pedro-teixeira/correios/issues/265) Correção para Produtos Configuráveis + +### Feature + +- [#266](https://github.com/pedro-teixeira/correios/issues/266) Melhoria no Monitoramento Automático +- [#268](https://github.com/pedro-teixeira/correios/issues/268) Adiciona PSR2 com algumas modificações e atualiza PHPCS + # v4.8.1 ### Bugfix