<?php

namespace App\Services;

class StationApiService extends BaseApiService
{
    public function __construct()
    {
        parent::__construct(config('app.station_api_base_url'));
        $this->defaultHeaders = array_merge($this->defaultHeaders, [
            'X-Requested-With' => 'station-locator-api',
        ]);
    }

    public function getBranch($url, $params = [])
    {
        return $this->makeRequest('get', $url, $params);
    }

    public function postBranch($url, $params = [])
    {
        return $this->makeRequest('post', $url, $params);
    }

    public function putBranch($url, $params = [])
    {
        return $this->makeRequest('put', $url, $params);
    }

    public function deleteBranch($url, $params = [])
    {
        return $this->makeRequest('delete', $url, ['params' => $params]);
    }

    public function postFuel($url, $params = [])
    {
        return $this->makeRequest('post', $url, $params);
    }

    public function putFuel($url, $params = [])
    {
        return $this->makeRequest('put', $url, $params);
    }

    public function getFuels($url, $params = [])
    {
        return $this->makeRequest('get', $url, $params);
    }

    public function getCsv($url, $params = [])
    {
        return Http::withHeaders(array_merge($this->defaultHeaders, [
            'Authorization' => 'Bearer ' . Session::get('token', ''),
        ]))->get($this->baseUrl . $url, $params)->body(); // Return raw text for CSV
    }
}