Sha256: 0d9869256dcff0487d15acd7db0d459a5abe6f1407d71931018ead17491f48e4
Contents?: true
Size: 886 Bytes
Versions: 4
Compression:
Stored size: 886 Bytes
Contents
module Telegram module Bot class Botan TRACK_URI = 'https://api.botan.io/track'.freeze class Error < Bot::Error; end include DebugClient attr_reader :client, :token def initialize(token) @client = HTTPClient.new @token = token end def track(event, uid, payload = {}) res = http_request( :post, TRACK_URI, {token: token, name: event, uid: uid}, payload.to_json, ) status = res.status return JSON.parse(res.body) if 300 > status result = JSON.parse(res.body) rescue nil # rubocop:disable RescueModifier err_msg = "#{res.reason}: #{result && result['info'] || '-'}" raise Error, err_msg end def http_request(method, uri, query, body) client.request(method, uri, query, body) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
telegram-bot-0.8.0 | lib/telegram/bot/botan.rb |
telegram-bot-0.7.4 | lib/telegram/bot/botan.rb |
telegram-bot-0.7.3 | lib/telegram/bot/botan.rb |
telegram-bot-0.7.2 | lib/telegram/bot/botan.rb |