Example #1
0
     if (is_bool($emailStatus) === true) {
         $reply->data = Notification::getNotificationByEmailStatus($pdo, $emailStatus);
     } else {
         if (empty($notificationDateTime) === false) {
             $notificationDateTimeInt = new DateTime();
             $notificationDateTimeInt->setTimestamp($notificationDateTime / 1000);
             $reply->data = Notification::getNotificationByNotificationDateTime($pdo, $notificationDateTimeInt);
         } else {
             if (empty($alertId) === false) {
                 $reply->data = Notification::getProductByAlertId($pdo, $alertId);
             } else {
                 if ($page >= 0) {
                     $notifications = Notification::getAllNotifications($pdo, $page)->toArray();
                     foreach ($notifications as $index => $notification) {
                         $product = null;
                         $productAlert = ProductAlert::getProductAlertByAlertId($pdo, $notification->getAlertId());
                         if ($productAlert !== null) {
                             $product = Product::getProductByProductId($pdo, $productAlert->getProductId());
                         }
                         $notifications[$index] = json_decode(json_encode($notification));
                         $notifications[$index]->product = $product;
                     }
                     $reply->data = $notifications;
                 } else {
                     throw new InvalidArgumentException("no parameters given", 405);
                 }
             }
         }
     }
 }
 // post to a new Notification
 /**
  * test grabbing a ProductAlert by alertId that does not exist
  *
  * PDOException
  **/
 public function testGetInvalidProductLocationByAlertId()
 {
     // grab an alertId that does not exist
     $pdoProductAlert = ProductAlert::getProductAlertByAlertId($this->getPDO(), InventoryTextTest::INVALID_KEY);
     $this->assertNull($pdoProductAlert);
 }