private static function _moSmsFromFields(&$json, &$fields)
    {
        if ($fields->type === 'mo_text') {
            $result = new Api\MoTextSms();
            $result->setBody($fields->body);

            if (isset($fields->keyword)) {
                $result->setKeyword($fields->keyword);
            }
        } else if ($fields->type === 'mo_binary') {
            $result = new Api\MoBinarySms();
            $result->setBody(base64_decode($fields->body));
            $result->setUdh(hex2bin($fields->udh));
        } else {
            throw new UnexpectedResponseException(
                "Received unexpected inbound type " . $fields->type,
                $json
            );
        }

        $result->setMessageId($fields->id);
        $result->setSender($fields->from);
        $result->setRecipient($fields->to);

        if (isset($fields->operator)) {
            $result->setOperator($fields->operator);
        }

        if (isset($fields->sent_at)) {
            $result->setSentAt(
                Deserialize::_dateTime($json, $fields->sent_at)
            );
        }

        if (isset($fields->received_at)) {
            $result->setReceivedAt(
                Deserialize::_dateTime($json, $fields->received_at)
            );
        }

        return $result;
    }