Ejemplo n.º 1
0
 /**
  * @expectedException \Keboola\Juicer\Exception\UserException
  * @expectedExceptionMessage Scroller 'nonExistentScroller' not set in API definitions. Scrollers defined: param, cursor, page
  */
 public function testUndefinedScrollerException()
 {
     $config = $this->getScrollerConfig();
     $scroller = new MultipleScroller($config);
     $noScrollerConfig = new JobConfig('none', ['endpoint' => 'data', 'scroller' => 'nonExistentScroller']);
     $req = $scroller->getFirstRequest(RestClient::create(), $noScrollerConfig);
 }
Ejemplo n.º 2
0
 protected static function createScroller(array $config)
 {
     if (empty($config['method'])) {
         return NoScroller::create([]);
     }
     switch ($config['method']) {
         case 'offset':
             return OffsetScroller::create($config);
         case 'response.param':
             return ResponseParamScroller::create($config);
         case 'response.url':
             return ResponseUrlScroller::create($config);
         case 'zendesk.response.url':
             return ZendeskResponseUrlScroller::create($config);
         case 'facebook.response.url':
             return FacebookResponseUrlScroller::create($config);
         case 'pagenum':
             return PageScroller::create($config);
         case 'cursor':
             return CursorScroller::create($config);
         case 'multiple':
             return MultipleScroller::create($config);
         default:
             $method = is_string($config['method']) ? $config['method'] : json_encode($config['method']);
             throw new UserException("Unknown pagination method '{$method}'");
             break;
     }
 }