lib/telegram/bot/api.rb in telegram-bot-ruby-0.8.6.1 vs lib/telegram/bot/api.rb in telegram-bot-ruby-0.9.0
- old
+ new
@@ -1,8 +1,8 @@
module Telegram
module Bot
- class Api
+ class Api # rubocop:disable ClassLength
ENDPOINTS = %w(
getUpdates setWebhook deleteWebhook getWebhookInfo getMe sendMessage
forwardMessage sendPhoto sendAudio sendDocument sendVideo sendVoice
sendVideoNote sendMediaGroup sendLocation editMessageLiveLocation
stopMessageLiveLocation sendVenue sendContact sendChatAction
@@ -14,11 +14,12 @@
answerCallbackQuery editMessageText editMessageCaption
editMessageReplyMarkup deleteMessage sendSticker getStickerSet
uploadStickerFile createNewStickerSet addStickerToSet
setStickerPositionInSet deleteStickerFromSet answerInlineQuery
sendInvoice answerShippingQuery answerPreCheckoutQuery
- sendGame setGameScore getGameHighScores
+ sendGame setGameScore getGameHighScores setPassportDataErrors
+ editMessageMedia sendAnimation sendPoll stopPoll
).freeze
REPLY_MARKUP_TYPES = [
Telegram::Bot::Types::ReplyKeyboardMarkup,
Telegram::Bot::Types::ReplyKeyboardRemove,
Telegram::Bot::Types::ForceReply,
@@ -89,17 +90,17 @@
def sanitize_value(value)
jsonify_inline_query_results(jsonify_reply_markup(value))
end
def jsonify_reply_markup(value)
- return value unless REPLY_MARKUP_TYPES.include?(value.class)
+ return value unless REPLY_MARKUP_TYPES.any? { |type| value.is_a?(type) }
value.to_compact_hash.to_json
end
def jsonify_inline_query_results(value)
return value unless
value.is_a?(Array) &&
- value.all? { |i| INLINE_QUERY_RESULT_TYPES.include?(i.class) }
+ value.all? { |i| INLINE_QUERY_RESULT_TYPES.any? { |t| i.is_a?(t) } }
value.map { |i| i.to_compact_hash.select { |_, v| v } }.to_json
end
def camelize(method_name)
words = method_name.split('_')