Class: Stripe::StripeResponse

Inherits:
Object
  • Object
show all
Includes:
StripeResponseBase
Defined in:
lib/stripe/stripe_response.rb

Overview

StripeResponse encapsulates some vitals of a response that came back from the Stripe API.

Constant Summary collapse

Headers =

We have to alias StripeResponseHeaders to StripeResponse::Headers, as this class used to be embedded within StripeResponse and we want to be backwards compatible.

StripeResponseHeaders

Instance Attribute Summary collapse

Attributes included from StripeResponseBase

#http_headers, #http_status, #request_id

Class Method Summary collapse

Methods included from StripeResponseBase

populate_for_net_http

Instance Attribute Details

#dataObject

The data contained by the HTTP body of the response deserialized from JSON.



72
73
74
# File 'lib/stripe/stripe_response.rb', line 72

def data
  @data
end

#http_bodyObject

The raw HTTP body of the response.



75
76
77
# File 'lib/stripe/stripe_response.rb', line 75

def http_body
  @http_body
end

Class Method Details

.from_net_http(http_resp) ⇒ Object

Initializes a StripeResponse object from a Net::HTTP::HTTPResponse object.



79
80
81
82
83
84
85
# File 'lib/stripe/stripe_response.rb', line 79

def self.from_net_http(http_resp)
  resp = StripeResponse.new
  resp.data = JSON.parse(http_resp.body, symbolize_names: true)
  resp.http_body = http_resp.body
  StripeResponseBase.populate_for_net_http(resp, http_resp)
  resp
end