Skip to content

Commit

Permalink
Added client source (#55)
Browse files Browse the repository at this point in the history
Co-authored-by: Karol Wojciechowski <[email protected]>
  • Loading branch information
kwojc and Karol Wojciechowski authored Nov 27, 2023
1 parent a1cabae commit 81c1154
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/.dev-tools/.php-cs-fixer.cache
/vendor/
/composer.lock
.idea/
17 changes: 17 additions & 0 deletions src/Api/ApiAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class ApiAction
/** @var bool */
private $productionMode;

private $clientName = 'tpay-com/tpay-openapi-php:1.6.3';

/**
* @param Token $Token
* @param bool $productionMode
Expand Down Expand Up @@ -118,6 +120,16 @@ public function getHttpResponseCode()
return $this->Curl->getHttpResponseCode();
}

public function setClientName($clientName)
{
$this->clientName = $clientName;
}

public function getClientName()
{
return $this->clientName;
}

protected function sendRequest($apiMethod, $requestMethod, $fields = [], $headers = [])
{
$requestUrl = sprintf(
Expand All @@ -131,6 +143,11 @@ protected function sendRequest($apiMethod, $requestMethod, $fields = [], $header
if (!empty($fields)) {
$headers[] = 'Content-Type: application/json';
}

if ($this->clientName) {
$headers[] = 'X-Client-Source: '.$this->clientName;
}

Logger::log(
'Outgoing request',
vsprintf(
Expand Down

0 comments on commit 81c1154

Please sign in to comment.