Class: Intacct::FunctionResult
- Inherits:
-
Object
- Object
- Intacct::FunctionResult
- Defined in:
- lib/intacct/function_result.rb
Instance Attribute Summary collapse
-
#control_id ⇒ Object
readonly
Returns the value of attribute control_id.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#xml_data ⇒ Object
readonly
Returns the value of attribute xml_data.
Instance Method Summary collapse
-
#initialize(xml_entry) ⇒ FunctionResult
constructor
A new instance of FunctionResult.
- #parsed_data ⇒ Object
- #push_error_messages ⇒ Object
- #successful? ⇒ Boolean
Constructor Details
#initialize(xml_entry) ⇒ FunctionResult
Returns a new instance of FunctionResult.
7 8 9 10 11 |
# File 'lib/intacct/function_result.rb', line 7 def initialize(xml_entry) @status = xml_entry.xpath("status").text @control_id = xml_entry.xpath("controlid").text @xml_data = xml_entry end |
Instance Attribute Details
#control_id ⇒ Object (readonly)
Returns the value of attribute control_id.
5 6 7 |
# File 'lib/intacct/function_result.rb', line 5 def control_id @control_id end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
5 6 7 |
# File 'lib/intacct/function_result.rb', line 5 def status @status end |
#xml_data ⇒ Object (readonly)
Returns the value of attribute xml_data.
5 6 7 |
# File 'lib/intacct/function_result.rb', line 5 def xml_data @xml_data end |
Instance Method Details
#parsed_data ⇒ Object
17 18 19 20 |
# File 'lib/intacct/function_result.rb', line 17 def parsed_data hash = Crack::XML.parse(@xml_data.to_s).with_indifferent_access successful? ? hash.fetch("result") : hash end |
#push_error_messages ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/intacct/function_result.rb', line 22 def error_details = parsed_data.dig(:result, :errormessage, :error) error_details = [error_details] unless error_details.is_a?(Array) error_details.compact.map do |error_data| [error_data[:description2], error_data[:correction]].compact.join(" ") end end |
#successful? ⇒ Boolean
13 14 15 |
# File 'lib/intacct/function_result.rb', line 13 def successful? @status == "success" end |