Exemplo n.º 1
0
 def transfer(self, domain: Domain):
     if domain.epp_code is None:
         raise RegistrarConnectorException('EPP Code is missing')
     contact = domain.contact or domain.service.client
     owner_handle = self.find_or_create_customer(client=contact)
     nameserver_list = self._get_domain_nameservers_as_xml(domain)
     if not nameserver_list:
         raise RegistrarConnectorException(
             _('Nameservers for domain are required'))
     dom_req = E.createDomainRequest(
         self._xml_domain(domain), E.period(domain.registration_period),
         E.authCode(DomainUtils.decode_epp_code(domain.epp_code)),
         E.ownerHandle(owner_handle), E.adminHandle(owner_handle),
         E.techHandle(owner_handle), E.billingHandle(owner_handle),
         E.resellerHandle(''), E.nameServers(E.array(*nameserver_list)))
     response = self.api_request(data=dom_req)
     if response.data.status == 'ACT':
         domain.status = DomainStatus.active
         domain.registration_date = datetime.strptime(
             str(response.data.activationDate), '%Y-%m-%d %H:%M:%S').date()
         domain.expiry_date = datetime.strptime(
             str(response.data.expirationDate), '%Y-%m-%d %H:%M:%S').date()
         domain.epp_code = DomainUtils.encode_epp_code(
             str(response.data.authCode))
         domain.save(update_fields=[
             'status', 'registration_date', 'expiry_date', 'epp_code'
         ])
         return _('Domain transfered')
     elif response.data.status == 'REQ':
         domain.status = DomainStatus.pending
         domain.save(update_fields=['status'])
         return _('Domain pending registration')
     else:
         raise RegistrarConnectorException(_('Domain registration unknown'))
Exemplo n.º 2
0
 def transfer(self, domain: Domain) -> str:
     api_params = self._prepare_register_params(domain, years=1)
     api_params['auth-code'] = DomainUtils.decode_epp_code(domain.epp_code)
     api_response = self.api_request('POST', self.TRANSFER_DOMAIN_URL, api_params)
     message = self.get_actionstatusdesc(api_response)
     domain.status = DomainStatus.active
     domain.save(update_fields=['status'])
     return message
Exemplo n.º 3
0
 def transfer(self, domain: Domain) -> str:
     """Transfer domain to other registrar"""
     params = {
         'domain': domain.name,
         'authorization_key': DomainUtils.decode_epp_code(domain.epp_code)
     }
     try:
         self.api_request(request_method=RotldActions.TRANSFER_DOMAIN,
                          params=params)
     except RegistrarConnectorException as e:
         LOG.debug(e)
         return '{}'.format(e)
     return _('Success')