Sha256: 35fcac5dda56c52d6f6869ce9de73b4d9271eb72e7de514664e4cdb247b78afb
Contents?: true
Size: 1.12 KB
Versions: 2
Compression:
Stored size: 1.12 KB
Contents
require 'multi_xml' class Gillbus class BaseResponse extend Fields include UpdateAttrs attr_accessor :data attr_accessor :session_id attr_accessor :error_code attr_accessor :error_message attr_accessor :external_error_message attr_accessor :request_time def error? !error_code.nil? end def self.parse(data, instance: new, options: options) # ugly if data['MESSAGE'] instance.error_code = data['MESSAGE']['CODE'].to_i instance.error_message = data['MESSAGE']['TEXT'] instance.external_error_message = data['MESSAGE']['EXT_TEXT'] else super(data, instance: instance, options: options) end # for debugging? instance.data = data instance end def self.parse_string(xml_string, **options) xml = MultiXml.parse(xml_string) # <DATA/> is a valid response return ParseError.new(xml_string) unless xml.key?('DATA') data = xml['DATA'] || {} parse(data, instance: new, options: options) rescue MultiXml::ParseError, ArgumentError ParseError.new(xml_string) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gillbus-0.16.9 | lib/gillbus/base_response.rb |
gillbus-0.16.8 | lib/gillbus/base_response.rb |