<?php

namespace App\Http\Controllers\V1;

use Illuminate\Http\Request;
use App\Services\MediaResourcesService;
use Constants;



class MediaController extends BaseController
{

    protected $request;
    protected $service;


    public function __construct(Request $request,MediaResourcesService $mediaResourcesService)
    {
        $this->request = $request;
        $this->service = $mediaResourcesService;
    }


    public function getMetDownloadUrl()
    {

        $mediaId = $this->request->input('media_id');

        $mediaIdDecode = json_decode($mediaId,true);


        if(empty($mediaIdDecode) || !is_array($mediaIdDecode)){
           return $this->respondError(Constants::PARAMETER_ERROR,'媒资传入参数格式错误');
        }

        $re = $this->service->getMediaResources($mediaIdDecode);

        $re = $this->service->dealMediaResources($re,'met');
        return $this->respondSuccess($re);

    }

    public function getVideoMessage()
    {

        $mediaId = $this->request->input('media_id');

        $mediaIdDecode = json_decode($mediaId,true);

        if(empty($mediaIdDecode) && !is_array($mediaIdDecode)){
            return $this->respondError(Constants::PARAMETER_ERROR,'媒资传入参数格式错误');
        }
        $re = $this->service->getMediaResources($mediaIdDecode);


        $re = $this->service->dealMediaResources($re,'video_message');
        return $this->respondSuccess($re);
    }












}