Class: KSequencing::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/k_sequencing/connection.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#get(path, options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/k_sequencing/connection.rb', line 7

def get(path, options = {})
  @response = connection.get do |request|
    request.url(path)
    request.headers['Content-Type'] = 'application/json'
    request.headers['Authorization'] = options[:token] unless options[:token].nil?
    request.params = options[:path_param] ? prediction_options(options) : options
  end
  Response.new(data, status_code, message, meta, total)
rescue Error, Faraday::Error => e
  handle_error(e)
end

#post(path, options = {}, query_params = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/k_sequencing/connection.rb', line 19

def post(path, options = {}, query_params = {})
  @response = connection.post do |request|
    request.path = path
    request.headers['Content-Type'] = 'application/json'
    request.headers['Authorization'] = options[:token] unless options[:token].nil?
    request.params = query_params
    request.body = options unless options.nil?
  end
  Response.new(data, status_code, message, meta, nil)
rescue Error, Faraday::Error => e
  handle_error(e)
end