Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
edsonalvesan committed Mar 24, 2020
1 parent 30aea7e commit b23dd22
Show file tree
Hide file tree
Showing 21 changed files with 199 additions and 1,271 deletions.
824 changes: 104 additions & 720 deletions src/Api.php

Large diffs are not rendered by default.

101 changes: 0 additions & 101 deletions src/Commands/Command.php

This file was deleted.

154 changes: 0 additions & 154 deletions src/Commands/CommandBus.php

This file was deleted.

12 changes: 0 additions & 12 deletions src/Commands/CommandInterface.php

This file was deleted.

25 changes: 0 additions & 25 deletions src/Commands/HelpCommand.php

This file was deleted.

29 changes: 22 additions & 7 deletions src/DigiSacClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class DigiSacClient
protected $httpClientHandler;

/**
* Instantiates a new TelegramClient object.
* Instantiates a new DigiSacClient object.
*
* @param HttpClientInterface|null $httpClientHandler
*/
Expand Down Expand Up @@ -67,26 +67,36 @@ public function getHttpClientHandler()
}

/**
* Returns the base Bot URL.
* Returns the base URL begin.
*
* @return string
*/
public function getBaseBotUrl()
public function getBaseBotUrlBegin()
{
return static::BASE_API_URL_BEGIN;
}

/**
* Returns the base URL begin.
*
* @return string
*/
public function getBaseBotUrlEnd()
{
return static::BASE_API_URL_END;
}

/**
* Prepares the API request for sending to the client handler.
*
* @param TelegramRequest $request
* @param DigiSacRequest $request
*
* @return array
*/
public function prepareRequest(DigiSacRequest $request)
{
$url = $this->getBaseBotUrl().$request->getAccessToken().'/'.$request->getEndpoint();

$url = $this->getBaseBotUrlBegin().$request->getUrl().$this->getBaseBotUrlEnd().'/'.$request->getEndpoint();
return [
$url,
$request->getMethod(),
Expand All @@ -106,8 +116,13 @@ public function prepareRequest(DigiSacRequest $request)
*/
public function sendRequest(DigiSacRequest $request)
{

list($url, $method, $headers, $isAsyncRequest) = $this->prepareRequest($request);

if (!empty($request->getId())) {
$url = $url.'/'.$request->getId();
}

$timeOut = $request->getTimeOut();
$connectTimeOut = $request->getConnectTimeOut();

Expand All @@ -116,7 +131,7 @@ public function sendRequest(DigiSacRequest $request)
} else {
$options = ['query' => $request->getParams()];
}

$rawResponse = $this->httpClientHandler->send($url, $method, $headers, $options, $timeOut, $isAsyncRequest, $connectTimeOut);

$returnResponse = $this->getResponse($request, $rawResponse);
Expand Down
Loading

0 comments on commit b23dd22

Please sign in to comment.