Skip to content

Commit

Permalink
Merge pull request #84 from niulingyun/master
Browse files Browse the repository at this point in the history
custom headers
  • Loading branch information
hhxsv5 authored Jun 9, 2020
2 parents aec65f0 + 8171edb commit d0e07bf
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ abstract class Api
*/
protected static $logLevel = Logger::DEBUG;

/**
* @var array
*/
protected static $customHeaders;

/**
* @var IAuth $auth
*/
Expand Down Expand Up @@ -171,6 +176,22 @@ public static function setLogLevel($logLevel)
self::$logLevel = $logLevel;
}

/**
* @param array $headers
*/
public static function setCustomHeaders(array $headers)
{
self::$customHeaders = $headers;
}

/**
* @return array
*/
public static function getCustomHeaders()
{
return self::$customHeaders;
}

/**
* @param string $method
* @param string $uri
Expand Down Expand Up @@ -198,6 +219,11 @@ public function call($method, $uri, array $params = [], array $headers = [], $ti
$headers = array_merge($headers, $authHeaders);
}
$headers['User-Agent'] = 'KuCoin-PHP-SDK/' . static::VERSION;

if (self::$customHeaders) {
$headers = array_merge($headers, self::$customHeaders);
}

$request->setHeaders($headers);

$requestId = uniqid();
Expand Down

0 comments on commit d0e07bf

Please sign in to comment.