Class: Libis::Services::Rosetta::User

Inherits:
Object
  • Object
show all
Defined in:
lib/libis/services/rosetta/user.rb

Constant Summary collapse

RECORD_TYPE =
%w'USER CONTACT ORGANIZATION STAFF PUBLIC'
USER_STATUS =
%w'ACTIVE INACTIVE DELETED'
USER_ROLES_STATUS =
%w'NEW ACTIVE INACTIVE PENDING DELETED'
USER_TYPE =
%w'CASUAL INTERNAL EXTERNAL INTEXTAUTH'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_xml(xml) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
# File 'lib/libis/services/rosetta/user.rb', line 57

def self.from_xml(xml)
  xml_doc = Libis::Tools::XmlDocument.parse(xml)
  hash = xml_doc.to_hash(
      strip_namespaces: true,
      delete_namespace_attributes: true,
      empty_tag_value: nil,
      convert_tags_to: lambda(&:to_sym)
  )
  # noinspection RubyArgCount
  self.new(hash[:producer_info])
end

Instance Method Details

#to_hashObject



41
42
43
# File 'lib/libis/services/rosetta/user.rb', line 41

def to_hash
  super.cleanup
end

#to_xmlObject



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/libis/services/rosetta/user.rb', line 45

def to_xml
  Libis::Tools::XmlDocument.build do |xml|
    # noinspection RubyResolve
    xml. {
      xml.parent.default_namespace = 'http://www.exlibrisgroup.com/xsd/dps/backoffice/service'
      self.attributes.each do |name, value|
        xml.send(name, xmlns: '') { xml.text(value) } if value
      end
    }
  end.to_xml
end