public function blockUntilDone(
        $appId,
        $scanId,
        $waitTime = 0,
        $sleepTime = 5,
        array $queryParams = []
    ) {
        for ($iteration = 0;; $iteration++) {
            $scanResponse = $this->getById($appId, $scanId, $queryParams);
            $scan = $scanResponse->getDecodedData();

            if ((int) $scan->phase === 0 && (int) $scan->percent === 100) {
                return $scanResponse;
            } else if ($waitTime > 0 && $iteration > ($waitTime / $sleepTime)) {
                throw new \Exception('Scan did not finish before the defined wait time.');
            }

            sleep($sleepTime);
        }

        throw new \Exception('blockUntilDone unexpected state');
    }