Class: Justifi::JustifiResponse
- Inherits:
-
Object
- Object
- Justifi::JustifiResponse
- Extended by:
- Gem::Deprecate
- Includes:
- JustifiResponseBase
- Defined in:
- lib/justifi/justifi_response.rb
Overview
JustifiResponse encapsulates some vitals of a response that came back from the Justifi API.
Instance Attribute Summary collapse
-
#data ⇒ Object
The data contained by the HTTP body of the response deserialized from JSON.
-
#error_details ⇒ Object
The error hash from JustiFi API.
-
#error_message ⇒ Object
The error error_message from JustiFi API.
-
#http_body ⇒ Object
The raw HTTP body of the response.
-
#success ⇒ Object
The boolean flag based on Net::HTTPSuccess.
Attributes included from JustifiResponseBase
#http_headers, #http_status, #request_id
Class Method Summary collapse
-
.from_net_http(http_resp) ⇒ Object
Initializes a JustifiResponse object from a Net::HTTP::HTTPResponse object.
Methods included from JustifiResponseBase
Instance Attribute Details
#data ⇒ Object
The data contained by the HTTP body of the response deserialized from JSON.
65 66 67 |
# File 'lib/justifi/justifi_response.rb', line 65 def data @data end |
#error_details ⇒ Object
The error hash from JustiFi API
77 78 79 |
# File 'lib/justifi/justifi_response.rb', line 77 def error_details @error_details end |
#error_message ⇒ Object
The error error_message from JustiFi API
71 72 73 |
# File 'lib/justifi/justifi_response.rb', line 71 def end |
#http_body ⇒ Object
The raw HTTP body of the response.
68 69 70 |
# File 'lib/justifi/justifi_response.rb', line 68 def http_body @http_body end |
#success ⇒ Object
The boolean flag based on Net::HTTPSuccess
74 75 76 |
# File 'lib/justifi/justifi_response.rb', line 74 def success @success end |
Class Method Details
.from_net_http(http_resp) ⇒ Object
Initializes a JustifiResponse object from a Net::HTTP::HTTPResponse object.
81 82 83 84 85 86 87 88 89 90 |
# File 'lib/justifi/justifi_response.rb', line 81 def self.from_net_http(http_resp) resp = JustifiResponse.new resp.data = JSON.parse(http_resp.body, symbolize_names: true) resp.http_body = http_resp.body resp.success = http_resp.is_a? Net::HTTPSuccess resp. = resp.data.dig(:error, :message) resp.error_details = resp.data.dig(:error) JustifiResponseBase.populate_for_net_http(resp, http_resp) resp end |