CheckDictionariesChange.php 864 Bytes
<?php
namespace App\Service\Requests\Direct;

use App\Jobs\ProcessCallLimitedAPI;
use App\Service\API\API;
use App\Service\Requests\APIRequest;
use App\Service\Requests\DirectRequest;

class CheckDictionariesChange extends DirectRequest {
    protected $next;

    function call($next = null, $response = null){
        $this->next = $next;
        $this->requestPrepare($response);
        $process = new ProcessCallLimitedAPI($this);
        dispatch($process)->onQueue('limits');
    }

    function handle($response){
//        if ($this->next){
//            $this->next->call(null, $response);
//        }
        $this->token->timestamp = $response['result']['Timestamp'] ?? '';
        $this->token->save();
    }

    private function requestPrepare($response){
        $this->setService('changes');
        $this->setMethod('checkDictionaries');
    }
}