Esempio n. 1
0
 public function testGetNextRequestNested()
 {
     $client = RestClient::create();
     $config = new JobConfig('test', ['endpoint' => 'test']);
     $scroller = new CursorScroller(['idKey' => 'id.int', 'param' => 'since_id']);
     $response = [(object) ['id' => (object) ['int' => 3]]];
     $next = $scroller->getNextRequest($client, $config, $response, $response);
     $expected = $client->createRequest(['endpoint' => 'test', 'params' => ['since_id' => 3]]);
     self::assertEquals($expected, $next);
 }
Esempio 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;
     }
 }