class Stripe::StripeClient::RequestLogContext

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

def dup_from_response(resp)

might have had available.
a `Stripe-Version` header beyond what configuration information that we
with for a request. For example, we should trust whatever came back in
contains information that's more authoritative than what we started
context information because a response that we've received from the API
The idea with this method is that we might want to update some of
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.account = headers["Stripe-Account"]
  context.api_version = headers["Stripe-Version"]
  context.idempotency_key = headers["Idempotency-Key"]
  context.request_id = headers["Request-Id"]
  context
end