lib/telegram/bot/botan/api.rb in telegram-bot-ruby-0.4.2 vs lib/telegram/bot/botan/api.rb in telegram-bot-ruby-0.5.0.beta1

- old
+ new

@@ -1,22 +1,26 @@ module Telegram module Bot module Botan class Api - include HTTParty - attr_reader :token - base_uri 'https://api.botan.io' - def initialize(token) @token = token end def track(event, uid, properties = {}) - self.class.post('/track', - query: { token: token, name: event, uid: uid }, - body: properties.to_json) + query_str = URI.encode_www_form(token: token, name: event, uid: uid) + conn.post("/track?#{query_str}", properties.to_json) + end + + private + + def conn + @conn ||= Faraday.new(url: 'https://api.botan.io') do |faraday| + faraday.request :url_encoded + faraday.adapter Telegram::Bot.configuration.adapter + end end end end end end