baseUrl = $baseUrl; $this->token = $token; } public function set(string $baseUrl = null,string $token = null):self { $this->baseUrl = $baseUrl; $this->token = $token; return $this; } public function setBaseUrl():self { $this->baseUrl = $baseUrl; return $this; } public function setToken(string $token): self { $this->token = $token; return $this; } public function withDefaultHeaders(): \Illuminate\Http\Client\PendingRequest { return Http::withHeaders([ 'Accept' => 'application/json', 'Authorization' => 'Bearer ' . $this->token, 'Content-Type' => 'application/json', ]); } public function post(string $endpoint, array $data = []) { return $this->withDefaultHeaders()->post($this->baseUrl . $endpoint, $data); } public function get(string $endpoint, array $query = []) { return $this->withDefaultHeaders()->get($this->baseUrl . $endpoint, $query); } }