Module: PriceHubble::Client::Utils::Request
- Extended by:
- ActiveSupport::Concern
- Included in:
- Base
- Defined in:
- lib/price_hubble/client/utils/request.rb
Overview
Some helpers to prepare requests in a general way.
Constant Summary collapse
- CONTENT_TYPE =
A common HTTP content type to symbol mapping for correct header settings.
{ json: 'application/json', multipart: 'multipart/form-data', url_encoded: 'application/x-www-form-urlencoded' }.freeze
Instance Method Summary collapse
-
#use_authentication(req) ⇒ Object
Use the configured identity to authenticate the given request.
-
#use_default_context(req, action) ⇒ Object
Use the default request context to identificate the request.
Instance Method Details
#use_authentication(req) ⇒ Object
Use the configured identity to authenticate the given request.
23 24 25 |
# File 'lib/price_hubble/client/utils/request.rb', line 23 def use_authentication(req) req.params.merge!(access_token: PriceHubble.identity.access_token) end |
#use_default_context(req, action) ⇒ Object
Use the default request context to identificate the request.
31 32 33 34 35 36 |
# File 'lib/price_hubble/client/utils/request.rb', line 31 def use_default_context(req, action) req..context ||= {} req..context.merge!(client: self.class, action: action, request_id: SecureRandom.hex(3)) end |