Skip to content

Commit

Permalink
analysis: fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
a1383n committed Sep 27, 2024
1 parent d76a955 commit ed7a401
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions src/Services/ApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,22 @@ public function __construct($username, $privateKey, $baseUri = 'https://tp.tax.g
$this->encryptor = new EncryptionService();
$this->response = new Response();
}

/**
* Sends a packet to the API server.
*
* @param Packet $packet The packet to send.
* @return mixed The response from the API server.
* @return Response The response from the API server.
*/
public function sendRequest(Request $request): Response
{
if ($request->needToken) {
$this->addToken($request);
}

if ($request->getPacket()->needEncrypt) {
$this->encryptPacket($request->getPacket());
}

$request = $this->signRequest($request);

$httpResp = $this->httpClient->post($request->getPacket()->path, [
Expand Down Expand Up @@ -88,8 +90,7 @@ public function getToken()
/**
* Signs a packet with a digital signature.
*
* @param Packet $packet The packet to sign.
* @return void
* @return Request
*/
private function signRequest(Request $request)
{
Expand All @@ -111,7 +112,8 @@ private function signRequest(Request $request)
* Encrypts a packet with a symmetric encryption algorithm.
*
* @param Packet $packet The packet to encrypt.
* @return void
*
* @return Packet
*/
private function encryptPacket(Packet $packet)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Services/SignatureService.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static function normalizer(array $data, array $headers): string
if ($value === '' || $value === null) {
$value = '#';
} else {
strtr($value, [ '#' => '##']);
$value = strtr($value, [ '#' => '##']);
}

$normalizedData[] = $value;
Expand Down

0 comments on commit ed7a401

Please sign in to comment.