Exemple #1
0
 /**
  * @return Token
  */
 private function fetchNewToken()
 {
     $request = $this->requestFactory->createRequest('login', $this->consumer->exportToArray())->setMethod(Request::POST);
     try {
         $response = Json::decode($this->getCurlSender()->send($request)->getResponse());
         return new Token($response->token, $this->consumer->getAppId(), new DateTime($response->expiration));
     } catch (CurlException $e) {
         Debugger::log('Cannot fetch new token: ' . $e->getMessage(), 'logistics');
         throw $e;
     }
 }
 /**
  * @param int $id
  * @return OrderTimesDTO|NULL
  */
 public function getOrderTimes($id)
 {
     $request = $this->requestFactory->createRequest('order-times/' . intval($id))->setMethod(Request::GET);
     try {
         $response = $this->connector->send($request);
     } catch (BadStatusException $e) {
         $this->unexpectedResponseCode($e->getResponse()->getCode());
     }
     if ($response->getCode() !== Response::S200_OK) {
         $this->unexpectedResponseCode($response->getCode());
     }
     $orderTimes = Json::decode($response->getResponse(), Json::FORCE_ARRAY);
     return $orderTimes === NULL ?: new OrderTimesDTO($orderTimes);
 }
 public function getArrivals()
 {
     $request = $this->requestFactory->createRequest('arrivals')->setMethod(Request::GET);
     try {
         $response = $this->connector->send($request);
     } catch (BadStatusException $e) {
         $this->unexpectedResponseCode($e->getResponse()->getCode());
         return FALSE;
     }
     if (($responseCode = $response->getCode()) !== Response::S200_OK) {
         $this->unexpectedResponseCode($responseCode);
         return FALSE;
     }
     return Json::decode($response->response, TRUE);
 }