class Zaius::RequestLogContext

RequestLogContext stores information about a request that's begin made so that we can log certain information. It's useful because it means that we don't have to pass around as many parameters.

Attributes

account[RW]
api_key[RW]
api_version[RW]
body[RW]
method[RW]
path[RW]
query_params[RW]
request_id[RW]
url[RW]

Public Instance Methods

dup_from_response(resp) click to toggle source

The idea with this method is that we might want to update some of context information because a response that we've received from the API contains information that's more authoritative than what we started with for a request.

# File lib/zaius/zaius_client.rb, line 257
def dup_from_response(resp)
  return self if resp.nil?

  # Faraday's API is a little unusual. Normally it'll produce a response
  # object with a `headers` method, but on error what it puts into
  # `e.response` is an untyped `Hash`.
  headers = if resp.is_a?(Faraday::Response)
              resp.headers
            else
              resp[:headers]
            end

  context = dup
  context
end