Class: RubyCode::Views::Adapter::DebugRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/rubycode/views/adapter/debug_request.rb

Overview

Builds debug request text for adapter API calls

Class Method Summary collapse

Class Method Details

.build(adapter_name:, url:, model:, payload:) ⇒ Object



11
12
13
14
15
# File 'lib/rubycode/views/adapter/debug_request.rb', line 11

def self.build(adapter_name:, url:, model:, payload:)
  pastel = Pastel.new
  content = build_content_lines(pastel, adapter_name, url, model, payload)
  content.join("\n")
end

.build_content_lines(pastel, adapter_name, url, model, payload) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rubycode/views/adapter/debug_request.rb', line 17

def self.build_content_lines(pastel, adapter_name, url, model, payload)
  [
    "",
    pastel.yellow.bold("=== DEBUG REQUEST ==="),
    "#{pastel.bold("Adapter:")} #{adapter_name}",
    "#{pastel.bold("URL:")} #{url}",
    "#{pastel.bold("Model:")} #{model}",
    "",
    pastel.bold("Payload:"),
    JSON.pretty_generate(payload),
    pastel.yellow.bold("=" * 21)
  ]
end