コード例 #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;
 }