public function testCreate() { \Onfido\Config::init()->set_token('test_NY2rpxJR3C0YwS9WWDzSMoFJ5s95-7aV'); $random = time() . rand(0, 999); $applicant = new \Onfido\Applicant(); $applicant->first_name = 'John' . $random; $applicant->last_name = 'Smith'; $applicant->email = 'email' . $random . '@server.com'; $address1 = new \Onfido\Address(); $address1->postcode = 'abc'; $address1->town = 'London'; $address1->country = 'GBR'; $applicant->addresses = array($address1); $response = $applicant->create(); $this->assertInstanceOf('stdClass', $response); $this->assertObjectHasAttribute('first_name', $response); $this->assertEquals($response->first_name, 'John' . $random); $check = new \Onfido\Check(); $check->type = 'standard'; $report1 = new \Onfido\CheckReport(); $report1->name = 'identity'; $check->reports = array($report1); $response = $check->create_for($response->id); $this->assertInstanceOf('stdClass', $response); }
public function testGet() { \Onfido\Config::init()->set_token('test_NY2rpxJR3C0YwS9WWDzSMoFJ5s95-7aV'); $report = (new \Onfido\Report())->get('e573d91a-691d-473e-b460-a43c73d3a8ee', self::$reports[0]->id); $this->assertInstanceOf('stdClass', $report); $this->assertObjectHasAttribute('id', $report); $this->assertEquals(self::$reports[0]->id, $report->id); }
public function testAddress() { \Onfido\Config::init()->set_token('test_NY2rpxJR3C0YwS9WWDzSMoFJ5s95-7aV')->paginate(null, 10); $address = new \Onfido\AddressPicker(); $address->postcode = 'SW4 6EH'; $addresses = $address->pick(); $this->assertGreaterThanOrEqual(1, count($addresses)); $this->assertInstanceOf('stdClass', $addresses[0]); $this->assertObjectHasAttribute('country', $addresses[0]); $this->assertEquals($addresses[0]->country, 'GBR'); $this->assertEquals($addresses[0]->town, 'LONDON'); }
public function testUpload() { \Onfido\Config::init()->set_token('test_NY2rpxJR3C0YwS9WWDzSMoFJ5s95-7aV')->paginate(null, 5); $applicants = (new \Onfido\Applicant())->get(); $this->assertEquals(5, count($applicants)); $document = new \Onfido\Document(); $document->file_name = 'c.jpg'; $document->file_path = 'c.jpg'; $document->file_type = 'image/jpg'; $document->type = 'passport'; $document->side = 'front'; $response = $document->upload_for($applicants[0]->id); $this->assertInstanceOf('stdClass', $response); $this->assertObjectHasAttribute('id', $response); $this->assertAttributeNotEmpty('id', $response); $this->assertEquals($document->file_name, $response->file_name); }
public function send($params) { if (\Onfido\Config::init()->debug) { var_dump(get_object_vars($params)); } $params = get_object_vars($params); $headers = array('Authorization: Token token=' . \Onfido\Config::init()->token); $url_params = ''; if ($this->method === 'POST') { // $headers[] = "Content-type: multipart/form-data"; curl_setopt($this->curlHandle, CURLOPT_POST, 1); $this->prepare_params($params); // var_dump($params); // var_dump(http_build_query($params)); curl_setopt($this->curlHandle, CURLOPT_POSTFIELDS, $params); } else { if ($this->method === 'GET') { $params['page'] = \Onfido\Config::init()->page; $params['per_page'] = \Onfido\Config::init()->per_page; $url_params = '?'; $_url_params = array(); foreach ($params as $key => $value) { $_url_params[] = $key . '=' . urlencode($value); } $url_params .= implode('&', $_url_params); } } curl_setopt($this->curlHandle, CURLOPT_HTTPHEADER, $headers); curl_setopt($this->curlHandle, CURLOPT_URL, $this->url . \Onfido\Config::init()->version . '/' . $this->endpoint . $url_params); curl_setopt($this->curlHandle, CURLOPT_RETURNTRANSFER, 1); $response = curl_exec($this->curlHandle); return $this->processResponse($response); curl_close($this->curlHandle); }
public function send($params) { $params = get_object_vars($params); $headers = ['Authorization: Token token=' . \Onfido\Config::init()->token]; $url_params = ''; if ($this->method === 'POST') { curl_setopt($this->curlHandle, CURLOPT_POST, 1); $this->prepare_params($params); curl_setopt($this->curlHandle, CURLOPT_POSTFIELDS, $params); } else { if ($this->method === 'GET') { $params['page'] = \Onfido\Config::init()->page; $params['per_page'] = \Onfido\Config::init()->per_page; $url_params = '?'; $_url_params = []; foreach ($params as $key => $value) { $_url_params[] = $key . '=' . urlencode($value); } $url_params .= implode('&', $_url_params); } } curl_setopt($this->curlHandle, CURLOPT_HTTPHEADER, $headers); curl_setopt($this->curlHandle, CURLOPT_URL, $this->url . \Onfido\Config::init()->version . '/' . $this->endpoint . $url_params); curl_setopt($this->curlHandle, CURLOPT_RETURNTRANSFER, 1); $response = curl_exec($this->curlHandle); return $this->processResponse($response); }