Method: Jamf::XMLWorkaround.data_via_xml

Defined in:
lib/jamf/api/classic/xml_workaround.rb

.data_via_xml(rsrc, map, cnx) ⇒ Object

When APIObject classes are fetched, API JSON data is retrieved by the APIObject#lookup_object_data method, which parses the JSON into Ruby data.

If the APIObject class has the constant USE_XML_WORKAROUND defined, that means the JSON data from the API is invalid, incorrect, or otherwise borked. So instead, the XML is retrieved from the API here.

It is then parsed by using the methods in this module and returned to the APIObject#lookup_object_data method, which then treats it normally.



125
126
127
128
129
130
131
132
133
# File 'lib/jamf/api/classic/xml_workaround.rb', line 125

def self.data_via_xml(rsrc, map, cnx)
  raw_xml = cnx.c_get(rsrc, :xml)
  xmlroot = REXML::Document.new(raw_xml).root
  hash_from_xml = {}
  map.each do |key, model|
    hash_from_xml[key] = process_map_item model, xmlroot
  end
  hash_from_xml
end