Handles the response from Telegram API.
 /**
  * A factory for creating the appropriate exception based on the response from Telegram.
  *
  * @param TelegramResponse $response The response that threw the exception.
  *
  * @return TelegramResponseException
  */
 public static function create(TelegramResponse $response)
 {
     $data = $response->getDecodedBody();
     if (!isset($data['ok']) || $data['ok'] === true && !isset($data['result'])) {
         return new TelegramMalformedResponseException($response, 'The ok/result fields are not set in the response', -2);
     }
     $code = isset($data['error_code']) ? $data['error_code'] : -1;
     $message = isset($data['description']) ? $data['description'] : 'Unknown error from API.';
     return new static($response, $message, $code);
 }
 /**
  * A factory for creating the appropriate exception based on the response from Telegram.
  *
  * @param TelegramResponse $response The response that threw the exception.
  *
  * @return TelegramResponseException
  */
 public static function create(TelegramResponse $response)
 {
     $data = $response->getDecodedBody();
     $code = null;
     $message = null;
     if (isset($data['ok'], $data['error_code']) && $data['ok'] === false) {
         $code = $data['error_code'];
         $message = isset($data['description']) ? $data['description'] : 'Unknown error from API.';
     }
     // Others
     return new static($response, new TelegramOtherException($message, $code));
 }