<?php

namespace App\Integrations\Semrush\Requests;

use App\Integrations\Common\Configurable;

final class GetBacklinksRequest extends Configurable implements RequestInterface
{
    protected $options = [
        'url' => 'https://api.semrush.com/analytics/v1/',
        'method' => 'GET',
        'type' => 'backlinks_overview',
        'target_type' => 'url',
    ];

    public function __construct()
    {
        parent::__construct();
    }

    /**
     * @return string
     */
    public function getMethod(): string
    {
        return $this->getOption('method');
    }

    public function getUri()
    {
        return $this->getOption('url')
            .'?'
            .http_build_query([
                'type' => $this->getOption('type'),
                'target' => $this->getOption('target'),
                'target_type' => $this->getOption('target_type'),
                'key' => $this->getOption('key'),
            ]);
    }

    public function getBody()
    {
        return;
    }

    public function setUrl(string $url)
    {
        $this->setOption('target', $url);
    }
}
