예제 #1
0
 /**
  * @dataProvider applicantProvider
  */
 public function testGetNewInstance($name, $email, $zip)
 {
     $applicant = new Applicant(["name" => $name, 'email' => $email, "address_zip" => $zip]);
     $newApplicant = $applicant->getNewInstance();
     $this->assertInstanceOf('Playbook\\Applicant', $newApplicant);
     $this->assertEquals($name, $newApplicant->name);
     $this->assertEquals($email, $newApplicant->email);
     $this->assertEquals($zip, $newApplicant->address_zip);
 }
예제 #2
0
 /**
  * searches playbook for a user matching the applicant object criteria
  *
  * @param Applicant $applicant
  *
  * @return mixed
  * @throws ApplicantNotFoundException
  * @throws \Exception
  */
 public function searchApplicants(Applicant $applicant)
 {
     if (!$applicant->email) {
         throw new InvalidApplicantException("Applicant is missing a required field");
     }
     try {
         $response = $this->client->request("GET", '/api/v2/search', ["auth" => [$this->user, $this->api_key], "query" => $applicant->toArray()]);
     } catch (ClientException $e) {
         throw new \Exception($e->getMessage());
     } catch (ServerException $e) {
         throw new \Exception("ERROR: " . $e->getMessage());
     }
     $body = $response->getBody();
     $json = json_decode((string) $body, true);
     if ($json['found'] === false) {
         throw new ApplicantNotFoundException("Applicant was not found");
     }
     return $applicant->getNewInstance(array_filter($json['applicant']), $this);
 }