Class: Optimum::Connection

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

Constant Summary collapse

BASE_PATH =
'/api/v1/instant-decision'

Instance Method Summary collapse

Instance Method Details

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



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/optimum/connection.rb', line 13

def get(path, params = {})
  log "GET #{path} with #{params}"

  http_response = adapter.get(PathSanitizer.sanitize(path)) do |req|
    req.body = params.to_json
  end

  log "Response: #{http_response.body}"

  Response.new(http_response)
end

#post(path, params = {}) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/optimum/connection.rb', line 25

def post(path, params = {})
  log "POST #{path} with #{params}"

  http_response = adapter.post(PathSanitizer.sanitize(path), params.to_json)

  log "Response: #{http_response.body}"

  Response.new(http_response)
end

#put(path, params = {}) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/optimum/connection.rb', line 35

def put(path, params = {})
  log "PUT #{path} with #{params}"

  http_response = adapter.put(PathSanitizer.sanitize(path), params.to_json)

  log "Response: #{http_response.body}"

  Response.new(http_response)
end