Esempio n. 1
0
 public function parse(Session $rets, Response $response, $parameters)
 {
     // we're given the first response automatically, so parse this and start the recursion
     /** @var \PHRETS\Parsers\Search\OneX $parser */
     $parser = $rets->getConfiguration()->getStrategy()->provide('parser.search');
     $rs = $parser->parse($rets, $response, $parameters);
     while ($this->continuePaginating($rets, $parameters, $rs)) {
         $pms = $parameters;
         $rets->debug("Continuing pagination...");
         $rets->debug("Current count collected already: " . $rs->count());
         $resource = $pms['SearchType'];
         $class = $pms['Class'];
         $query = array_key_exists('Query', $pms) ? $pms['Query'] : null;
         $pms['Offset'] = $this->getNewOffset($rets, $parameters, $rs);
         unset($pms['SearchType']);
         unset($pms['Class']);
         unset($pms['Query']);
         /** @var Results $inner_rs */
         $inner_rs = $rets->Search($resource, $class, $query, $pms, false);
         $rs->setTotalResultsCount($inner_rs->getTotalResultsCount());
         $rs->setMaxRowsReached($inner_rs->isMaxRowsReached());
         // test if we're actually paginating
         if ($this->isPaginationBroken($rs, $inner_rs)) {
             throw new AutomaticPaginationError("Automatic pagination doesn't not appear to be supported by the server");
         }
         foreach ($inner_rs as $ir) {
             $rs->addRecord($ir);
         }
     }
     return $rs;
 }
Esempio n. 2
0
 /**
  * @param Session $rets
  * @param $xml
  * @param $parameters
  * @return string
  */
 protected function getDelimiter(Session $rets, $xml, $parameters)
 {
     if (isset($xml->DELIMITER)) {
         // delimiter found so we have at least a COLUMNS row to parse
         return chr("{$xml->DELIMITER->attributes()->value}");
     } else {
         // assume tab delimited since it wasn't given
         $rets->debug('Assuming TAB delimiter since none specified in response');
         return chr("09");
     }
 }
Esempio n. 3
0
 public function setUp()
 {
     $client = new GuzzleHttp\Client();
     $watcher = new Gsaulmon\GuzzleRecorder\GuzzleRecorder(__DIR__ . '/Fixtures/Http');
     $watcher->includeCookies(false);
     $client->getEmitter()->attach($watcher);
     \PHRETS\Http\Client::set($client);
     $config = new \PHRETS\Configuration();
     $config->setLoginUrl('http://retsgw.flexmls.com/rets2_1/Login')->setUsername(getenv('PHRETS_TESTING_USERNAME'))->setPassword(getenv('PHRETS_TESTING_PASSWORD'))->setRetsVersion('1.7.2');
     $this->session = new PHRETS\Session($config);
     $this->session->Login();
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $config = ConfigLoader::get();
     $output->writeln('<comment>Testing connection...</comment>');
     $rets = new Session($config);
     try {
         $connect = $rets->Login();
     } catch (Exception $e) {
         $output->writeln('<error>Cannot connect:</error>');
         $output->writeln("<error>{$e}</error>");
         return;
     }
     $output->writeln('<info>Conntected</info>');
 }
Esempio n. 5
0
 /**
  * @return null
  */
 public function getMetadata()
 {
     if (!$this->metadata) {
         $this->metadata = $this->session->GetTableMetadata($this->getResource(), $this->getClass());
     }
     return $this->metadata;
 }
Esempio n. 6
0
 /**
  * @param Session $session
  * @return string
  */
 public function userAgentDigestHash(Session $session)
 {
     $ua_a1 = md5($this->getUserAgent() . ':' . $this->getUserAgentPassword());
     return md5(trim($ua_a1) . '::' . trim($session->getRetsSessionId()) . ':' . trim($this->getRetsVersion()->asHeader()));
 }
Esempio n. 7
0
 /** @test **/
 public function it_allows_overriding_the_cookie_jar()
 {
     $c = new Configuration();
     $c->setLoginUrl('http://www.reso.org/login');
     $s = new Session($c);
     $jar = new \GuzzleHttp\Cookie\CookieJar();
     $s->setCookieJar($jar);
     $this->assertSame($jar, $s->getCookieJar());
 }