Class: Yext::Api::Utils::DefaultParameters
- Inherits:
-
Faraday::Response::Middleware
- Object
- Faraday::Response::Middleware
- Yext::Api::Utils::DefaultParameters
- Defined in:
- lib/yext/api/utils/default_parameters.rb
Overview
Faraday Middleware for adding Configuration default values to API calls as needed.
Most options can be set via scopes and the soped values will be kept if they are used.
The following configuration options are defaulted:
validation_level: Added to query parameters if not already there and is not nil
api_key: Added to query parameters if not already there
api_version: Added to qeury parameters if not already there
account_id: Inserted into the path if the path includes the Account default URI and no
account_id was specified.
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
Instance Method Summary collapse
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
17 18 19 |
# File 'lib/yext/api/utils/default_parameters.rb', line 17 def configuration @configuration end |
Instance Method Details
#call(request_env) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/yext/api/utils/default_parameters.rb', line 19 def call(request_env) @configuration = Yext::Api.configuration url = request_env[:url] params = Rack::Utils.parse_nested_query(url.query).with_indifferent_access add_username_headers(request_env, configuration, params) add_default_query_params(configuration, params) save_query_params(url, params) @app.call(request_env) end |