-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mikel
committed
Jan 8, 2019
1 parent
62c9b70
commit 7423f10
Showing
3 changed files
with
104 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
/** | ||
* Copyright © 2017 SeQura Engineering. All rights reserved. | ||
*/ | ||
|
||
namespace Sequra\Core\Console; | ||
|
||
use \Sequra\Core\Model\ConfigFactory; | ||
use \Symfony\Component\Console\Command\Command; | ||
use \Symfony\Component\Console\Input\InputArgument; | ||
use \Symfony\Component\Console\Input\InputInterface; | ||
use \Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class TriggerReport extends Command | ||
{ | ||
/** Command name */ | ||
const NAME = 'sequra:triggerreport'; | ||
|
||
/** | ||
* Names of input arguments or options | ||
*/ | ||
const INPUT_KEY_SHOPCODES = 'shopcodes'; | ||
|
||
/** | ||
* @var \Sequra\Core\Model\Config | ||
*/ | ||
protected $_config; | ||
|
||
/** | ||
* @var \Sequra\Core\Model\ReporterFactory | ||
*/ | ||
protected $_reporter; | ||
|
||
|
||
/** | ||
* Constructor | ||
* | ||
* @param ConfigFactory $configFactory | ||
* @param \Sequra\Core\Model\ReporterFactory $reporterFactory | ||
*/ | ||
public function __construct( | ||
ConfigFactory $configFactory, | ||
\Sequra\Core\Model\ReporterFactory $reporterFactory | ||
) { | ||
$this->_config = $configFactory->create(); | ||
$this->_reporter = $reporterFactory->create(); | ||
parent::__construct(); | ||
} | ||
|
||
protected function configure() | ||
{ | ||
$this->addArgument( | ||
self::INPUT_KEY_SHOPCODES, | ||
InputArgument::IS_ARRAY | InputArgument::OPTIONAL, | ||
'Shop code' | ||
); | ||
$this->setName(self::NAME) | ||
->setDescription('Send Delivery Report to SeQura'); | ||
|
||
parent::configure(); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
$codeKeys = $input->getArgument(self::INPUT_KEY_SHOPCODES); | ||
$output->write('Trigger Delivery Report for '); | ||
if(count($codeKeys)<1){ | ||
$codeKeys[0] = false; | ||
$output->writeln('all shops'); | ||
} else { | ||
$output->writeln(implode(',',$codeKeys)); | ||
} | ||
foreach ($codeKeys as $codeKey){ | ||
if ($results = $this->_reporter->sendOrderWithShipment($codeKey)) { | ||
$output->writeln('Ok, report Sent!'); | ||
foreach($results as $key => $value){ | ||
$output->writeln($key . ' => ' . $value . ' orders sent'); | ||
} | ||
return; | ||
} | ||
$output->writeln('Ko, report was not sent!'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters