/**
  * Delete the Message from Server
  *
  * @method deleteMessage
  *
  * @param {string} msgId - Id of the message to delete
  *
  * @return {Response} Returns Response object
  * @throws ServiceException if API request was not successful.
  */
 public function deleteMessage($msgId)
 {
     // Get OAuth token
     $token = $this->getSessionConsentToken('MIM');
     $immnSrvc = new IMMNService($this->base_url, $token);
     return $immnSrvc->deleteMessage($msgId, true);
 }
/*
 * Copyright 2015 AT&T
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
session_start();
require_once __DIR__ . '/common.php';
require_once __DIR__ . '/../lib/IMMN/IMMNService.php';
use Att\Api\IMMN\IMMNService;
try {
    $msgId = $_POST['deleteMsgId'];
    envinit();
    $immnSrvc = new IMMNService(getFqdn(), getSessionToken());
    $immnSrvc->createMessageIndex();
    $immnSrvc->deleteMessage($msgId);
    $arr = array('success' => true, 'text' => 'Message(s) Deleted');
} catch (Exception $e) {
    $arr = array('success' => false, 'text' => $e->getMessage());
}
echo json_encode($arr);
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
 public function handleDeleteMsgs()
 {
     $vnames = array('deleteMessage', 'messageId');
     $this->copyToSession($vnames);
     if (!isset($_SESSION['deleteMessage'])) {
         return;
     }
     try {
         $msgIds = $_SESSION['messageId'];
         $msgIds = explode(',', $msgIds);
         $immnSrvc = new IMMNService($this->apiFQDN, $this->getSessionToken());
         $this->clearSession(array('deleteMessage'));
         if (count($msgIds) > 1) {
             $immnSrvc->deleteMessages($msgIds);
         } else {
             /* one message id */
             $msgId = $msgIds[0];
             $immnSrvc->deleteMessage($msgId);
         }
         $this->results[C_DELETE_MSGS] = true;
     } catch (Exception $e) {
         $this->errors[C_DELETE_MSGS] = $e->getMessage();
         $this->clearSession(array('deleteMessage'));
     }
 }