lib/bitpay/rest_connector.rb
def process_request(request)
      request['User-Agent'] = @user_agent
      request['Content-Type'] = 'application/json'
      request['X-BitPay-Plugin-Info'] = 'Rubylib' + VERSION

      begin
        response = @https.request request
      rescue => error
        raise BitPay::ConnectionError, "#{error.message}"
      end

      if response.kind_of? Net::HTTPSuccess
        return JSON.parse(response.body)
      elsif JSON.parse(response.body)["error"]
        raise(BitPayError, "#{response.code}: #{JSON.parse(response.body)['error']}")
      else
        raise BitPayError, "#{response.code}: #{JSON.parse(response.body)}"
      end

    end
def process_request(request)
      request['User-Agent'] = @user_agent
      request['Content-Type'] = 'application/json'
      request['X-BitPay-Plugin-Info'] = 'Rubylib' + VERSION

      begin
        response = @https.request request
      rescue => error
        raise BitPay::ConnectionError, "#{error.message}"
      end

      if response.kind_of? Net::HTTPSuccess
        return JSON.parse(response.body)
      elsif JSON.parse(response.body)["error"]
        raise(BitPayError, "#{response.code}: #{JSON.parse(response.body)['error']}")
      else
        raise BitPayError, "#{response.code}: #{JSON.parse(response.body)}"
      end

    end
def process_request ( request ) request [ 'User-Agent' ] = @user_agent request [ 'Content-Type' ] = 'application/json' request [ 'X-BitPay-Plugin-Info' ] = 'Rubylib' + VERSION begin response = @https . request request rescue => error raise BitPay :: ConnectionError , "#{error.message}" end if response . kind_of? Net :: HTTPSuccess return JSON . parse ( response . body ) elsif JSON . parse ( response . body ) [ "error" ] raise ( BitPayError , "#{response.code}: #{JSON.parse(response.body)['error']}" ) else raise BitPayError , "#{response.code}: #{JSON.parse(response.body)}" end end
Processes HTTP Request and returns parsed response
 Otherwise throws error
Processes HTTP Request and returns parsed response Otherwise throws error