PHP Class Telegram\Bot\TelegramResponse

Handles the response from Telegram API.
Exibir arquivo Open project: irazasyed/telegram-bot-sdk Class Usage Examples

Protected Properties

Property Type Description
$body The raw body of the response from API request.
$decodedBody The decoded body of the API response.
$endPoint API Endpoint used to make the request.
$headers The headers returned from API request.
$httpStatusCode The HTTP status code response from API.
$request The original request that returned this response.
$thrownException The exception thrown by this request.

Public Methods

Method Description
__construct ( Telegram\Bot\TelegramRequest $request, Psr\Http\Message\ResponseInterface | GuzzleHttp\Promise\PromiseInterface $response ) Gets the relevant data from the Http client.
decodeBody ( ) Converts raw API response to proper decoded response.
getAccessToken ( ) : string | null Return the bot access token that was used for this request.
getBody ( ) : string Return the raw body response.
getDecodedBody ( ) : array Return the decoded body response.
getEndpoint ( ) : string Gets the Request Endpoint used to get the response.
getHeaders ( ) : array Return the HTTP headers for this response.
getHttpStatusCode ( ) : null | integer Gets the HTTP status code.
getRequest ( ) : Telegram\Bot\TelegramRequest Return the original request that returned this response.
getResult ( ) : mixed Helper function to return the payload of a successful response.
getThrownException ( ) : Telegram\Bot\Exceptions\TelegramSDKException Returns the exception that was thrown for this request.
isError ( ) : boolean Checks if response is an error.
makeException ( ) Instantiates an exception to be thrown later.
throwException ( ) Throws the exception.

Method Details

__construct() public method

Gets the relevant data from the Http client.
public __construct ( Telegram\Bot\TelegramRequest $request, Psr\Http\Message\ResponseInterface | GuzzleHttp\Promise\PromiseInterface $response )
$request Telegram\Bot\TelegramRequest
$response Psr\Http\Message\ResponseInterface | GuzzleHttp\Promise\PromiseInterface

decodeBody() public method

Converts raw API response to proper decoded response.
public decodeBody ( )

getAccessToken() public method

Return the bot access token that was used for this request.
public getAccessToken ( ) : string | null
return string | null

getBody() public method

Return the raw body response.
public getBody ( ) : string
return string

getDecodedBody() public method

Return the decoded body response.
public getDecodedBody ( ) : array
return array

getEndpoint() public method

Gets the Request Endpoint used to get the response.
public getEndpoint ( ) : string
return string

getHeaders() public method

Return the HTTP headers for this response.
public getHeaders ( ) : array
return array

getHttpStatusCode() public method

Returns NULL if the request was asynchronous since we are not waiting for the response.
public getHttpStatusCode ( ) : null | integer
return null | integer

getRequest() public method

Return the original request that returned this response.
public getRequest ( ) : Telegram\Bot\TelegramRequest
return Telegram\Bot\TelegramRequest

getResult() public method

Helper function to return the payload of a successful response.
public getResult ( ) : mixed
return mixed

getThrownException() public method

Returns the exception that was thrown for this request.
public getThrownException ( ) : Telegram\Bot\Exceptions\TelegramSDKException
return Telegram\Bot\Exceptions\TelegramSDKException

isError() public method

Checks if response is an error.
public isError ( ) : boolean
return boolean

makeException() public method

Instantiates an exception to be thrown later.
public makeException ( )

throwException() public method

Throws the exception.
public throwException ( )

Property Details

$body protected_oe property

The raw body of the response from API request.
protected $body

$decodedBody protected_oe property

The decoded body of the API response.
protected $decodedBody

$endPoint protected_oe property

API Endpoint used to make the request.
protected $endPoint

$headers protected_oe property

The headers returned from API request.
protected $headers

$httpStatusCode protected_oe property

The HTTP status code response from API.
protected $httpStatusCode

$request protected_oe property

The original request that returned this response.
protected $request

$thrownException protected_oe property

The exception thrown by this request.
protected $thrownException