Пример #1
0
 /**
  * @param Domain $domain
  * @param null $authcode
  * @param bool|false $change_owner
  * @param int $duration
  * @return Operation
  * @throws APIException
  */
 public function transfert(Domain $domain, $authcode = null, $change_owner = false, $duration = 1)
 {
     //add default admin handle if not set
     if (null == $domain->getAdminContact() && array_key_exists('admin', $this->default_handles)) {
         $domain->setAdminContact(new Contact($this->default_handles['admin']));
     }
     //add default bill handle if not set
     if (null == $domain->getBillContact() && array_key_exists('bill', $this->default_handles)) {
         $domain->setBillContact(new Contact($this->default_handles['bill']));
     }
     //add default tech handle if not set
     if (null == $domain->getTechContact() && array_key_exists('tech', $this->default_handles)) {
         $domain->setTechContact(new Contact($this->default_handles['tech']));
     }
     //add default owner handle if not set
     if (null == $domain->getOwnerContact() && array_key_exists('owner', $this->default_handles)) {
         $domain->setOwnerContact(new Contact($this->default_handles['owner']));
     }
     $data = array('admin' => $domain->getAdminContact()->getHandle(), 'bill' => $domain->getBillContact()->getHandle(), 'owner' => $domain->getOwnerContact()->getHandle(), 'tech' => $domain->getTechContact()->getHandle(), 'duration' => $duration);
     if (null !== $authcode) {
         $data['authinfo'] = $authcode;
     }
     if (false !== $change_owner) {
         $data['change_owner'] = true;
     }
     if (count($domain->getNameservers()) > 0) {
         $data['nameservers'] = $domain->getNameservers();
     }
     $gandi = $this->gandi->getProxy('domain.transferin');
     $result = $gandi->proceed($this->api_key, $domain->getFqdn(), $data);
     if ($result['last_error']) {
         throw new APIException($result['last_error']);
     }
     return new Operation($result);
 }