<?php

namespace App\Integrations\Semrush\Requests;

use App\Integrations\Common\Configurable;

final class DeleteKeywordRequest extends Configurable implements RequestInterface
{
    protected $options = [
        'url' => 'https://api.semrush.com/management/v1/projects/',
        'suffix' => '/keywords',
        'method' => 'DELETE',
    ];

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

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

    public function getUri()
    {
        return $this->getOption('url')
            .$this->getOption('projectId')
            .$this->getOption('suffix')
            .'?key='
            .$this->getOption('key');
    }

    /**
     * @param array $body
     *
     * @return $this
     */
    public function setBody(array $body): self
    {
        $this->setOption('body', $body);

        return $this;
    }

    public function getBody()
    {
        return $this->getOption('body');
    }

    public function setProjectId(string $projectId)
    {
        $this->setOption('projectId', $projectId);
    }

    /**
     * @return mixed
     *
     * @throws \Exception
     */
    public function getProjectId()
    {
        if (null === $this->getOption('projectId')) {
            throw new \Exception('Semrush project id is not set');
        }

        return $this->getOption('projectId');
    }
}
