Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mrikhter opened this issue Apr 20, 2018 · 0 comments
Open

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

mrikhter opened this issue Apr 20, 2018 · 0 comments

Comments

@mrikhter
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant