зеркало из
https://github.com/glebtv/telegram-bot.git
synced 2026-08-28 15:26:18 +03:00
Pass action parameter to RequestBodyFormatter
Этот коммит содержится в:
@@ -1,6 +1,6 @@
|
|||||||
# Unreleased
|
# Unreleased
|
||||||
|
|
||||||
# 0.15.5
|
# 0.15.6
|
||||||
|
|
||||||
- Rails 7.0 support.
|
- Rails 7.0 support.
|
||||||
- Fix sending File objects in nested objects in sendMediaGroup.
|
- Fix sending File objects in nested objects in sendMediaGroup.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
[](http://badge.fury.io/rb/telegram-bot)
|
[](http://badge.fury.io/rb/telegram-bot)
|
||||||
[](https://codeclimate.com/github/telegram-bot-rb/telegram-bot)
|
[](https://codeclimate.com/github/telegram-bot-rb/telegram-bot)
|
||||||
[](https://travis-ci.com/telegram-bot-rb/telegram-bot)
|
[](https://app.travis-ci.com/github/telegram-bot-rb/telegram-bot)
|
||||||
|
|
||||||
Tools for developing Telegram bots. Best used with Rails, but can be used in
|
Tools for developing Telegram bots. Best used with Rails, but can be used in
|
||||||
[standalone app](https://github.com/telegram-bot-rb/telegram-bot/wiki/Not-rails-application).
|
[standalone app](https://github.com/telegram-bot-rb/telegram-bot/wiki/Not-rails-application).
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ module Telegram
|
|||||||
end
|
end
|
||||||
|
|
||||||
def prepare_async_args(action, body = {})
|
def prepare_async_args(action, body = {})
|
||||||
[action.to_s, Async.prepare_hash(RequestBodyFormatter.format(body))]
|
[action.to_s, Async.prepare_hash(RequestBodyFormatter.format(body, action))]
|
||||||
end
|
end
|
||||||
|
|
||||||
def error_for_response(response)
|
def error_for_response(response)
|
||||||
@@ -63,7 +63,7 @@ module Telegram
|
|||||||
end
|
end
|
||||||
|
|
||||||
def request(action, body = {})
|
def request(action, body = {})
|
||||||
response = http_request("#{base_uri}#{action}", RequestBodyFormatter.format(body))
|
response = http_request("#{base_uri}#{action}", RequestBodyFormatter.format(body, action))
|
||||||
raise self.class.error_for_response(response) if response.status >= 300
|
raise self.class.error_for_response(response) if response.status >= 300
|
||||||
JSON.parse(response.body)
|
JSON.parse(response.body)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module Telegram
|
module Telegram
|
||||||
module Bot
|
module Bot
|
||||||
VERSION = '0.15.5'.freeze
|
VERSION = '0.15.6'.freeze
|
||||||
|
|
||||||
def self.gem_version
|
def self.gem_version
|
||||||
Gem::Version.new VERSION
|
Gem::Version.new VERSION
|
||||||
|
|||||||
@@ -129,7 +129,8 @@ RSpec.describe Telegram::Bot::Client do
|
|||||||
let(:body) { body_json.to_json }
|
let(:body) { body_json.to_json }
|
||||||
let(:body_json) { {'param' => 'val', 'description' => 'some description'} }
|
let(:body_json) { {'param' => 'val', 'description' => 'some description'} }
|
||||||
before do
|
before do
|
||||||
expect(described_class).to receive(:prepare_body).with(request_body) { prepared_body }
|
expect(Telegram::Bot::Client::RequestBodyFormatter).
|
||||||
|
to receive(:format).with(request_body, action) { prepared_body }
|
||||||
expect(instance).to receive(:http_request).with(url, prepared_body) { response }
|
expect(instance).to receive(:http_request).with(url, prepared_body) { response }
|
||||||
end
|
end
|
||||||
around { |ex| Telegram::Bot::ClientStub.stub_all!(false) { ex.run } }
|
around { |ex| Telegram::Bot::ClientStub.stub_all!(false) { ex.run } }
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user