示例#1
0
 /**
  * Returns prepared array of recipients
  *
  * @param Envelope $envelope
  * @return array
  */
 private function prepareRecipients(Envelope $envelope)
 {
     $templateRoles = array();
     $recipients = $envelope->getRecipients();
     if (is_array($recipients) && count($recipients)) {
         foreach ($recipients as $recipient) {
             if ($recipient instanceof RecipientInterface) {
                 $templateRole = array('name' => $recipient->getName(), 'email' => $recipient->getEmail(), 'roleName' => $recipient->getRoleName());
                 $tabs = $recipient->getTabs();
                 if ($tabs->count()) {
                     $templateRole['tabs'] = $tabs->toArray();
                 }
                 if ($recipient->getClientUserId()) {
                     $templateRole['clientUserId'] = $recipient->getClientUserId();
                 }
                 $templateRoles[] = $templateRole;
             }
         }
     }
     return $templateRoles;
 }
示例#2
0
 /**
  * Set status
  *
  * @param string $status
  * @return $this
  * @throws \Wealthbot\SignatureBundle\Exception\InvalidEnvelopeStatusException
  */
 public function setStatus($status)
 {
     if (!in_array($status, Envelope::getStatusChoices())) {
         throw new InvalidEnvelopeStatusException(sprintf('Invalid envelope status: %s', $status));
     }
     $this->status = $status;
     return $this;
 }
 /**
  * Send envelope
  *
  * @param SignableInterface $object
  * @return mixed
  * @throws \RuntimeException
  */
 private function sendEnvelope(SignableInterface $object)
 {
     $recipients = $this->getRecipients($object);
     $envelope = new Envelope();
     $envelope->setEmailSubject('TestS');
     $envelope->setEmailBlurb('TestB');
     $envelope->setRecipients($recipients);
     $envelope->setStatus(Envelope::STATUS_SENT);
     try {
         $templateId = $this->getTemplateForSignableObject($object);
         $options = array('enableWetSign' => false);
         $response = $this->docusignApi->sendEnvelopeFromTemplate($envelope, $templateId, $options);
     } catch (\Exception $e) {
         throw new \RuntimeException($e->getMessage(), $e->getCode(), $e);
     }
     return $response;
 }