Class: Coinbase::Wallet::NetHTTPResponse

Inherits:
APIResponse show all
Defined in:
lib/coinbase/wallet/adapters/net_http.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 Coinbase::Wallet::APIResponse

Instance Method Details

#bodyObject



44
45
46
# File 'lib/coinbase/wallet/adapters/net_http.rb', line 44

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

#body=(body) ⇒ Object



48
49
50
# File 'lib/coinbase/wallet/adapters/net_http.rb', line 48

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

#dataObject



52
53
54
# File 'lib/coinbase/wallet/adapters/net_http.rb', line 52

def data
  body['data']
end

#headersObject



56
57
58
59
60
61
# File 'lib/coinbase/wallet/adapters/net_http.rb', line 56

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



63
64
65
# File 'lib/coinbase/wallet/adapters/net_http.rb', line 63

def status
  @response.code.to_i
end