Skip to content

Commit

Permalink
Merge pull request #27 from fekiwebstudio-ceo/master
Browse files Browse the repository at this point in the history
Feature: ability to add extra headers to the API requests.
  • Loading branch information
danfekete authored Sep 24, 2019
2 parents 3ff0faf + 827220b commit 1c57c0b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/HTTP/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ protected function resolveOptions($opts)
$this->resolver->setDefault('version', '2');
$this->resolver->setDefault('host', 'https://www.billingo.hu/api/'); // might be overridden in the future
$this->resolver->setDefault('leeway', 60);
$this->resolver->setDefault('headers', []);
$this->resolver->setRequired(['host', 'version', 'leeway']);

if (array_key_exists('token', $opts)) {
Expand Down Expand Up @@ -91,8 +92,8 @@ public function request($method, $uri, $data = [])
$queryKey = 'json';
}

// make signature
$response = $this->client->request($method, $uri, [$queryKey => $data, 'headers' => $this->generateAuthHeader()]);
$headers = array_merge_recursive($this->config['headers'], $this->generateAuthHeader());
$response = $this->client->request($method, $uri, [$queryKey => $data, 'headers' => $headers]);

$jsonData = json_decode($response->getBody(), true);

Expand Down

0 comments on commit 1c57c0b

Please sign in to comment.