Ejemplo n.º 1
0
 /**
  * @param Certificate $certificate
  * @return Operation
  * @throws APIException
  */
 public function create(Certificate $certificate)
 {
     $result = $this->gandi->create($this->api_key, array('csr' => $certificate->getCsr(), 'duration' => $certificate->getDuration(), 'handle' => $certificate->getOwner()->getHandle(), 'dcv_method' => $certificate->getValidationMethod(), 'package' => $certificate->getType()));
     if ($result['last_error']) {
         throw new APIException($result['last_error']);
     }
     return new Operation($result);
 }
Ejemplo n.º 2
0
 /**
  * @param Contact $contact
  * @return bool
  * @throws APIException
  * @throws \Exception
  */
 public function persist(Contact $contact)
 {
     $data = $contact->toGandiArray();
     if ($contact->isNew()) {
         $response = $this->gandi->create($this->api_key, $data);
         if (is_array($response)) {
             return $response['handle'];
         } else {
             throw new APIException("Cannot create contact.");
         }
     } else {
         $handle = $contact->getHandle();
         $response = $this->gandi->update($this->api_key, $handle, $data);
         if (is_array($response)) {
             return true;
         } else {
             throw new \Exception("Cannot update contact.");
         }
     }
 }