Class: Logvisual::Api
- Inherits:
-
Object
- Object
- Logvisual::Api
- Defined in:
- lib/logvisual/api.rb
Overview
Api class
Class Method Summary collapse
Class Method Details
.send_request(endpoint, data = {}, token = nil) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/logvisual/api.rb', line 11 def self.send_request(endpoint, data = {}, token = nil) uri = URI('http://api.logvisual.co/v1' + endpoint) http = Net::HTTP.new(uri.host, uri.port) body = URI.encode_www_form(data) req = Net::HTTP::Post.new(uri) req.add_field('AUTHORIZATION', token) if token req.body = body JSON.parse(http.request(req).body) rescue abort 'Need Internet!' end |