Пример #1
0
 /**
  * @param Domain $domain
  * @param String $action = create, renew, transfer, change_owner
  * @param String $grid = A, B, C, D, E
  * @return float price
  */
 public function getPriceForDomain(Domain $domain, $action = 'create', $currency = 'EUR', $grid = null)
 {
     $gandi = $this->gandi->getProxy('catalog');
     if (null === $grid) {
         $grid = $this->getCurrentGrid();
     }
     $options = array('product' => array('type' => 'domain'), 'action' => array('name' => $action));
     $result = $gandi->list($this->api_key, $options, $currency, $grid);
     foreach ($result as $price) {
         if ($domain->getTld() == $price['product']['description']) {
             return $price['unit_price'][0]['price'];
         }
     }
     return null;
 }
Пример #2
0
 /**
  * Commit a Domain changes
  *
  * @param Domain $domain
  * @return int number of changes
  */
 public function update(Domain $domain)
 {
     $changes = $domain->getChangesTrack();
     $nbUpdates = 0;
     //update autorenew settings
     if (true === $changes['auto_renew']) {
         if (true === $domain->getAutorenew()) {
             $this->api->enableAutorenew($domain);
         } else {
             $this->api->disableAutorenew($domain);
         }
         $nbUpdates++;
     }
     //update nameservers
     if (true === $changes['nameservers']) {
         $this->api->setNameservers($domain);
     }
     //update lock status
     if (true === $changes['lock']) {
         if (false === $domain->getLock()) {
             $this->api->unlock($domain);
         } else {
             $this->api->lock($domain);
         }
     }
     //update dnssec key
     if (true === $changes['dnssec']) {
         //@TODO: complete
         //essayer ici de trouver les différences...
     }
     return $nbUpdates;
 }
Пример #3
0
 /**
  * @param Domain $domain
  * @param $key
  * @return Operation
  * @throws APIException
  */
 public function addDnssecKey(Domain $domain, $key)
 {
     $gandi = $this->gandi->getProxy('domain.dnssec');
     $result = $gandi->create($this->api_key, $domain->getFqdn(), $key);
     if ($result['last_error']) {
         throw new APIException($result['last_error']);
     }
     return new Operation($result);
 }