rikas / zoho_hub

Zoho CRM API V2 Wrapper
MIT License
25 stars 30 forks source link

Inconsistent behavior when no attribute_translations are defined #58

Closed gerardo-navarro closed 2 years ago

gerardo-navarro commented 4 years ago

When using ZohoHub::BaseRecord without attribute_translation, then updating a zoho record does not work because the attributes are camelcased by default. Here is an example.

class Deal < ZohoHub::BaseRecord
  attributes :id, :custom_deal_module_field
  # No attribute_translation defined
end

Deal.find("123123131312"). custom_deal_module_field <= This will work like charm, because initializing a base record does not expect a camelcase field by default, see https://github.com/rikas/zoho_hub/blob/master/lib/zoho_hub/base_record.rb#L173

Deal.update("123451231213123", custom_deal_module_field: "some Value") <= This will not work, because zoho_hub camelcases the field name to Custom_Deal_Module_Field and the ZOHO API does not know how to handle this, see https://github.com/rikas/zoho_hub/blob/master/lib/zoho_hub/with_attributes.rb#L51

Although it can be easily fixed by defining an attribute_translation, it seems to me like inconsistent behavior.

What do you think?

gerardo-navarro commented 4 years ago

This issue seems similar to https://github.com/rikas/zoho_hub/issues/29

@rikas What to do think?

rikas commented 3 years ago

Yeah seems like the same thing, I've been struggling to get time to dedicate to this project, will try to review that ASAP and maybe merge.

rikas commented 2 years ago

After researching a little bit I don't see an easy way to fix this... I would rather keep using attribute translations where needed. The default fields in Zoho are capitalized, so it will work for the default ones.

If you have custom fields with a different standard I would say it's up to you to make sure they work.