Class: PaypalServerSdk::ResponseLoggingConfiguration

Inherits:
CoreLibrary::ApiResponseLoggingConfiguration
  • Object
show all
Defined in:
lib/paypal_server_sdk/logging/configuration/api_logging_configuration.rb

Overview

Initializes a new instance of ResponseLoggingConfiguration.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(log_body: false, log_headers: false, headers_to_include: nil, headers_to_exclude: nil, headers_to_unmask: nil) ⇒ ResponseLoggingConfiguration

Returns a new instance of ResponseLoggingConfiguration.



79
80
81
82
83
84
85
86
87
88
# File 'lib/paypal_server_sdk/logging/configuration/api_logging_configuration.rb', line 79

def initialize(log_body: false, log_headers: false, headers_to_include: nil,
               headers_to_exclude: nil, headers_to_unmask: nil)
  super(
    log_body,
    log_headers,
    headers_to_exclude,
    headers_to_include,
    headers_to_unmask
  )
end

Class Method Details

.any_logging_configured?Boolean

Returns:

  • (Boolean)


123
124
125
126
127
128
129
130
131
# File 'lib/paypal_server_sdk/logging/configuration/api_logging_configuration.rb', line 123

def self.any_logging_configured?
  %w[
    RESPONSE_LOG_BODY
    RESPONSE_LOG_HEADERS
    RESPONSE_HEADERS_TO_INCLUDE
    RESPONSE_HEADERS_TO_EXCLUDE
    RESPONSE_HEADERS_TO_UNMASK
  ].any? { |key| ENV.key?(key) && !ENV[key].nil? && !ENV[key].empty? }
end

.from_envObject



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/paypal_server_sdk/logging/configuration/api_logging_configuration.rb', line 107

def self.from_env
  log_body = ENV['RESPONSE_LOG_BODY']
  log_headers = ENV['RESPONSE_LOG_HEADERS']
  headers_to_include = ENV['RESPONSE_HEADERS_TO_INCLUDE']
  headers_to_exclude = ENV['RESPONSE_HEADERS_TO_EXCLUDE']
  headers_to_unmask = ENV['RESPONSE_HEADERS_TO_UNMASK']

  new(
    log_body: log_body,
    log_headers: log_headers,
    headers_to_include: headers_to_include,
    headers_to_exclude: headers_to_exclude,
    headers_to_unmask: headers_to_unmask
  )
end

Instance Method Details

#clone_with(log_body: nil, log_headers: nil, headers_to_include: nil, headers_to_exclude: nil, headers_to_unmask: nil) ⇒ Object



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/paypal_server_sdk/logging/configuration/api_logging_configuration.rb', line 90

def clone_with(log_body: nil, log_headers: nil, headers_to_include: nil,
               headers_to_exclude: nil, headers_to_unmask: nil)
  log_body ||= self.log_body
  log_headers ||= self.log_headers
  headers_to_include ||= self.headers_to_include
  headers_to_exclude ||= self.headers_to_exclude
  headers_to_unmask ||= self.headers_to_unmask

  ResponseLoggingConfiguration.new(
    log_body: log_body,
    log_headers: log_headers,
    headers_to_include: headers_to_include,
    headers_to_exclude: headers_to_exclude,
    headers_to_unmask: headers_to_unmask
  )
end