Skip to content

Commit

Permalink
Feature: ability to add extra headers to the API requests.
Browse files Browse the repository at this point in the history
  • Loading branch information
nxu committed Sep 23, 2019
1 parent 3ff0faf commit 827220b
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 827220b

Please sign in to comment.