You are here

function amazon_ses_identity_list_update in Amazon SES 7

Same name and namespace in other branches
  1. 7.2 includes/amazon_ses.admin.inc \amazon_ses_identity_list_update()

Send request to amazon ses api to delete sender's identities.

1 string reference to 'amazon_ses_identity_list_update'
amazon_ses_identity_list_form in includes/amazon_ses.admin.inc
Display Verified Sender Identites to Admin.

File

includes/amazon_ses.admin.inc, line 345
Administration menu callbacks for amazon_mail_service.

Code

function amazon_ses_identity_list_update($form, &$form_state) {
  $selected_identities = array_filter($form_state['values']['list_table']);
  module_load_include('inc', 'amazon_ses', 'includes/amazon_ses.mail');

  // @todo Amazon SES api throtteled request per second. Here we are sending
  // request in loop which may cause problem. so will add sleep for 1 sec.
  foreach ($selected_identities as $value) {
    $action_parameter['identity'] = $form_state['complete form']['amazon_list_identities_update']['list_table']['#options'][$value]['key'];

    // This request is throttled per second.
    $result = amazon_ses_send_request('DeleteIdentity', $action_parameter);

    // Display the response of calling of Amazon SES API.
    if (isset($result['status'])) {
      switch ($result['status']) {
        case AMAZON_SES_REQUEST_SUCCESS:

          // For reloading identities.
          $message = t('Identity @identity is deleted successfully from Amazon SES.', array(
            '@identity' => $action_parameter['identity'],
          ));
          drupal_set_message($message, 'status');
          break;
        case AMAZON_SES_REQUEST_FALIURE:
          $message = t('Request to <strong>DeleteIdentity</strong> action of Amazon
            SES API call has failed, please check your network connection or try
            after some time.');
          drupal_set_message($message, 'error');
          break;
      }
    }
  }
}