<?php

namespace App\Http\Services\V1;

use App\Generated\V1\Messages\Share\PairVipCheckMessage;
use App\Generated\V1\Messages\Share\PairGetMessage;
use App\Managers\LikeManager;
use App\Managers\SharePairManager;
use App\Http\Controllers\Core\Auth;
use App\Generated\V1\Messages\Share\LikeMeMessage;
use App\Generated\V1\Messages\Share\LikeMeCheckMessage;
use App\Generated\V1\Messages\Share\LikeMeHistoryMessage;

class ShareService
{
    protected $sharePairManager;
    protected $likeManager;

    public function __construct(SharePairManager $sharePairManager, LikeManager $likeManager)
    {
        $this->sharePairManager = $sharePairManager;
        $this->likeManager = $likeManager;
    }

    public function pairVipCheck(PairVipCheckMessage $message)
    {
        $inviteId = $message->getInviteId();
        $uid = Auth::auth();
        $data = $this->sharePairManager->vipCheck($uid, $inviteId);

        $message->setResponse($data);
    }

    public function pairGet(PairGetMessage $message)
    {
        $listId = $message->getListId();
        $data = $this->sharePairManager->get($listId);
        $message->setResponse($data);
    }

    public function likeMe(LikeMeMessage $message)
    {
        $praiseId = $message->getPraiseId();

        $data = $this->likeManager->get($praiseId);

        $message->setResponse($data);
    }

    public function likeMeCheck(LikeMeCheckMessage $message)
    {
        $praiseId = $message->getPraiseId();
        $uid = Auth::auth();

        $data = $this->likeManager->check($uid, $praiseId);

        $message->setResponse($data);
    }

    public function likeMeHistory(LikeMeHistoryMessage $message)
    {
        $praiseId = $message->getPraiseId();

        $data = $this->likeManager->history($praiseId);

        $message->setResponse($data);
    }
}
