Sha256: 2892459436b15449e9b0d3a9133a24da5aba998827803c05880db80432668057

Contents?: true

Size: 836 Bytes

Versions: 9

Compression:

Stored size: 836 Bytes

Contents

module Digicert
  class Debugger
    def initialize(request:, response:)
      @request = request
      @response = response
    end

    def debug
      puts "[API Reqeust Begin]".center(50, "=")
      puts api_request_details
      puts api_response_details
      puts "[API Reqeust End]".center(50, "=")
    end

    private

    attr_reader :request, :response

    def api_request_details
      uri = ["[URI]", request.method, request.uri].join(" ")
      headers = "[Headers] " + request.to_hash.to_s
      body = "[Request Body] " + request.body.to_json if request.body

      [uri, headers, body].join("\n")
    end

    def api_response_details
      response_object = "[Response] " + response.inspect
      body = "[Response Body] " + response.body if response.body

      [response_object, body].join("\n")
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
digicert-1.0.0 lib/digicert/debugger.rb
digicert-0.5.0 lib/digicert/debugger.rb
digicert-0.4.1 lib/digicert/debugger.rb
digicert-0.4.0 lib/digicert/debugger.rb
digicert-0.3.1 lib/digicert/debugger.rb
digicert-0.3.0 lib/digicert/debugger.rb
digicert-0.2.0 lib/digicert/debugger.rb
digicert-0.1.2 lib/digicert/debugger.rb
digicert-0.1.1 lib/digicert/debugger.rb