Ejemplo n.º 1
0
 /**
  * Returns up to 25 approved senders
  *
  * @param  integer $startIndex Optional start index
  * @param  array $extras Optional list of extras to fetch {status,details}
  * @return array|false
  */
 public function get($startIndex = 0, $extras = [])
 {
     $params = array();
     if ($startIndex) {
         $params = array('startindex' => $startIndex);
     }
     $response = $this->getApiClient()->get('/senders', $params);
     if ($response && $response->isOk()) {
         $response->data;
         $senders = array();
         foreach ($response->data->senders as $senderData) {
             $sender = new Sender();
             $sender->setEmailAddress($senderData->emailaddress);
             if (in_array('status', $extras)) {
                 $status = new Status($this->getApiClient());
                 $status->get($sender);
             }
             if (in_array('details', $extras)) {
                 $details = new Details($this->getApiClient());
                 $details->get($sender);
             }
             $senders[] = $sender;
         }
         return $senders;
     }
     return false;
 }
Ejemplo n.º 2
0
 /**
  * Create DKIM selector, optionally using the provided selector
  *
  * @param Sender $sender
  * @param string $dkimIdentifier Optional selector to assign to domain's DKIM
  * @return boolean
  */
 public function create(Sender $sender, $dkimIdentifier = false)
 {
     if (false === $dkimIdentifier) {
         $dkimIdentifier = uniqid();
     }
     $params = array('emailaddress' => $sender->getEmailAddress(), 'dkim' => $dkimIdentifier);
     // Assignment of a new selector should be rare and we're extremely likely
     // to want the public keys after, so we'll go ahead and refresh details which
     // which contain the DKIM records
     $response = $this->getApiClient()->post('/senders/dkim', $params);
     if ($response && $response->isOK()) {
         $details = new Details($this->getApiClient());
         $details->get($sender);
         return true;
     }
     return false;
 }