diff --git a/lib/freshbooks/base.rb b/lib/freshbooks/base.rb index 2a7122a..503a027 100644 --- a/lib/freshbooks/base.rb +++ b/lib/freshbooks/base.rb @@ -24,6 +24,7 @@ def self.new_from_xml(xml_root) self.schema_definition.members.each do |member_name, member_options| node = xml_root.elements[member_name.dup] next if node.nil? + next if XmlSerializer.deprecated? node value = FreshBooks::XmlSerializer.to_value(node, member_options[:type]) object.send("#{member_name}=", value) diff --git a/lib/freshbooks/xml_serializer.rb b/lib/freshbooks/xml_serializer.rb index 2059b6b..e46f831 100644 --- a/lib/freshbooks/xml_serializer.rb +++ b/lib/freshbooks/xml_serializer.rb @@ -13,5 +13,10 @@ def self.to_node(member_name, value, type) def self.create_serializer(type) "FreshBooks::XmlSerializer::#{type.to_s.classify}Serializer".constantize end + + def self.deprecated?(node) + !node.attribute('deprecated').nil? + end + end end diff --git a/lib/freshbooks/xml_serializer/serializers.rb b/lib/freshbooks/xml_serializer/serializers.rb index f6e21a4..adbabe1 100644 --- a/lib/freshbooks/xml_serializer/serializers.rb +++ b/lib/freshbooks/xml_serializer/serializers.rb @@ -86,8 +86,8 @@ def self.to_node(member_name, value) def self.to_value(xml_val) xml_val.elements.map { |elem| - FreshBooks::const_get(elem.name.camelize)::new_from_xml(elem) - } + FreshBooks::const_get(elem.name.camelize)::new_from_xml(elem) unless XmlSerializer.deprecated? elem + }.compact end end