/**
  * {@inheritDoc}
  */
 public function stringToNotifications($jsonString)
 {
     $json = json_decode($jsonString);
     $notifications = new Notifications();
     if (isset($json->url)) {
         $notifications->setUrl($json->url);
     }
     if (isset($json->events->video_created)) {
         $notifications->addNotificationEvent(new NotificationEvent('video_created', $json->events->video_created));
     }
     if (isset($json->events->video_encoded)) {
         $notifications->addNotificationEvent(new NotificationEvent('video_encoded', $json->events->video_encoded));
     }
     if (isset($json->events->encoding_progress)) {
         $notifications->addNotificationEvent(new NotificationEvent('encoding_progress', $json->events->encoding_progress));
     }
     if (isset($json->events->encoding_completed)) {
         $notifications->addNotificationEvent(new NotificationEvent('encoding_completed', $json->events->encoding_completed));
     }
     return $notifications;
 }
Esempio n. 2
0
 public function testSetNotifications()
 {
     $data = array('url' => 'http://example.com/panda_notification', 'events[video_created]' => 'false', 'events[video_encoded]' => 'true', 'events[encoding_progress]' => 'false', 'events[encoding_completed]' => 'false');
     $parameterBag = new ParameterBag();
     $parameterBag->set('url', 'http://example.com/panda_notification');
     $parameterBag->set('events[video_created]', 'false');
     $parameterBag->set('events[video_encoded]', 'true');
     $parameterBag->set('events[encoding_progress]', 'false');
     $parameterBag->set('events[encoding_completed]', 'false');
     $notifications = new Notifications();
     $notifications->setUrl('http://example.com/panda_notification');
     $this->validateRequest('put', '/notifications.json', $data);
     $this->validateTransformer('Notifications', 'toRequestParams', $parameterBag);
     $this->validateTransformer('Notifications', 'stringToNotifications');
     $this->cloud->setNotifications($notifications);
 }