Class: Bugno::Reporter
- Inherits:
-
Object
- Object
- Bugno::Reporter
- Defined in:
- lib/bugno/reporter.rb
Instance Attribute Summary collapse
-
#http ⇒ Object
readonly
Returns the value of attribute http.
-
#request ⇒ Object
Returns the value of attribute request.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #api_response(response) ⇒ Object
-
#initialize ⇒ Reporter
constructor
A new instance of Reporter.
- #send ⇒ Object
Constructor Details
#initialize ⇒ Reporter
Returns a new instance of Reporter.
12 13 14 15 16 |
# File 'lib/bugno/reporter.rb', line 12 def initialize @uri = URI.parse("#{Bugno.configuration.api_url}/api/v1/projects/#{Bugno.configuration.api_key}/events") @http = Net::HTTP.new(uri.host, uri.port) @request = Net::HTTP::Post.new(uri.request_uri, 'Content-Type': 'application/json') end |
Instance Attribute Details
#http ⇒ Object (readonly)
Returns the value of attribute http.
9 10 11 |
# File 'lib/bugno/reporter.rb', line 9 def http @http end |
#request ⇒ Object
Returns the value of attribute request.
10 11 12 |
# File 'lib/bugno/reporter.rb', line 10 def request @request end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
9 10 11 |
# File 'lib/bugno/reporter.rb', line 9 def uri @uri end |
Instance Method Details
#api_response(response) ⇒ Object
27 28 29 30 31 |
# File 'lib/bugno/reporter.rb', line 27 def api_response(response) body = JSON.parse(response.body.presence || '{}') = body['message'] || body['error'] || response. "#{.capitalize} | Code: #{response.code}" end |