<?php

declare(strict_types=1);

namespace LidonationDevs\ADAPAYFWC\Integrations\AdaUsdExchange\Requests;

use Saloon\Enums\Method;
use Saloon\Http\Request;

class CoinmarketcapGetQuoteRequest extends Request
{
    /**
     * The HTTP method of the request
     */
    protected Method $method = Method::GET;

    public $settings;

    public function __construct(protected int $id)
    {
        $this->settings = get_option('woocommerce_ada_payment_settings');
    }

    public function defaultHeaders(): array
    {

        return [
            'X-CMC_PRO_API_KEY' => !!$this->settings ? $this->settings['coinMarketCapKey'] : null,
            'Accepts' => 'application/json',
        ];
    }

    /**
     * The endpoint for the request
     */
    public function resolveEndpoint(): string
    {
        return 'https://pro-api.coinmarketcap.com/v2/cryptocurrency/quotes/latest';
    }

    protected function defaultQuery(): array
    {
        return [
            'id' => $this->id,
        ];
    }
}
