Class: Miniswag::RequestFactory
- Inherits:
-
Object
- Object
- Miniswag::RequestFactory
- Defined in:
- lib/miniswag/request_factory.rb
Instance Attribute Summary collapse
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#params ⇒ Object
Returns the value of attribute params.
Instance Method Summary collapse
- #build_request ⇒ Object
-
#initialize(metadata, params = {}, headers = {}, config = Miniswag.config) ⇒ RequestFactory
constructor
A new instance of RequestFactory.
Constructor Details
#initialize(metadata, params = {}, headers = {}, config = Miniswag.config) ⇒ RequestFactory
Returns a new instance of RequestFactory.
13 14 15 16 17 18 |
# File 'lib/miniswag/request_factory.rb', line 13 def initialize(, params = {}, headers = {}, config = Miniswag.config) @config = config @metadata = @params = params.transform_keys(&:to_s) @headers = headers.transform_keys(&:to_s) end |
Instance Attribute Details
#headers ⇒ Object
Returns the value of attribute headers.
11 12 13 |
# File 'lib/miniswag/request_factory.rb', line 11 def headers @headers end |
#metadata ⇒ Object
Returns the value of attribute metadata.
11 12 13 |
# File 'lib/miniswag/request_factory.rb', line 11 def @metadata end |
#params ⇒ Object
Returns the value of attribute params.
11 12 13 |
# File 'lib/miniswag/request_factory.rb', line 11 def params @params end |
Instance Method Details
#build_request ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/miniswag/request_factory.rb', line 20 def build_request openapi_spec = @config.get_openapi_spec([:openapi_spec]) parameters = (, openapi_spec) {}.tap do |request| add_verb(request, ) add_path(request, , openapi_spec, parameters) add_headers(request, , openapi_spec, parameters) add_payload(request, parameters) end end |