class Telnyx::TelnyxClient::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
api_key[RW]
body[RW]
method[RW]
path[RW]
query_params[RW]
request_id[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. For example, we should trust whatever came back in a `Telnyx-Version` header beyond what configuration information that we might have had available.
# File lib/telnyx/telnyx_client.rb, line 444 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.request_id = headers["X-Request-Id"] context end