class Raddocs::Request
Documented response
@param attributes [Hash]
Attributes
Public Class Methods
@param attributes [Hash] @option attributes [Hash] “request_headers”
Hash of request headers, not in rack format
@option attributes [String] “request_method” @option attributes [String] “request_path” @option attributes [Hash] “request_query_parameters”
Query parameters pulled from the request if a GET request
@option attributes [String] “request_body” @option attributes [String] “curl” Formatted
cURL request
@option attributes [String] “response_status” @option attributes [Hash] “response_headers”
Hash of response headers, not in rack format
@option attributes [String] “response_body”
# File lib/raddocs/models.rb, line 249 def initialize(attributes) @attrs = attributes @request_headers = attributes.fetch("request_headers") @request_method = attributes.fetch("request_method") @request_path = attributes.fetch("request_path") @request_query_parameters = attributes.fetch("request_query_parameters", nil) @request_body = attributes.fetch("request_body", nil) @curl = attributes.fetch("curl", nil) @response_status = attributes.fetch("response_status") @response_headers = attributes.fetch("response_headers", {}) @response_body = attributes.fetch("response_body", nil) end
Public Instance Methods
@return [Boolean] true if cURL command is present
# File lib/raddocs/models.rb, line 297 def curl? !@curl.nil? end
@return [Boolean] true if request body is present
# File lib/raddocs/models.rb, line 281 def request_body? !@request_body.nil? end
Request
headers must be set @return [String] Content type of the request
# File lib/raddocs/models.rb, line 292 def request_content_type @request_headers["Content-Type"] end
There are unwanted indents if this was a simple each and output in haml
# File lib/raddocs/models.rb, line 264 def request_headers @request_headers.map do |header, value| "#{header}: #{value}" end.join("\n") end
@return [Boolean] true if request headers are present
# File lib/raddocs/models.rb, line 286 def request_headers? request_headers.length > 0 end
@return [String] joined query parameters, eg: “key=valuenkey=value”
# File lib/raddocs/models.rb, line 271 def request_query_parameters @request_query_parameters.map { |k,v| "#{k}=#{v}" }.join("\n") end
@return [Boolean] true if request query parameters are present
# File lib/raddocs/models.rb, line 276 def request_query_parameters? !@request_query_parameters.empty? end
@return [Boolean] true if the response is present
# File lib/raddocs/models.rb, line 302 def response? !@response_status.nil? end
@return [Boolean] true if response body is present
# File lib/raddocs/models.rb, line 314 def response_body? !@response_body.nil? end
Response headers must be set @return [String] Content type of the response
# File lib/raddocs/models.rb, line 325 def response_content_type @response_headers["Content-Type"] end
There are unwanted indents if this was a simple each and output in haml
# File lib/raddocs/models.rb, line 307 def response_headers @response_headers.map do |header, value| "#{header}: #{value}" end.join("\n") end
@return [Boolean] true if response headers are present
# File lib/raddocs/models.rb, line 319 def response_headers? response_headers.length > 0 end