Parse a response from messageId check and returns a Message.

@param $rawMessage

@return \SimpleSoftwareIO\SMS\IncomingMessage
438549
protected function processReceive($rawMessage)
    {
        $rawMessage = $rawMessage->getSmsStatusResp;
        $incomingMessage = $this->createIncomingMessage();
        $incomingMessage->setRaw($rawMessage);
        $incomingMessage->setFrom($rawMessage->shortcode);
        $incomingMessage->setMessage(null);
        $incomingMessage->setId($rawMessage->id);
        $incomingMessage->setTo(null);

        return $incomingMessage;
    }
1265991
def from_raw_message(cls, rawmessage):
        """"""
        return StandardReceive(rawmessage[2:5],
                               rawmessage[5:8],
                               {'cmd1': rawmessage[9],
                                'cmd2': rawmessage[10]},
                               flags=rawmessage[8])
456795
protected static function parseSearch(array $rawSearch) {

        $dtSearch = new DataTablesSearch();

        if (false === static::isValidRawSearch($rawSearch)) {
            return $dtSearch;
        }

        $dtSearch->setRegex(BooleanHelper::parseString($rawSearch[DataTablesSearchInterface::DATATABLES_PARAMETER_REGEX]));
        $dtSearch->setValue($rawSearch[DataTablesSearchInterface::DATATABLES_PARAMETER_VALUE]);

        return $dtSearch;
    }
1371230
public static function parseSnsMessage(Message $snsMsg)
    {
        // Create the message and extract the information we need
        $ipnMsg = new Message($snsMsg->getMandatoryField("Message"));
        self::_addMetadataToIpnMessage(
            $ipnMsg, 
            $snsMsg->getNotificationMetadata()
        );
        return $ipnMsg;
    }
1051467
protected function returnSuccess($rawData = array(), $withMessage=true)
    {
        $data = array();
        if ($withMessage) {
            $data['success'] = true;
            $data['data'] = $rawData;
            $data['version'] = TAO_VERSION;
        } else {
            $data = $rawData;
        }

        $this->returnJson($data);
//        exit(0);
    }
1280309
protected function handleDefaults(ParsedMessage $parsedMessage)
    {
        if (!$parsedMessage->getFrom() && $this->defaults['from']['email']) {
            $parsedMessage->setFrom($this->defaults['from']['email'], $this->defaults['from']['name']);
        }

        if (!$parsedMessage->getTo() && $this->defaults['to']['email']) {
            $parsedMessage->addTo($this->defaults['to']['email'], $this->defaults['to']['name']);
        }

        if (!$parsedMessage->getCc() && $this->defaults['cc']['email']) {
            $parsedMessage->addCC($this->defaults['cc']['email'], $this->defaults['cc']['name']);
        }

        if (!$parsedMessage->getBcc() && $this->defaults['bcc']['email']) {
            $parsedMessage->addBcc($this->defaults['bcc']['email'], $this->defaults['bcc']['name']);
        }

        if (!$parsedMessage->getReplyTo() && $this->defaults['replyTo']) {
            $parsedMessage->setReplyTo($this->defaults['replyTo']);
        }

        if (!$parsedMessage->getSubject() && $this->defaults['subject']) {
            $parsedMessage->setSubject($this->defaults['subject']);
        }
    }
439128
public static function parse_raw($text)
    {
        $line = new static($text);

        if (! $line->isPair()) {
            return $line;
        }

        return new KeyValue($line->key(), $line->value(), $line->quote());
    }
630318
public function parse($raw)
    {
        $lines = explode("\n", $raw);

        // Status Line
        preg_match('/HTTP\/(\d\.\d) (\d\d\d) (.*)/', $lines[0], $statusLine);
        $response = (new Response())
            ->withProtocolVersion($statusLine[1])
            ->withStatus($statusLine[2], $statusLine[3]);
        unset($lines[0]);

        // Headers
        foreach ($lines as $i => $line) {
            if ('' == trim($line)) {
                unset($lines[$i]);
                break;
            }
            $header   = explode(': ', $line);
            $response = $response->withHeader($header[0], $header[1]);
            unset($lines[$i]);
        }

        // Body
        $stream = new Stream(fopen('php://memory', 'rw+'));
        $stream->write(implode("\n", $lines));
        $stream->rewind();
        $response = $response->withBody($stream);

        return $response;
    }
280249
private function handleMessage($messageData): \Generator
    {
        $messageType = implode('|', [
            ErrorResponse::class,
            ResultResponse::class,
            Notification::class,
            Request::class,
        ]);

        try {
            /** @var Message $message */
            $message = $this->mapper->load($messageData, $messageType);

            if ($message->jsonrpc !== Message::VERSION) {
                $this->logger->warning('[jsonrpc] Bad JSONRPC version received');
            }
        } catch (MapperException $e) {
            $this->logger->warning('[jsonrpc] Malformed message received');

            return new ErrorResponse(null, new InvalidRequestException());
        }

        if ($message instanceof Response) {
            return yield $this->handleResponse($message);
        }
        if ($message instanceof Request) {
            return yield $this->handleRequest($message);
        }
        if ($message instanceof Notification) {
            return yield $this->handleNotification($message);
        }

        throw new \LogicException(); // @codeCoverageIgnore
    }
588529
protected function transformMessage(ParsedMessage $parsedMessage)
    {
        $message = new \Swift_Message();

        if ($from = $parsedMessage->getFrom()) {
            $message->setFrom($from);
        }

        // handle to with defaults
        if ($to = $parsedMessage->getTo()) {
            $message->setTo($to);
        }

        // handle cc with defaults
        if ($cc = $parsedMessage->getCc()) {
            $message->setCc($cc);
        }

        // handle bcc with defaults
        if ($bcc = $parsedMessage->getBcc()) {
            $message->setBcc($bcc);
        }

        // handle reply to with defaults
        if ($replyTo = $parsedMessage->getReplyTo()) {
            $message->setReplyTo($replyTo);
        }

        // handle subject with default
        if ($subject = $parsedMessage->getSubject()) {
            $message->setSubject($subject);
        }

        // handle body, no default values here
        $message->setBody($parsedMessage->getMessageText());
        if ($parsedMessage->getMessageHtml()) {
            $message->addPart($parsedMessage->getMessageHtml(), 'text/html');
        }

        return $message;
    }
846653
public function setMaxMessage($maxMessage)
    {
        if (!is_string($maxMessage)) {
            throw new \InvalidArgumentException('The attribute maxMessage on the class Attribute has to be string (' . gettype($maxMessage) . ('object' === gettype($maxMessage) ? ' ' . get_class($maxMessage) : '') . ' given).');
        }

        $this->maxMessage = $maxMessage;

        return $this;
    }
488921
public function getMessage($messageId)
    {
        $rawMessage = $this->plivo->get_message(['record_id' => $messageId]);
        $incomingMessage = $this->createIncomingMessage();
        $this->processReceive($incomingMessage, $rawMessage);

        return $incomingMessage;
    }
517548
protected function getMessage($rawResponse)
    {
        if ($message = Arr::get($rawResponse, 'message')) {
            return $message;
        }

        if (!empty(Arr::get($rawResponse, 'payments'))) {
            if ($message = $this->getPaymentStatus($rawResponse)) {
                return $message;
            }
        }
    }
1341863
public function getRawMessage($cb, $uid, $byUid = true)
    {
        $this->onResponse->push($cb);
        $this->fetch(['FLAGS', 'BODY[]'], $uid, null, $byUid, self::TAG_GETRAWMESSAGE);
    }
73722
public function getMessages()
    {
        if (empty($this->messages)) {
            $message = new IncomingMessage(Image::PATTERN, $this->event->get('from')['id'], $this->event->get('conversation')['id'],
                $this->payload);
            $message->setImages($this->getImagesUrls());
            $this->messages = [$message];
        }

        return $this->messages;
    }
393715
protected function getValue($rawValue, $defaultValue = null)
    {
        if ($rawValue === null) {
            return $defaultValue;
        }

        try {
            return (new Resource($rawValue))->process();
        } catch (Exception $e) {
            // ...
        }
    }
197319
public function getUser(IncomingMessage $matchingMessage)
    {
        $user = null;
        $this->client->getUserById($matchingMessage->getSender())->then(function ($_user) use (&$user) {
            $user = $_user;
        });
        if (! is_null($user) && $user instanceof SlackUser) {
            return new User($this->client, $user->getRawUser());
        }

        return new User($this->client, ['id' => $matchingMessage->getSender()]);
    }