/** * @return ServiceFactory */ protected function makeServiceFactory() { //this is what you usually want, for production: return new ServiceFactory($this->makeContext(), Host::standard(), '4.0'); //current release candidate for the next production version: //return new ServiceFactory($this->makeContext(), Host::http("rc-api.nameapi.org"), '4.1'); }
public function test_parseTwoPeople() { //setup code: $context = Context::builder()->priority(Priority::REALTIME())->build(); $myApiKey = 'test'; //grab one from nameapi.org $serviceFactory = new ServiceFactory($myApiKey, $context, Host::http('rc50-api.nameapi.org'), '5.0'); $personNameParser = $serviceFactory->parserServices()->personNameParser(); //the call: $inputPerson = NaturalInputPerson::builder()->name(InputPersonName::westernBuilder()->fullname("Peter und Daniela Meyer")->build())->build(); $parseResult = $personNameParser->parse($inputPerson); //the assertions: $bestMatch = $parseResult->getBestMatch(); $this->assertEquals('MULTIPLE', (string) $bestMatch->getParsedPerson()->getPersonType()); $people = $bestMatch->getParsedPerson()->getPeople(); $this->assertEquals(2, sizeof($people)); $firstPerson = $people[0]; $this->assertEquals('Peter', $firstPerson->getAddressingGivenName()); $this->assertEquals('Meyer', $firstPerson->getAddressingSurname()); $this->assertEquals('MALE', (string) $firstPerson->getGender()->getGender()); $secondPerson = $people[1]; $this->assertEquals('Daniela', $secondPerson->getAddressingGivenName()); $this->assertEquals('Meyer', $secondPerson->getAddressingSurname()); $this->assertEquals('FEMALE', (string) $secondPerson->getGender()->getGender()); }
public function testDea() { //setup code: $context = Context::builder()->priority(Priority::REALTIME())->build(); $myApiKey = 'test'; //grab one from nameapi.org $serviceFactory = new ServiceFactory($myApiKey, $context, Host::http('rc50-api.nameapi.org'), '5.0'); //the call: $deaDetector = $serviceFactory->emailServices()->disposableEmailAddressDetector(); $result = $deaDetector->isDisposable("*****@*****.**"); //the assertions: $this->assertEquals('YES', (string) $result->getDisposable()); }
public function testPing() { //setup code: $context = Context::builder()->priority(Priority::REALTIME())->build(); $myApiKey = 'test'; //grab one from nameapi.org $serviceFactory = new ServiceFactory($myApiKey, $context, Host::http('rc50-api.nameapi.org'), '5.0'); //the call: $pingService = $serviceFactory->systemServices()->ping(); $result = $pingService->ping(); //the assertions: $this->assertEquals('pong', $result); }
/** * @var $context * @var $host defaults to Host::standard() * @var $apiVersion default is the "latest stable", currently that is 4.0. * You want to change this to target another version, for example a release candidate or a development version. */ public function __construct(Context $context, Host $host = null, $apiVersion = null) { $this->context = $context; if ($host == null) { $this->host = Host::standard(); } else { $this->host = $host; } if ($host == null) { $this->apiVersion = '4.0'; } else { $this->apiVersion = $apiVersion; } $this->baseUrl = $this->host->toString() . '/soap/v' . $this->apiVersion . '/'; }
/** * @var $apiKey * @var $context * @var $host defaults to Host::standard() * @var $apiVersion default is the "latest stable", currently that is 5.0. * You want to change this to target another version, for example a release candidate or a development version. */ public function __construct($apiKey, Context $context, Host $host = null, $apiVersion = null) { $this->apiKey = $apiKey; $this->context = $context; if ($host == null) { $this->host = Host::standard(); } else { $this->host = $host; } if ($apiVersion == null) { $this->apiVersion = '5.0'; } else { $this->apiVersion = $apiVersion; } $this->baseUrl = $this->host->toString() . '/' . $this->technology . '/v' . $this->apiVersion . '/'; }