You are here

public function AmazonSesHandler::getIdentities in Amazon SES 2.0.x

Get verified identities.

Return value

array An array of verified indentities.

Overrides AmazonSesHandlerInterface::getIdentities

File

src/AmazonSesHandler.php, line 221

Class

AmazonSesHandler
Amazon SES service.

Namespace

Drupal\amazon_ses

Code

public function getIdentities() {
  $identities = [];
  $results = $this->client
    ->listIdentities();
  foreach ($results
    ->toArray()['Identities'] as $identity) {
    $result = $this->client
      ->getIdentityVerificationAttributes([
      'Identities' => [
        $identity,
      ],
    ]);
    $attributes = $result
      ->toArray()['VerificationAttributes'];
    $domain = array_key_exists('VerificationToken', $attributes[$identity]);
    $item = [
      'identity' => $identity,
      'status' => $attributes[$identity]['VerificationStatus'],
      'type' => $domain ? 'Domain' : 'Email Address',
    ];
    if ($domain) {
      $item['token'] = $attributes[$identity]['VerificationToken'];
    }
    $identities[] = $item;
  }
  return $identities;
}