lib/sms_notify/response.rb in cdyne-sms-notify-0.9.6 vs lib/sms_notify/response.rb in cdyne-sms-notify-0.10.0

- old
+ new

@@ -1,12 +1,19 @@ require 'xmlsimple' module SmsNotify # Handles parsing a CDYNE SmsNotify! XML response # into a Ruby-like hash. class Response - # Converts XML into a Ruby-like hash - def self.parse(xml_response_body) - parser = XmlSimple.new({'ForceArray' => false, 'KeepRoot' => true, 'SuppressEmpty' => nil}) - parser.xml_in(xml_response_body) - end + class << self + # Converts XML into a Ruby-like hash + def parse(response) + if response.is_a?(SOAP::Mapping::Object) + soap_response = SoapResponse.new(response) + soap_response.to_hash + else + parser = XmlSimple.new({'ForceArray' => false, 'KeepRoot' => true, 'SuppressEmpty' => nil}) + parser.xml_in(response) + end + end + end end end