Attribute keys for non-Onfleet objects are not being camelized
mrikhter opened this issue · 0 comments
mrikhter commented
Hi there. We are trying to create a task with barcodes, and set the barcode scan to block completion. The attributes method is not correctly camelizing the keys for attributes which are not Onfleet (gem) objects, therefore these attributes are ignored by Onfleet.
Example:
Onfleet::Task.create(
destination: '138473',
recipients: ['13294713'],
barcodes: [{ data: 'whatever', block_completion: true }]
)
def attributes
attrs = Hash.new
instance_variables.each do |var|
str = var.to_s.gsub /^@/, ''
if respond_to? "#{str}="
instance_var = instance_variable_get(var)
if klass = Util.object_classes[str]
# Removed for readability
else
# The barcode is not an Onfleet object so the array is simply added to the attrs without
# camelizing the keys
attrs[Util.to_camel_case_lower(str).to_sym] = instance_var
end
end
end
attrs
end
Thanks