1
0
mirror of synced 2025-01-19 11:41:42 +03:00

Removed rudimentary code

This commit is contained in:
Pavel 2019-06-24 11:05:15 +03:00
parent b630b73f1d
commit da3405661a
2 changed files with 7 additions and 23 deletions

View File

@ -67,7 +67,6 @@ class Client
* @param string $method * @param string $method
* @param object|null $request Request parameters * @param object|null $request Request parameters
* @param string $responseType * @param string $responseType
* @param string $serializeTo
* @param bool $arrayOfObjects * @param bool $arrayOfObjects
* *
* @return object|null * @return object|null
@ -78,14 +77,12 @@ class Client
$method, $method,
$request, $request,
$responseType, $responseType,
$serializeTo = Serializer::S_JSON,
$arrayOfObjects = false $arrayOfObjects = false
) { ) {
$response = $this->client->makeRequest( $response = $this->client->makeRequest(
$path, $path,
$method, $method,
$request, $request
$serializeTo
); );
$data = json_decode((string) $response->getBody(), true); $data = json_decode((string) $response->getBody(), true);
@ -167,7 +164,6 @@ class Client
HttpClient::METHOD_GET, HttpClient::METHOD_GET,
$request, $request,
static::getEntityClass('Bot'), static::getEntityClass('Bot'),
Serializer::S_ARRAY,
true true
); );
} }
@ -205,7 +201,6 @@ class Client
HttpClient::METHOD_GET, HttpClient::METHOD_GET,
$request, $request,
static::getEntityClass('Channel', 'Channel'), static::getEntityClass('Channel', 'Channel'),
Serializer::S_ARRAY,
true true
); );
} }
@ -225,7 +220,6 @@ class Client
HttpClient::METHOD_GET, HttpClient::METHOD_GET,
$request, $request,
static::getEntityClass('Chat', 'Chat'), static::getEntityClass('Chat', 'Chat'),
Serializer::S_ARRAY,
true true
); );
} }
@ -245,7 +239,6 @@ class Client
HttpClient::METHOD_GET, HttpClient::METHOD_GET,
$request, $request,
static::getEntityClass('Command'), static::getEntityClass('Command'),
Serializer::S_ARRAY,
true true
); );
} }
@ -264,8 +257,7 @@ class Client
sprintf("/my/commands/%s", $request->getName()), sprintf("/my/commands/%s", $request->getName()),
HttpClient::METHOD_PUT, HttpClient::METHOD_PUT,
$request, $request,
static::getResponseClass(self::ERROR_ONLY_RESPONSE), static::getResponseClass(self::ERROR_ONLY_RESPONSE)
Serializer::S_JSON
); );
} }
@ -283,8 +275,7 @@ class Client
sprintf("/my/commands/%s", $request), sprintf("/my/commands/%s", $request),
HttpClient::METHOD_DELETE, HttpClient::METHOD_DELETE,
null, null,
static::getResponseClass(self::ERROR_ONLY_RESPONSE), static::getResponseClass(self::ERROR_ONLY_RESPONSE)
Serializer::S_JSON
); );
} }
@ -303,7 +294,6 @@ class Client
HttpClient::METHOD_GET, HttpClient::METHOD_GET,
$request, $request,
static::getEntityClass('Customer'), static::getEntityClass('Customer'),
Serializer::S_ARRAY,
true true
); );
} }
@ -323,7 +313,6 @@ class Client
HttpClient::METHOD_GET, HttpClient::METHOD_GET,
$request, $request,
static::getEntityClass('Dialog'), static::getEntityClass('Dialog'),
Serializer::S_ARRAY,
true true
); );
} }
@ -342,8 +331,7 @@ class Client
sprintf("/dialogs/%d/assign", $request->getDialogId()), sprintf("/dialogs/%d/assign", $request->getDialogId()),
HttpClient::METHOD_PATCH, HttpClient::METHOD_PATCH,
$request, $request,
static::getResponseClass('AssignResponse'), static::getResponseClass('AssignResponse')
Serializer::S_JSON
); );
} }
@ -380,7 +368,6 @@ class Client
HttpClient::METHOD_GET, HttpClient::METHOD_GET,
$request, $request,
static::getEntityClass('Chat', 'ChatMember'), static::getEntityClass('Chat', 'ChatMember'),
Serializer::S_ARRAY,
true true
); );
} }
@ -400,7 +387,6 @@ class Client
HttpClient::METHOD_GET, HttpClient::METHOD_GET,
$request, $request,
self::getEntityClass('Message', 'Message'), self::getEntityClass('Message', 'Message'),
Serializer::S_ARRAY,
true true
); );
} }
@ -474,7 +460,6 @@ class Client
HttpClient::METHOD_GET, HttpClient::METHOD_GET,
$request, $request,
self::getEntityClass('User'), self::getEntityClass('User'),
Serializer::S_ARRAY,
true true
); );
} }

View File

@ -107,12 +107,11 @@ class HttpClient
* @param string $path Request URL * @param string $path Request URL
* @param string $method Request method (default: 'GET') * @param string $method Request method (default: 'GET')
* @param mixed $request Request model (default: null) * @param mixed $request Request model (default: null)
* @param string $serializeTo Serializer::S_JSON or Serializer::S_ARRAY
* *
* @return ResponseInterface * @return ResponseInterface
* @throws \Exception * @throws \Exception
*/ */
public function makeRequest($path, $method, $request = null, $serializeTo = Serializer::S_JSON) public function makeRequest($path, $method, $request = null)
{ {
$getParameters = ''; $getParameters = '';
@ -126,7 +125,7 @@ class HttpClient
$getParameters = Url::buildGetParameters(Serializer::serialize($request, Serializer::S_ARRAY)); $getParameters = Url::buildGetParameters(Serializer::serialize($request, Serializer::S_ARRAY));
} }
$parameters = is_null($request) ? null : Serializer::serialize($request, $serializeTo); $requestBody = is_null($request) ? null : Serializer::serialize($request, Serializer::S_JSON);
$request = new Request( $request = new Request(
$method, $method,
\sprintf("%s%s%s", $this->basePath, $path, $getParameters), \sprintf("%s%s%s", $this->basePath, $path, $getParameters),
@ -137,7 +136,7 @@ class HttpClient
); );
if (in_array($method, [self::METHOD_POST, self::METHOD_PUT, self::METHOD_PATCH, self::METHOD_DELETE])) { if (in_array($method, [self::METHOD_POST, self::METHOD_PUT, self::METHOD_PATCH, self::METHOD_DELETE])) {
$request = $request->withBody(stream_for($parameters)); $request = $request->withBody(stream_for($requestBody));
} }
$responseObject = null; $responseObject = null;