Class: Justifi::JustifiResponse
- Inherits:
-
Object
- Object
- Justifi::JustifiResponse
- 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_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.
63 64 65 |
# File 'lib/justifi/justifi_response.rb', line 63 def data @data end |
#error_message ⇒ Object
The error error_message from JustiFi API
69 70 71 |
# File 'lib/justifi/justifi_response.rb', line 69 def @error_message end |
#http_body ⇒ Object
The raw HTTP body of the response.
66 67 68 |
# File 'lib/justifi/justifi_response.rb', line 66 def http_body @http_body end |
#success ⇒ Object
The boolean flag based on Net::HTTPSuccess
72 73 74 |
# File 'lib/justifi/justifi_response.rb', line 72 def success @success end |
Class Method Details
.from_net_http(http_resp) ⇒ Object
Initializes a JustifiResponse object from a Net::HTTP::HTTPResponse object.
76 77 78 79 80 81 82 83 84 |
# File 'lib/justifi/justifi_response.rb', line 76 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) JustifiResponseBase.populate_for_net_http(resp, http_resp) resp end |