Ejemplo n.º 1
0
 public function parseMessage($json, Message $message)
 {
     if (empty($json)) {
         return $message;
     }
     $messageBody = json_decode($json, true);
     if (json_last_error() > 0) {
         return $message;
     }
     $message->setId($this->checkArray($messageBody, 'id'));
     $message->setDeviceId($this->checkArray($messageBody, 'deviceId'));
     $message->setFingerprint($this->checkArray($messageBody, 'fingerprint'));
     $message->setContactId($this->checkArray($messageBody, 'contactId'));
     $message->setFinalDestination($this->checkArray($messageBody, 'finalDestination'));
     $message->setFinalSource($this->checkArray($messageBody, 'finalSource'));
     $message->setAddress($this->checkArray($messageBody, 'address'));
     $message->setBcc($this->checkArray($messageBody, 'bcc'));
     $message->setCc($this->checkArray($messageBody, 'cc'));
     $message->setMessageType($this->checkArray($messageBody, 'messageType'));
     $message->setBody($this->checkArray($messageBody, 'body'));
     $message->setBodySize($this->checkArray($messageBody, 'bodySize'));
     $message->setStatusCode($this->checkArray($messageBody, 'statusCode'));
     $message->setHasAttachment($this->checkArray($messageBody, 'hasAttachment'));
     $message->setDeleted($this->checkArray($messageBody, 'deleted'));
     $message->setRead($this->checkArray($messageBody, 'read'));
     $message->setVisible($this->checkArray($messageBody, 'visible'));
     $message->setDateCreatedFromString($this->checkArray($messageBody, 'dateCreated'));
     $message->setDateDeletedFromString($this->checkArray($messageBody, 'dateDeleted'));
     $message->setDateReadFromString($this->checkArray($messageBody, 'dateRead'));
     $message->setScheduledDateFromString($this->checkArray($messageBody, 'scheduledDate'));
     return $message;
 }
Ejemplo n.º 2
0
 public function testISO8601DateFormatting()
 {
     $message = new Message();
     $message->setScheduledDateFromString('2016-05-24T20:42:06-07:00');
     $this->assertEquals('2016-05-24T20:42:06-0700', $message->getScheduledDateAsString());
 }