Esempio n. 1
0
 public function testApiRequired()
 {
     $this->assertFalse(GandiAPIMethodRequirements::isApiKeyRequired('system.listMethods'));
     $this->assertTrue(GandiAPIMethodRequirements::isApiKeyRequired('contact.balance'));
 }
Esempio n. 2
0
 /**
  * Calls XML_RPC Class
  *
  * @param string $method final endpoint of call
  * @param mixed  $args   variable length array
  *
  * @return mixed
  */
 function __call($method, $args)
 {
     $this->method = $method;
     $this->calledMethod = $this->getCompleteMethod();
     $callArray = array();
     if (GandiAPIMethodRequirements::isApiKeyRequired($this->calledMethod)) {
         $callArray[] = $this->getApiKey();
     }
     foreach ($args as $a) {
         $callArray[] = $a;
     }
     try {
         $guzzle = new \GuzzleHttp\Client(array('verify' => false));
         $transport = new Guzzle4Bridge($guzzle);
         $client = new Client($this->getUrl(), $transport);
         $apiResult = $client->call($this->getCompleteMethod(), $callArray);
     } catch (\Exception $e) {
         // @codeCoverageIgnoreStart
         $apiResult = array();
         // @codeCoverageIgnoreEnd
     }
     return $apiResult;
 }