class Coinbase::Wallet::NetHTTPClient
Net-HTTP adapter
Public Class Methods
new(base_uri, options = {})
click to toggle source
# File lib/coinbase/wallet/adapters/net_http.rb, line 5 def initialize(base_uri, options = {}) @conn = Net::HTTP.new(base_uri.host, base_uri.port) @conn.use_ssl = true if base_uri.scheme == 'https' @conn.cert_store = self.class.whitelisted_certificates @conn.ssl_version = :TLSv1_2 end
Private Instance Methods
http_verb(method, path, body = nil, headers = {}) { |out| ... }
click to toggle source
# File lib/coinbase/wallet/adapters/net_http.rb, line 14 def http_verb(method, path, body = nil, headers = {}) case method when 'GET' then req = Net::HTTP::Get.new(path) when 'PUT' then req = Net::HTTP::Put.new(path) when 'POST' then req = Net::HTTP::Post.new(path) when 'DELETE' then req = Net::HTTP::Delete.new(path) else raise end req.body = body req['Content-Type'] = 'application/json' req['User-Agent'] = "coinbase/ruby/#{Coinbase::Wallet::VERSION}" auth_headers(method, path, body).each do |key, val| req[key] = val end headers.each do |key, val| req[key] = val end resp = @conn.request(req) out = NetHTTPResponse.new(resp) Coinbase::Wallet::check_response_status(out) yield(out) out.data end