Class: Cryptoprocessing::NetHTTPResponse

Inherits:
APIResponse show all
Defined in:
lib/cryptoprocessing/client/net_response.rb

Overview

Net-Http response object

Instance Attribute Summary

Attributes inherited from APIResponse

#client, #method, #params, #received_at

Instance Method Summary collapse

Methods inherited from APIResponse

#has_more?, #initialize, #raw

Constructor Details

This class inherits a constructor from Cryptoprocessing::APIResponse

Instance Method Details

#bodyObject



7
8
9
# File 'lib/cryptoprocessing/client/net_response.rb', line 7

def body
  JSON.parse(@response.body) rescue {}
end

#body=(body) ⇒ Object



11
12
13
# File 'lib/cryptoprocessing/client/net_response.rb', line 11

def body=(body)
  @response.body = body.to_json
end

#dataObject



15
16
17
# File 'lib/cryptoprocessing/client/net_response.rb', line 15

def data
  body
end

#headersObject



19
20
21
22
23
24
# File 'lib/cryptoprocessing/client/net_response.rb', line 19

def headers
  out = @response.to_hash.map do |key, val|
    [key.upcase.gsub('_', '-'), val.count == 1 ? val.first : val]
  end
  out.to_h
end

#statusObject



26
27
28
# File 'lib/cryptoprocessing/client/net_response.rb', line 26

def status
  @response.code.to_i
end