Skip to content

Attribute keys for non-Onfleet objects are not being camelized #12

Description

@mrikhter

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions