コード例 #1
0
ファイル: ApiTest.php プロジェクト: caseyw/ziprecruiter-php
 /**
  * Test Can Get Multiple Result Pages
  */
 public function testCanGetMultipleResultPages()
 {
     $client = new Client();
     $responses = [new Response(200, [], Stream::factory('{"limit":"1","results":[{"email_md5":"12345678901234567890123456789012","deactivation_reason":"inactivity-never-clicked-14-day","create_time":"2015-01-01T02:31:25","brand":"example1","id":"12345678","deactivation_time":"2015-04-10T23:53:31"}],"offset":"0","total_count":"3"}')), new Response(200, [], Stream::factory('{"limit":"1","results":[{"email_md5":"12345678901234567890123456789012","deactivation_reason":"inactivity-120-day","create_time":"2015-01-01T00:24:21","brand":"example2","id":"23456789","deactivation_time":"2015-04-10T23:50:02"}],"offset":"1","total_count":"3"}')), new Response(200, [], Stream::factory('{"limit":"1","results":[{"email_md5":"12345678901234567890123456789012","deactivation_reason":"inactivity-never-cli","create_time":"2015-01-01T16:00:24","brand":"example3","id":"34567890","deactivation_time":"2015-04-10T00:13:55"}],"offset":"2","total_count":"3"}')), new Response(200, [], Stream::factory('{"limit":"1","results":[],"offset":"3","total_count":"3"}'))];
     $mock = new Mock($responses);
     $client->getEmitter()->attach($mock);
     $query = new Query();
     $query->setDeactivationTime('2015-04-10 10:30:30');
     $query->setLimit(1);
     $query->setSkip(0);
     $api = new ZipRecruiterApi($client);
     $results = $api->querySubscribers($query);
     $this->assertEquals(3, count($results));
 }
コード例 #2
0
 /**
  * Helper method to get results even when the world is against you... I AM NOT DRAMATIC
  *
  * @param string $url
  * @param Query $query
  *
  * @return ResponseInterface
  */
 protected function fetchResponse($url, $query)
 {
     try {
         $response = $this->client->get($url, ['query' => $query->toArray()]);
     } catch (\GuzzleHttp\Exception\ServerException $e) {
         $response = $this->fetchResponse($url, $query);
     }
     return $response;
 }