Class: Experian::Response
- Inherits:
-
Object
- Object
- Experian::Response
- Defined in:
- lib/experian/response.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#xml ⇒ Object
readonly
Returns the value of attribute xml.
Instance Method Summary collapse
- #completion_code ⇒ Object
- #completion_message ⇒ Object
- #error? ⇒ Boolean
- #error_action_indicator ⇒ Object
- #error_action_indicator_message ⇒ Object
- #error_code ⇒ Object
- #error_message ⇒ Object
-
#error_message_segment ⇒ Object
The error message segment is embedded in the error segment :(.
-
#error_segment ⇒ Object
error_segment returns the entire host response (segments 100, 200, 900) since error responses do not separate segments with “@”.
- #header_segment ⇒ Object
- #host_response ⇒ Object
-
#initialize(xml) ⇒ Response
constructor
A new instance of Response.
- #segment(segment_id) ⇒ Object
- #segments(segment_id = nil) ⇒ Object
- #success? ⇒ Boolean
- #transaction_id ⇒ Object
Constructor Details
#initialize(xml) ⇒ Response
Returns a new instance of Response.
8 9 10 11 |
# File 'lib/experian/response.rb', line 8 def initialize(xml) @xml = xml @response = parse_xml_response end |
Instance Attribute Details
#xml ⇒ Object (readonly)
Returns the value of attribute xml.
6 7 8 |
# File 'lib/experian/response.rb', line 6 def xml @xml end |
Instance Method Details
#completion_code ⇒ Object
21 22 23 |
# File 'lib/experian/response.rb', line 21 def completion_code @response["CompletionCode"] end |
#completion_message ⇒ Object
25 26 27 |
# File 'lib/experian/response.rb', line 25 def Experian::COMPLETION_CODES[completion_code] end |
#error? ⇒ Boolean
61 62 63 |
# File 'lib/experian/response.rb', line 61 def error? completion_code != "0000" || !error_segment.nil? end |
#error_action_indicator ⇒ Object
76 77 78 79 |
# File 'lib/experian/response.rb', line 76 def error_action_indicator return unless error_segment [9] end |
#error_action_indicator_message ⇒ Object
81 82 83 |
# File 'lib/experian/response.rb', line 81 def Experian::ERROR_ACTION_INDICATORS[error_action_indicator] end |
#error_code ⇒ Object
71 72 73 74 |
# File 'lib/experian/response.rb', line 71 def error_code return unless error_segment [6..8].to_i end |
#error_message ⇒ Object
13 14 15 |
# File 'lib/experian/response.rb', line 13 def @response["ErrorMessage"] || (Experian::Error.(error_code) if error_code) end |
#error_message_segment ⇒ Object
The error message segment is embedded in the error segment :(
66 67 68 69 |
# File 'lib/experian/response.rb', line 66 def return unless error_segment error_segment[error_segment.index("200")..-1] end |
#error_segment ⇒ Object
error_segment returns the entire host response (segments 100, 200, 900) since error responses do not separate segments with “@”.
53 54 55 |
# File 'lib/experian/response.rb', line 53 def error_segment segment(100) end |
#header_segment ⇒ Object
47 48 49 |
# File 'lib/experian/response.rb', line 47 def header_segment segment(110) end |
#host_response ⇒ Object
17 18 19 |
# File 'lib/experian/response.rb', line 17 def host_response @response["HostResponse"] end |
#segment(segment_id) ⇒ Object
43 44 45 |
# File 'lib/experian/response.rb', line 43 def segment(segment_id) segments(segment_id).first end |
#segments(segment_id = nil) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/experian/response.rb', line 33 def segments(segment_id = nil) @segments ||= host_response ? host_response.split("@") : [] if segment_id @segments.select { |segment| segment.length >= 3 ? segment[0..2].to_i == segment_id : false } else @segments end end |
#success? ⇒ Boolean
57 58 59 |
# File 'lib/experian/response.rb', line 57 def success? completion_code == "0000" && !header_segment.nil? end |
#transaction_id ⇒ Object
29 30 31 |
# File 'lib/experian/response.rb', line 29 def transaction_id @response["TransactionId"] end |