Class: Ingenico::Connect::SDK::Logging::LogMessageBuilder
- Inherits:
-
Object
- Object
- Ingenico::Connect::SDK::Logging::LogMessageBuilder
- Defined in:
- lib/ingenico/connect/sdk/logging/log_message_builder.rb
Overview
Abstract class used to construct a message describing a request or response.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Request or response body as a string.
-
#content_type ⇒ Object
readonly
Content type of the body, generally ‘application/json’ or ‘text/html’.
-
#headers ⇒ Object
readonly
Request or response headers in string form.
-
#request_id ⇒ Object
readonly
An identifier assigned to the request and response.
Instance Method Summary collapse
-
#add_headers(name, value) ⇒ Object
Adds a single header to the #headers string.
-
#get_message ⇒ Object
Constructs and returns the log message as a string.
-
#initialize(requestId) ⇒ LogMessageBuilder
constructor
Create a new LogMessageBuilder.
-
#set_body(body, content_type) ⇒ Object
Sets the body of this message to the parameter body.
- #to_s ⇒ Object
Constructor Details
#initialize(requestId) ⇒ LogMessageBuilder
Create a new LogMessageBuilder
20 21 22 23 24 |
# File 'lib/ingenico/connect/sdk/logging/log_message_builder.rb', line 20 def initialize(requestId) raise ArgumentError if requestId.nil? or requestId.empty? @request_id = requestId @headers = '' end |
Instance Attribute Details
#body ⇒ Object (readonly)
Request or response body as a string
14 15 16 |
# File 'lib/ingenico/connect/sdk/logging/log_message_builder.rb', line 14 def body @body end |
#content_type ⇒ Object (readonly)
Content type of the body, generally ‘application/json’ or ‘text/html’
17 18 19 |
# File 'lib/ingenico/connect/sdk/logging/log_message_builder.rb', line 17 def content_type @content_type end |
#headers ⇒ Object (readonly)
Request or response headers in string form
11 12 13 |
# File 'lib/ingenico/connect/sdk/logging/log_message_builder.rb', line 11 def headers @headers end |
#request_id ⇒ Object (readonly)
An identifier assigned to the request and response
8 9 10 |
# File 'lib/ingenico/connect/sdk/logging/log_message_builder.rb', line 8 def request_id @request_id end |
Instance Method Details
#add_headers(name, value) ⇒ Object
Adds a single header to the #headers string
27 28 29 30 31 32 |
# File 'lib/ingenico/connect/sdk/logging/log_message_builder.rb', line 27 def add_headers(name, value) @headers += ', ' if @headers.length > 0 @headers += name + '="' @headers += LoggingUtil.obfuscate_header(name, value) unless value.nil? @headers += '"' end |
#get_message ⇒ Object
Constructs and returns the log message as a string.
43 44 45 |
# File 'lib/ingenico/connect/sdk/logging/log_message_builder.rb', line 43 def raise NotImplementedError("#{self.class.name}#get_message() is not implemented.") end |
#set_body(body, content_type) ⇒ Object
Sets the body of this message to the parameter body.
- body
-
The message body
- content_type
-
The content type of the body
37 38 39 40 |
# File 'lib/ingenico/connect/sdk/logging/log_message_builder.rb', line 37 def set_body(body, content_type) @body = LoggingUtil.obfuscate_body(body) @content_type = content_type end |
#to_s ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/ingenico/connect/sdk/logging/log_message_builder.rb', line 47 def to_s if self.class == LogMessageBuilder return super.to_s else return end end |