Class: AgentsControl::Channels::Telegram::Http
- Inherits:
-
Object
- Object
- AgentsControl::Channels::Telegram::Http
- Defined in:
- lib/agents_control/channels/telegram/api.rb
Overview
Transport is split out separately so tests never hit the network.
Constant Summary collapse
- NetworkError =
Class.new(StandardError)
- NETWORK_ERRORS =
[ Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::EHOSTUNREACH, Errno::ENETUNREACH, Errno::ETIMEDOUT, Errno::EPIPE, SocketError, Timeout::Error, OpenSSL::SSL::SSLError, IOError ].freeze
Instance Method Summary collapse
Instance Method Details
#post(uri, params, read_timeout:) ⇒ Object
159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/agents_control/channels/telegram/api.rb', line 159 def post(uri, params, read_timeout:) request = Net::HTTP::Post.new(uri) request.set_form_data(params) Net::HTTP.start(uri.host, uri.port, use_ssl: true, open_timeout: 10, read_timeout: read_timeout) do |http| http.request(request) end rescue *NETWORK_ERRORS => e raise NetworkError, e. end |