public function effect($requestOptions) { $callOptions = array("method" => "POST", "data" => $requestOptions['data'], "path" => 'lights/' . $requestOptions['selector'] . '/effects/' . $requestOptions['effect']); $request = new ApiCall($callOptions); $data = $request->doCall(); return $data; }
public function testIsCallStillValid() { $pastTime = new \DateTime('yesterday', new \DateTimeZone('UTC')); $this->apiCall->shouldReceive('getCachedUntil')->andReturn($pastTime); $this->apiCall->shouldReceive('getEarliestNextCall')->andReturn($pastTime); $this->assertTrue($this->apiTimeCalculator->isCallStillValid($this->apiCall)); }
public function setUp() { $this->noKeySectionApi = m::mock('Tarioch\\EveapiFetcherBundle\\Component\\Section\\NoKeySectionApi'); $this->keySectionApi = m::mock('Tarioch\\EveapiFetcherBundle\\Component\\Section\\KeySectionApi'); $this->apiCall = m::mock('Tarioch\\EveapiFetcherBundle\\Entity\\ApiCall'); $this->api = m::mock('Tarioch\\EveapiFetcherBundle\\Entity\\Api'); $this->factory = new SectionApiFactory($this->keySectionApi, $this->noKeySectionApi); $this->apiCall->shouldReceive('getApi')->andReturn($this->api); }
/** * Gets the language file for the given language and stores it. * * @param string $application The name of the application. * @param string $language The identifier of the language. * * @throws CurlException If there was an error during the download of the language file. * * @return bool The success of the operation. */ public function getFile($application, $language) { try { $result = ApiCall::call('system_api', 'language_api', array('system' => 'LanguageFiles', 'action' => 'getLanguageFile'), array('language' => $language)); $this->_apiErrorHandler->checkForApiErrorResult($result); } catch (\Exception $e) { echo '\\nError getting language file: (' . $application . '/' . $language . ') ' . $e->getMessage(); } return $result['data']; }
/** * Gets the available languages for the given applet. * * @param string $applet The applet identifier. * * @return array The list of the available applet languages. */ public function getAppletLanguages($applet) { $result = ApiCall::call('system_api', 'language_api', array('system' => 'LanguageFiles', 'action' => 'getAppletLanguages'), array('applet' => $applet)); try { $this->_apiErrorHandler->checkForApiErrorResult($result); } catch (\Exception $e) { echo "\nGetting languages for applet ({$applet}) was unsuccessful. {$e->getMessage()}"; } return $result['data']; }
private function mockPrepareApiCall() { $keyId = 'keyId'; $vcode = 'vcode'; $this->apiCall->shouldReceive('getKey')->andReturn($this->key); $this->key->shouldReceive('isActive')->andReturn(true); $this->key->shouldReceive('getKeyId')->andReturn($keyId); $this->key->shouldReceive('getVcode')->andReturn($vcode); $this->phealFactory->shouldReceive('createEveOnline')->with($keyId, $vcode)->andReturn($this->pheal); $this->apiCall->shouldReceive('getApi')->andReturn($this->api); $this->specificApiFactory->shouldReceive('create')->with($this->api)->andReturn($this->specificApi); }
private function mockFinishApiCall() { $this->apiTimeCalculator->shouldReceive('calculateEarliestNextCall')->with($this->apiCall)->andReturn(self::EARLIEST_NEXT_CALL); $this->apiCall->shouldReceive('setEarliestNextCall')->with(self::EARLIEST_NEXT_CALL); $this->logger->shouldReceive('info'); }
/** * Gets a language xml for an applet. * * @param string $applet The identifier of the applet. * @param string $language The language identifier. * * @return string|false The content of the language file or false if weren't able to get it. */ protected static function getAppletLanguageFile($applet, $language) { $result = ApiCall::call('system_api', 'language_api', array('system' => 'LanguageFiles', 'action' => 'getAppletLanguageFile'), array('applet' => $applet, 'language' => $language)); try { self::checkForApiErrorResult($result); } catch (\Exception $e) { throw new \Exception('Getting language xml for applet: (' . $applet . ') on language: (' . $language . ') was unsuccessful: ' . $e->getMessage()); } return $result['data']; }
<?php //Includes the class ApiCall include 'classes/ApiCall.php'; //Make a new instanc of the ApiCall class $api = new ApiCall("YOUR API KEY HERE"); //Making the call with london as city metric as units and a 5 day forecast $api->makeCall("london", "metric", "forecast");