Esempio n. 1
0
 public function testPostalCodeAndNumberMethods()
 {
     $someDummyKey = 'asdf';
     $client = new Client($someDummyKey);
     new Service($client);
     $this->assertEquals($client->getHttpRequest()->getHeader('Api-Key'), $someDummyKey);
 }
Esempio n. 2
0
 /**
  * @param $postalCode
  * @param null $number
  * @return array
  * @throws \RuntimeException
  */
 public function find($postalCode, $number = null)
 {
     $request = clone $this->apiClient->getHttpRequest();
     $params = array($postalCode);
     if (null !== $number) {
         $params[] = $number;
     }
     $request->setResource('/' . implode('/', $params));
     $response = new Message\Response();
     $this->client->send($request, $response);
     if ($response->getStatusCode() != 200) {
         throw new \RuntimeException(sprintf('Request failed with response code: %s', $response->getStatusCode()));
     }
     return $response->getData()->resource;
 }