コード例 #1
0
 public function calculateEarliestNextCall(ApiCall $call)
 {
     $minutesToEarliestNextCall = $call->getApi()->getCallInterval() * (1 + $call->getErrorCount());
     $earliestNextCall = new \DateTime('now', new \DateTimeZone('UTC'));
     $earliestNextCall->add(new \DateInterval('PT' . $minutesToEarliestNextCall . 'M'));
     return $earliestNextCall;
 }
コード例 #2
0
 /**
  *
  * @param ApiCall $call
  * @return SectionApi
  */
 public function create(ApiCall $call)
 {
     $section = $call->getApi()->getSection();
     if (in_array($section, self::$keySections)) {
         return $this->keySectionApi;
     } else {
         return $this->noKeySectionApi;
     }
 }
コード例 #3
0
 /**
  * @inheritdoc
  */
 public function update(ApiCall $call)
 {
     $key = $call->getKey();
     if ($key->isActive()) {
         $pheal = $this->phealFactory->createEveOnline($key->getKeyId(), $key->getVcode());
         try {
             $updateService = $this->specificApiFactory->create($call->getApi());
             $cachedUntil = $updateService->update($call, $key, $pheal);
             $key->clearErrorCount();
             return new \DateTime($cachedUntil);
         } catch (PhealException $e) {
             $key->increaseErrorCount();
             if ($key->getErrorCount() > self::ERROR_MAX) {
                 $key->setActive(false);
             }
             throw $e;
         }
     } else {
         $call->setActive(false);
         return $call->getCachedUntil();
     }
 }
コード例 #4
0
 /**
  * @inheritdoc
  */
 public function update(ApiCall $call)
 {
     $pheal = $this->phealFactory->createEveOnline();
     $specificApi = $this->specificApiFactory->create($call->getApi());
     return new \DateTime($specificApi->update($call, $pheal));
 }