Class: Stripe::StripeClient::RequestLogContext
- Inherits:
-
Object
- Object
- Stripe::StripeClient::RequestLogContext
- Defined in:
- lib/stripe/stripe_client.rb
Overview
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.
Instance Attribute Summary collapse
-
#account ⇒ Object
Returns the value of attribute account.
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#api_version ⇒ Object
Returns the value of attribute api_version.
-
#body ⇒ Object
Returns the value of attribute body.
-
#idempotency_key ⇒ Object
Returns the value of attribute idempotency_key.
-
#method ⇒ Object
Returns the value of attribute method.
-
#path ⇒ Object
Returns the value of attribute path.
-
#query_params ⇒ Object
Returns the value of attribute query_params.
-
#request_id ⇒ Object
Returns the value of attribute request_id.
Instance Method Summary collapse
-
#dup_from_response(resp) ⇒ Object
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.
Instance Attribute Details
#account ⇒ Object
Returns the value of attribute account.
574 575 576 |
# File 'lib/stripe/stripe_client.rb', line 574 def account @account end |
#api_key ⇒ Object
Returns the value of attribute api_key.
575 576 577 |
# File 'lib/stripe/stripe_client.rb', line 575 def api_key @api_key end |
#api_version ⇒ Object
Returns the value of attribute api_version.
576 577 578 |
# File 'lib/stripe/stripe_client.rb', line 576 def api_version @api_version end |
#body ⇒ Object
Returns the value of attribute body.
573 574 575 |
# File 'lib/stripe/stripe_client.rb', line 573 def body @body end |
#idempotency_key ⇒ Object
Returns the value of attribute idempotency_key.
577 578 579 |
# File 'lib/stripe/stripe_client.rb', line 577 def idempotency_key @idempotency_key end |
#method ⇒ Object
Returns the value of attribute method.
578 579 580 |
# File 'lib/stripe/stripe_client.rb', line 578 def method @method end |
#path ⇒ Object
Returns the value of attribute path.
579 580 581 |
# File 'lib/stripe/stripe_client.rb', line 579 def path @path end |
#query_params ⇒ Object
Returns the value of attribute query_params.
580 581 582 |
# File 'lib/stripe/stripe_client.rb', line 580 def query_params @query_params end |
#request_id ⇒ Object
Returns the value of attribute request_id.
581 582 583 |
# File 'lib/stripe/stripe_client.rb', line 581 def request_id @request_id end |
Instance Method Details
#dup_from_response(resp) ⇒ Object
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 ‘Stripe-Version` header beyond what configuration information that we might have had available.
589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 |
# File 'lib/stripe/stripe_client.rb', line 589 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 |