class Ingenico::Direct::SDK::Logging::LogMessageBuilder
Abstract class used to construct a message describing a request or response.
@attr_reader [String] request_id
An identifier assigned to the request and response @attr_reader [String] headers Request or response headers in string form @attr_reader [String] body Request or response body as a string @attr_reader [String] content_type
Content type of the body, generally 'application/json' or 'text/html'
Attributes
body[R]
content_type[R]
headers[R]
request_id[R]
Public Class Methods
new(request_id)
click to toggle source
Create a new LogMessageBuilder
# File lib/ingenico/direct/sdk/logging/log_message_builder.rb, line 18 def initialize(request_id) raise ArgumentError if request_id.nil? || request_id.empty? @request_id = request_id @headers = '' end
Public Instance Methods
add_headers(name, value)
click to toggle source
Adds a single header to the headers
string
# File lib/ingenico/direct/sdk/logging/log_message_builder.rb, line 25 def add_headers(name, value) @headers += ', ' unless @headers.empty? @headers += "#{name}='#{LoggingUtil.obfuscate_header(name, value)}'" end
get_message()
click to toggle source
Constructs and returns the log message as a string.
# File lib/ingenico/direct/sdk/logging/log_message_builder.rb, line 40 def get_message raise NotImplementedError, "#{self.class.name}#get_message() is not implemented." end
set_body(body, content_type)
click to toggle source
@param body [String] the message body @param content_type
[String] the content type of the body
# File lib/ingenico/direct/sdk/logging/log_message_builder.rb, line 34 def set_body(body, content_type) @body = LoggingUtil.obfuscate_body(body) @content_type = content_type end
to_s()
click to toggle source
Calls superclass method
# File lib/ingenico/direct/sdk/logging/log_message_builder.rb, line 44 def to_s self.class == LogMessageBuilder ? super.to_s : get_message end
Protected Instance Methods
empty_if_null(value)
click to toggle source
Returns an empty string if the parameter is nil, and returns the parameter itself otherwise
# File lib/ingenico/direct/sdk/logging/log_message_builder.rb, line 51 def empty_if_null(value) value.nil? ? '' : value end