Class: KSequencing::Connection
- Inherits:
-
Object
- Object
- KSequencing::Connection
- Defined in:
- lib/k_sequencing/connection.rb
Instance Method Summary collapse
Instance Method Details
#get(path, options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/k_sequencing/connection.rb', line 9 def get(path, = {}) response = connection.get do |request| request.url(path) request.headers["Content-Type"] = "application/json" request.headers["Authorization"] = [:token] unless [:token].nil? request.params = end Response.new(data(response), true, response.status, "success", (response), total(response)) rescue Error, Faraday::Error => e handle_error(e) end |
#post(path, options = {}, query_params = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/k_sequencing/connection.rb', line 21 def post(path, = {}, query_params = {}) response = connection.post do |request| request.path = path request.headers["Content-Type"] = "application/json" request.headers["Authorization"] = [:token] unless [:token].nil? request.params = query_params request.body = unless .empty? end Response.new(data(response), true, response.status) rescue Error, Faraday::Error => e handle_error(e) end |