Class: KSequencing::Connection
- Inherits:
-
Object
- Object
- KSequencing::Connection
- Defined in:
- lib/k_sequencing/connection.rb
Overview
:nodoc:
Instance Method Summary collapse
Instance Method Details
#get(path, options = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/k_sequencing/connection.rb', line 8 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
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/k_sequencing/connection.rb', line 20 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 |