Module: EbayRequest
- Defined in:
- lib/ebay_request.rb,
lib/ebay_request/version.rb
Defined Under Namespace
Classes: Auth, Base, BusinessPolicies, Config, Error, Finding, Response, Shopping, Site, Trading
Constant Summary collapse
- VERSION =
"0.2.0"
Class Attribute Summary collapse
-
.config_repository ⇒ Object
Returns the value of attribute config_repository.
-
.json_logger ⇒ Object
Returns the value of attribute json_logger.
-
.logger ⇒ Object
Returns the value of attribute logger.
-
.warn_logger ⇒ Object
Returns the value of attribute warn_logger.
Class Method Summary collapse
- .config(key = nil) ⇒ Object
- .configure(key = nil) ⇒ Object
- .configured? ⇒ Boolean
- .fix_utf(response) ⇒ Object
- .log(options) ⇒ Object
-
.log_info(o) ⇒ Object
rubocop:disable Metrics/AbcSize.
- .log_json(options) ⇒ Object
-
.log_warn(o) ⇒ Object
rubocop:enable Metrics/AbcSize.
Class Attribute Details
.config_repository ⇒ Object
Returns the value of attribute config_repository.
26 27 28 |
# File 'lib/ebay_request.rb', line 26 def config_repository @config_repository end |
.json_logger ⇒ Object
Returns the value of attribute json_logger.
27 28 29 |
# File 'lib/ebay_request.rb', line 27 def json_logger @json_logger end |
.logger ⇒ Object
Returns the value of attribute logger.
24 25 26 |
# File 'lib/ebay_request.rb', line 24 def logger @logger end |
.warn_logger ⇒ Object
Returns the value of attribute warn_logger.
25 26 27 |
# File 'lib/ebay_request.rb', line 25 def warn_logger @warn_logger end |
Class Method Details
.config(key = nil) ⇒ Object
29 30 31 32 |
# File 'lib/ebay_request.rb', line 29 def config(key = nil) @config_repository ||= {} @config_repository[key || :default] ||= Config.new end |
.configure(key = nil) ⇒ Object
34 35 36 |
# File 'lib/ebay_request.rb', line 34 def configure(key = nil) yield(config(key)) && config(key) end |
.configured? ⇒ Boolean
38 39 40 |
# File 'lib/ebay_request.rb', line 38 def configured? !@config_repository.nil? end |
.fix_utf(response) ⇒ Object
71 72 73 74 75 |
# File 'lib/ebay_request.rb', line 71 def fix_utf(response) response.encode( "UTF-8", undef: :replace, invalid: :replace, replace: " " ) end |
.log(options) ⇒ Object
42 43 44 45 46 |
# File 'lib/ebay_request.rb', line 42 def log() log_info() log_warn() log_json() end |
.log_info(o) ⇒ Object
rubocop:disable Metrics/AbcSize
49 50 51 52 53 54 55 56 |
# File 'lib/ebay_request.rb', line 49 def log_info(o) return if logger.nil? logger.info "[EbayRequest] | Url | #{o[:url]}" logger.info "[EbayRequest] | Headers | #{o[:headers]}" logger.info "[EbayRequest] | Body | #{o[:request_payload]}" logger.info "[EbayRequest] | Response | #{fix_utf(o[:response_payload])}" logger.info "[EbayRequest] | Time | #{o[:time]} #{o[:callname]}" end |
.log_json(options) ⇒ Object
66 67 68 69 |
# File 'lib/ebay_request.rb', line 66 def log_json() return if json_logger.nil? json_logger.info() end |
.log_warn(o) ⇒ Object
rubocop:enable Metrics/AbcSize
59 60 61 62 63 64 |
# File 'lib/ebay_request.rb', line 59 def log_warn(o) return if warn_logger.nil? || o[:warnings].empty? warn_logger.warn( "[EbayRequest] | #{o[:callname]} | #{o[:warnings].inspect}" ) end |