Class: Telebugs::Sender
- Inherits:
-
Object
- Object
- Telebugs::Sender
- Defined in:
- lib/telebugs/sender.rb
Overview
Responsible for sending HTTP requests to Telebugs.
Constant Summary collapse
- CONTENT_TYPE =
"application/json"
- USER_AGENT =
"telebugs-ruby/#{Telebugs::VERSION} (#{RUBY_ENGINE}/#{RUBY_VERSION})"
Instance Method Summary collapse
-
#initialize ⇒ Sender
constructor
A new instance of Sender.
- #send(data) ⇒ Object
Constructor Details
Instance Method Details
#send(data) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/telebugs/sender.rb', line 15 def send(data) req = build_request(@config.api_url, data) resp = build_https(@config.api_url).request(req) if resp.code_type == Net::HTTPCreated return JSON.parse(resp.body) end begin reason = JSON.parse(resp.body) rescue JSON::ParserError nil end raise HTTPError, "#{resp.code_type} (#{resp.code}): #{reason}" end |