Exemple #1
0
 /**
  * Constructor injects factories and creates dependancies
  *
  * @param CallServiceFactory    $callServiceFactory
  * @param FileSystemFactory     $fileSystemFactory
  * @param ResultsHandlerFactory $resultsHandlerFactory
  */
 public function __construct(CallServiceFactory $callServiceFactory, FileSystemFactory $fileSystemFactory, ResultsHandlerFactory $resultsHandlerFactory)
 {
     $callService = Config::get('callservice.default');
     $this->callService = $callServiceFactory->make($callService);
     $this->fileSystem = $fileSystemFactory->make(Config::get('filesystem.default'));
     $this->resultsHandler = $resultsHandlerFactory->make($callService);
     parent::__construct();
 }
 /**
  * Create a CallServiceInterface implementation
  *
  * @param string $default
  *
  * @return CallServiceInterface
  */
 public function make($default)
 {
     $connection = Config::getConnection('callservice', $default);
     switch ($connection['driver']) {
         case 'twilio':
             return new TwilioCallService(new Services_Twilio($connection['sid'], $connection['token']));
             break;
     }
     // @codeCoverageIgnore
 }
 /**
  * Create a ResultsHandlerInterface implementation
  *
  * @param string $default
  *
  * @return ResultsHandler
  */
 public function make($default)
 {
     $connection = Config::getConnection('callservice', $default);
     switch ($connection['driver']) {
         case 'twilio':
             return new TwilioResultsHandler();
             break;
     }
     // @codeCoverageIgnore
 }
Exemple #4
0
 /**
  * Execute the command
  *
  * @param InputInterface  $input  InputInterface instance
  * @param OutputInterface $output OutputInterface instance
  *
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (!$this->uploadCallScript($input->getArgument('path'), $output)) {
         return;
     }
     $callIds = $this->placeCalls(explode(',', $input->getArgument('numbers')), $input->getOption('from') ?: Config::get('callservice.from'));
     $results = $this->callService->getDetails($callIds);
     if (!empty($results)) {
         $this->resultsHandler->displayTable($this->getHelperSet()->get('table'), $results, $output);
     }
 }
Exemple #5
0
 /**
  * Create a FileSystem instance
  *
  * @param string $default
  *
  * @return FileSystem
  */
 public function make($default)
 {
     $connection = Config::getConnection('filesystem', $default);
     switch ($connection['driver']) {
         case 's3':
             $client = S3Client::factory(['key' => $connection['key'], 'secret' => $connection['secret']]);
             $bucket = $connection['bucket'];
             return new FileSystem(new AwsS3($client, $bucket));
             break;
     }
     // @codeCoverageIgnore
 }
Exemple #6
0
 /**
  * Sets the batches to be ran based on what is
  * present in batches.php and what the user supplies
  * in the batches argument
  *
  * @param string $batches Comma separated list of batch names
  *
  * @return array
  */
 protected function getBatchesToRun($batches)
 {
     $allBatches = Config::get('batches');
     if ($batches) {
         $batchNames = explode(',', $batches);
         $batchesToRun = array();
         foreach ($batchNames as $name) {
             $batchesToRun[] = $allBatches[$name];
         }
         return $batchesToRun;
     } else {
         return $allBatches;
     }
 }
Exemple #7
0
 /**
  * @expectedException InvalidArgumentException
  */
 public function testInvalidFileNameThrowsException()
 {
     Config::get('foo.bar');
 }
Exemple #8
0
 /**
  * Convert timestamps to UTC before making API request
  *
  * @param  string $date
  *
  * @return string
  */
 protected function convertToUTC($date)
 {
     $dateTime = new \DateTime($date, new \DateTimeZone(Config::get('callservice.timezone')));
     $offsetHours = $dateTime->format('P');
     return $dateTime->modify($offsetHours)->setTimezone(new \DateTimeZone('UTC'))->format('Y-m-d H:i:s');
 }
Exemple #9
0
 /**
  * Format the date for display
  *
  * @param string $date
  *
  * @return DateTime
  */
 protected function formatDate($date)
 {
     return (new \DateTime($date))->setTimezone(new \DateTimeZone(Config::get('callservice.timezone')))->format('Y-m-d H:i:s');
 }