You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I needed to add tasks to projects using your code, but found that the FreshBooks API rejects any tasks within project XML that include anything other than 'rate' and 'task_id'. My quick-and-dirty solution was to override Task's to_xml to only include those attributes:
class Task < FreshBooks::Task
def to_xml(elem_name = nil)
# The root element is the class name underscored
elem_name ||= self.class.to_s.split('::').last.underscore
root = REXML::Element.new(elem_name)
# only add rate and id to root elem
element = FreshBooks::XmlSerializer.to_node('rate', self.rate, 'fixnum')
root.add_element(element) if element != nil
# add id
element = FreshBooks::XmlSerializer.to_node('task_id', self.task_id, 'fixnum')
root.add_element(element) if element != nil
root.to_s
end
end
I imagine this needs more thought to solve as the above is a pretty messy solution. Perhaps another attribute when defining the attribute schema that defines whether or not each attribute should be included in upload XML. I noticed readonly attributes are excluded, but these aren't readonly.
The text was updated successfully, but these errors were encountered:
I needed to add tasks to projects using your code, but found that the FreshBooks API rejects any tasks within project XML that include anything other than 'rate' and 'task_id'. My quick-and-dirty solution was to override Task's to_xml to only include those attributes:
I imagine this needs more thought to solve as the above is a pretty messy solution. Perhaps another attribute when defining the attribute schema that defines whether or not each attribute should be included in upload XML. I noticed
readonly
attributes are excluded, but these aren't readonly.The text was updated successfully, but these errors were encountered: