Example #1
0
 public function get()
 {
     switch ($this->getParameter('mode')) {
         case 'cc':
             $buy = ExchangeModule::CURRENCY;
             break;
         case 'gold':
         default:
             $buy = ExchangeModule::GOLD;
             break;
     }
     $module = new ExchangeModule($this->client);
     $offers = $module->scan($buy, $this->getParameter('page'));
     $data = array('paginator' => $offers->getPaginator()->toArray(), 'offers' => $offers->getArrayCopy());
     $data['offers']['@nodeName'] = 'offer';
     $vm = new ViewModel($data);
     $vm->setRootNodeName('offers');
     return $vm;
 }
Example #2
0
 protected function buy($offer, $toBuy)
 {
     $output = $this->output;
     $result = $this->exchangeModule->buy($offer->id, $toBuy);
     $output->writeln('<info>' . $result['message'] . '</info>');
     if (preg_match('/buy more than ([\\d.]+)/', $result['message'], $m)) {
         $toBuy = (double) $m[1];
         $result = $this->exchangeModule->buy($offer->id, $toBuy);
         $output->writeln('<info>' . $result['message'] . '</info>');
     }
 }