<?php

namespace App\Generated\Controllers\V1;

use App\Generated\V1\Messages\Im\DeleteMessage;
use App\Generated\V1\Messages\Im\GetUsersLatestsMessage;
use App\Generated\V1\Messages\Im\MarkUserMessagesReadMessage;
use App\Http\Controllers\Controller;
use App\Generated\V1\Messages\Im\RevokeMessage;
use App\Http\Services\V1\ImService;
use App\Generated\V1\Messages\Im\SendMessage;
use DB;

class ImController extends Controller
{
    public $handler;

    public function __construct(ImService $handler)
    {
        $this->handler = $handler;
    }

    public function markUserMessagesRead(MarkUserMessagesReadMessage $message)
    {
        $message->validateInput();
        $this->handler->markUserMessagesRead($message);
        $message->validateOutput();
        return $message->getResponse();
    }

    public function delete(DeleteMessage $message)
    {
        $message->validateInput();
        $this->handler->delete($message);
        $message->validateOutput();
        return $message->getResponse();
    }

    public function revoke(RevokeMessage $message)
    {
        $message->validateInput();
        $this->handler->revoke($message);
        $message->validateOutput();
        return $message->getResponse();
    }

    public function send(SendMessage $message)
    {
        $message->validateInput();
        $this->handler->send($message);
        $message->validateOutput();
        return $message->getResponse();
    }

    public function getUsersLatests(GetUsersLatestsMessage $message)
    {
        $message->validateInput();
        $this->handler->getUsersLatests($message);
        $message->validateOutput();
        return $message->getResponse();
    }

}
