/**
  * Update the properties of a message
  *
  * @method updateMessage
  *
  * @param {string} msgId - Id of the message to update
  * @param {bool} isUnread - mark as unread or read
  * @param {bool} isFavorite - mark as favorite or not
  *
  * @return {Response} Returns Response object
  * @throws ServiceException if API request was not successful.
  */
 public function updateMessage($msgId, $isUnread, $isFavorite)
 {
     $token = $this->getSessionConsentToken('MIM');
     $immnSrvc = new IMMNService($this->base_url, $token);
     return $immnSrvc->updateMessage($msgId, $isUnread, $isFavorite, true);
 }
 public function handleUpdateMsgs()
 {
     $vnames = array('updateMessage', 'readflag', 'messageId');
     $this->copyToSession($vnames);
     if (!isset($_SESSION['updateMessage'])) {
         return;
     }
     try {
         $isUnread = $_SESSION['readflag'] == 'unread' ? true : false;
         $msgIds = $_SESSION['messageId'];
         $msgIds = explode(',', $msgIds);
         $immnSrvc = new IMMNService($this->apiFQDN, $this->getSessionToken());
         $this->clearSession(array('updateMessage'));
         if (count($msgIds) > 1) {
             $deltaChanges = array();
             foreach ($msgIds as $msgId) {
                 $deltaChanges[] = new IMMNDeltaChange($msgId, null, $isUnread);
             }
             $immnSrvc->updateMessages($deltaChanges);
         } else {
             /* one message id */
             $msgId = $msgIds[0];
             $immnSrvc->updateMessage($msgId, $isUnread);
         }
         $this->results[C_UPDATE_MSGS] = true;
     } catch (Exception $e) {
         $this->errors[C_UPDATE_MSGS] = $e->getMessage();
         $this->clearSession(array('updateMessage'));
     }
 }
 * 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;
$arr = null;
try {
    envinit();
    $immnSrvc = new IMMNService(getFqdn(), getSessionToken());
    $isUnread = $_POST['updateStatus'] == 'Read' ? false : true;
    $msgId = $_POST['updateMsgId'];
    $immnSrvc->updateMessage($msgId, $isUnread);
    $arr = array('success' => true, 'text' => 'Message(s) Updated');
} catch (Exception $e) {
    $arr = array('success' => false, 'text' => $e->getMessage());
}
echo json_encode($arr);
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
Example #4
0
    $immnDeltaChange = array(new IMMNDeltaChange($msgId, $favorite, $unread));
    // Send the request to update the messages.
    $immnSrvc->updateMessages($immnDeltaChange);
    echo "Successfully updated messages.\n";
} catch (ServiceException $se) {
    echo $se->getErrorResponse();
}
/* This try/catch block tests the updateMessage method. */
try {
    $msgId = 'ENTER VALUE';
    // Update the message's Favorite status to true.
    $favorite = true;
    // Update the message's Unread status to true.
    $unread = true;
    // Send the request to update the message.
    $immnSrvc->updateMessage($msgId, $unread, $favorite);
    echo "Successfully updated message.\n";
} catch (ServiceException $se) {
    echo $se->getErrorResponse();
}
/* This try/catch block tests the deleteMessages method. */
try {
    // Enter the ids of the messages to delete.
    $msgIds = array('ENTER VALUE!');
    // Send the request to delete the specified messages.
    $immnSrvc->deleteMessages($msgIds);
    echo "Successfully deleted messages.\n";
} catch (ServiceException $se) {
    echo $se->getErrorResponse();
}
/* This try/catch block tests the createMessageIndex method. */